[PATCH v2] drm/amd/amdgpu: S4 issue for amdgpu

Christian König deathsimple at vodafone.de
Wed Sep 7 08:15:03 UTC 2016


Am 07.09.2016 um 10:08 schrieb Shawn Starr:
> On Saturday, September 3, 2016 2:56:51 PM EDT jimqu wrote:
>> reset the asic if adapter is not powerdown when doing freeze()
>> thaw() and restore(), in order to get a valid state of adapter.
>>
>> Change-Id: Ibb03ab3c2ce6ef3c83affbe767308dc22474f563
>> Signed-off-by: JimQu <Jim.Qu at amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 19 +++++++++++++------
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 18 ++++++++++++++++--
>>   2 files changed, 29 insertions(+), 8 deletions(-)
>>
> Seems ok on CIK here with 4.8-rc5 + drm-next-4.9-wip merged in, I usually
> hibernate and reboot into Windows sometimes. I ran pm-hibernate manually.
>
> When you set:
> echo reboot > /sys/power/disk
>
> Tested By: Shawn Starr <shawn.starr at rogers.com>

I unfortunately don't have the slightest idea how this part of PM works 
and Alex is on vacation. But it sounds important so let's try to get 
this into out branches ASAP.

One minor nit pick below, apart from that looks good to me.

>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 6510514..f17fc6d 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>> @@ -1937,6 +1937,10 @@ int amdgpu_device_suspend(struct drm_device *dev,
>> bool suspend, bool fbcon) /* Shut down the device */
>>   		pci_disable_device(dev->pdev);
>>   		pci_set_power_state(dev->pdev, PCI_D3hot);
>> +	} else {
>> +		r = amdgpu_asic_reset(adev);
>> +		if (r)
>> +			DRM_ERROR("amdgpu asic reset failed\n");
>>   	}
>>
>>   	if (fbcon) {
>> @@ -1967,22 +1971,25 @@ int amdgpu_device_resume(struct drm_device *dev,
>> bool resume, bool fbcon) dev->switch_power_state ==
>> DRM_SWITCH_POWER_DYNAMIC_OFF)
>>   		return 0;
>>
>> -	if (fbcon) {
>> +	if (fbcon)
>>   		console_lock();
>> -	}
>> +
>>   	if (resume) {
>>   		pci_set_power_state(dev->pdev, PCI_D0);
>>   		pci_restore_state(dev->pdev);
>> -		if (pci_enable_device(dev->pdev)) {
>> +		if (r = pci_enable_device(dev->pdev)) {
>>   			if (fbcon)
>>   				console_unlock();
>> -			return -1;
>> +			return r;
>>   		}
>>   	}
>>
>>   	/* post card */
>> -	if (!amdgpu_card_posted(adev))
>> -		amdgpu_atom_asic_init(adev->mode_info.atom_context);
>> +	if (!amdgpu_card_posted(adev) || !resume) {
>> +		r = amdgpu_atom_asic_init(adev->mode_info.atom_context);
>> +		if (r)
>> +			DRM_ERROR("amdgpu asic init failed\n");
>> +	}
>>
>>   	r = amdgpu_resume(adev);
>>   	if (r)
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 21b8cd6..c00f4a8 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
>> @@ -520,6 +520,20 @@ static int amdgpu_pmops_thaw(struct device *dev)
>>   	return amdgpu_device_resume(drm_dev, false, true);
>>   }
>>
>> +static int amdgpu_pmops_poweroff(struct device *dev)
>> +{
>> +	struct pci_dev *pdev = to_pci_dev(dev);
>> +	struct drm_device *drm_dev = pci_get_drvdata(pdev);

Please add an empty line between the declaration and code.

With that fixed the patch is Acked-by: Christian König 
<christian.koenig at amd.com>.

Regards,
Christian.

>> +	return amdgpu_device_suspend(drm_dev, true, true);
>> +}
>> +
>> +static int amdgpu_pmops_restore(struct device *dev)
>> +{
>> +	struct pci_dev *pdev = to_pci_dev(dev);
>> +	struct drm_device *drm_dev = pci_get_drvdata(pdev);
>> +	return amdgpu_device_resume(drm_dev, false, true);
>> +}
>> +
>>   static int amdgpu_pmops_runtime_suspend(struct device *dev)
>>   {
>>   	struct pci_dev *pdev = to_pci_dev(dev);
>> @@ -622,8 +636,8 @@ static const struct dev_pm_ops amdgpu_pm_ops = {
>>   	.resume = amdgpu_pmops_resume,
>>   	.freeze = amdgpu_pmops_freeze,
>>   	.thaw = amdgpu_pmops_thaw,
>> -	.poweroff = amdgpu_pmops_freeze,
>> -	.restore = amdgpu_pmops_resume,
>> +	.poweroff = amdgpu_pmops_poweroff,
>> +	.restore = amdgpu_pmops_restore,
>>   	.runtime_suspend = amdgpu_pmops_runtime_suspend,
>>   	.runtime_resume = amdgpu_pmops_runtime_resume,
>>   	.runtime_idle = amdgpu_pmops_runtime_idle,
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx




More information about the amd-gfx mailing list