All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/amdgpu: reset the asic when hibernating
@ 2016-08-22 16:05 Alex Deucher
       [not found] ` <1471881925-27757-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Alex Deucher @ 2016-08-22 16:05 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

Some blocks require a reset to properly resume if there
is no power down of the asic like during various
hibernation steps.

Port of:
274ad65c9d02bdcbee9bae045517864c3521d530
(drm/radeon: hard reset r600 and newer GPU when hibernating.)
from radeon.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  3 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +++++++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 +++---
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 6fa8268..d0d0588 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -2436,7 +2436,8 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
 				 struct drm_file *file_priv);
 void amdgpu_driver_preclose_kms(struct drm_device *dev,
 				struct drm_file *file_priv);
-int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon);
+int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon,
+		       bool freeze);
 int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
 u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 21f4b74..5747e37 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1037,7 +1037,7 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero
 		printk(KERN_INFO "amdgpu: switched off\n");
 		drm_kms_helper_poll_disable(dev);
 		dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
-		amdgpu_suspend_kms(dev, true, true);
+		amdgpu_suspend_kms(dev, true, true, false);
 		dev->switch_power_state = DRM_SWITCH_POWER_OFF;
 	}
 }
@@ -1780,7 +1780,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
  * Returns 0 for success or an error on failure.
  * Called at driver suspend.
  */
-int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
+int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon,
+		       bool freeze)
 {
 	struct amdgpu_device *adev;
 	struct drm_crtc *crtc;
@@ -1844,7 +1845,10 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
 	amdgpu_bo_evict_vram(adev);
 
 	pci_save_state(dev->pdev);
-	if (suspend) {
+	if (freeze) {
+		/* reset the asic during freeze */
+		r = amdgpu_asic_reset(adev);
+	} else if (suspend) {
 		/* Shut down the device */
 		pci_disable_device(dev->pdev);
 		pci_set_power_state(dev->pdev, PCI_D3hot);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 58b1db8..eb4c9b0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -395,7 +395,7 @@ static int amdgpu_pmops_suspend(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
-	return amdgpu_suspend_kms(drm_dev, true, true);
+	return amdgpu_suspend_kms(drm_dev, true, true, false);
 }
 
 static int amdgpu_pmops_resume(struct device *dev)
@@ -409,7 +409,7 @@ static int amdgpu_pmops_freeze(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
-	return amdgpu_suspend_kms(drm_dev, false, true);
+	return amdgpu_suspend_kms(drm_dev, false, true, true);
 }
 
 static int amdgpu_pmops_thaw(struct device *dev)
@@ -434,7 +434,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
 	drm_kms_helper_poll_disable(drm_dev);
 	vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF);
 
-	ret = amdgpu_suspend_kms(drm_dev, false, false);
+	ret = amdgpu_suspend_kms(drm_dev, false, false, false);
 	pci_save_state(pdev);
 	pci_disable_device(pdev);
 	pci_ignore_hotplug(pdev);
-- 
2.5.5

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/2] drm/amdgpu: reset the asic on shutdown
       [not found] ` <1471881925-27757-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
@ 2016-08-22 16:05   ` Alex Deucher
  2016-08-23  1:52   ` [PATCH 1/2] drm/amdgpu: reset the asic when hibernating zhoucm1
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Alex Deucher @ 2016-08-22 16:05 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

This puts the asic into a known good state if the
driver is reloaded subsequently.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 5747e37..9fb9f59 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1756,6 +1756,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
 	if (adev->flags & AMD_IS_PX)
 		vga_switcheroo_fini_domain_pm_ops(adev->dev);
 	vga_client_register(adev->pdev, NULL, NULL, NULL);
+	/* reset the asic at shutdown */
+	r = amdgpu_asic_reset(adev);
 	if (adev->rio_mem)
 		pci_iounmap(adev->pdev, adev->rio_mem);
 	adev->rio_mem = NULL;
-- 
2.5.5

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating
       [not found] ` <1471881925-27757-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2016-08-22 16:05   ` [PATCH 2/2] drm/amdgpu: reset the asic on shutdown Alex Deucher
@ 2016-08-23  1:52   ` zhoucm1
       [not found]     ` <57BBAC6A.6010803-5C7GfCeVMHo@public.gmane.org>
  2016-08-23  4:18   ` Qu, Jim
  2016-08-23  8:05   ` Christian König
  3 siblings, 1 reply; 11+ messages in thread
From: zhoucm1 @ 2016-08-23  1:52 UTC (permalink / raw)
  To: Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

This series is Reviewed-by: Chunming Zhou <david1.zhou@amd.com>



On 2016年08月23日 00:05, Alex Deucher wrote:
> Some blocks require a reset to properly resume if there
> is no power down of the asic like during various
> hibernation steps.
>
> Port of:
> 274ad65c9d02bdcbee9bae045517864c3521d530
> (drm/radeon: hard reset r600 and newer GPU when hibernating.)
> from radeon.
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  3 ++-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +++++++---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 +++---
>   3 files changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 6fa8268..d0d0588 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -2436,7 +2436,8 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
>   				 struct drm_file *file_priv);
>   void amdgpu_driver_preclose_kms(struct drm_device *dev,
>   				struct drm_file *file_priv);
> -int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon);
> +int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon,
> +		       bool freeze);
>   int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
>   u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
>   int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 21f4b74..5747e37 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -1037,7 +1037,7 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero
>   		printk(KERN_INFO "amdgpu: switched off\n");
>   		drm_kms_helper_poll_disable(dev);
>   		dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
> -		amdgpu_suspend_kms(dev, true, true);
> +		amdgpu_suspend_kms(dev, true, true, false);
>   		dev->switch_power_state = DRM_SWITCH_POWER_OFF;
>   	}
>   }
> @@ -1780,7 +1780,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
>    * Returns 0 for success or an error on failure.
>    * Called at driver suspend.
>    */
> -int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
> +int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon,
> +		       bool freeze)
>   {
>   	struct amdgpu_device *adev;
>   	struct drm_crtc *crtc;
> @@ -1844,7 +1845,10 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
>   	amdgpu_bo_evict_vram(adev);
>   
>   	pci_save_state(dev->pdev);
> -	if (suspend) {
> +	if (freeze) {
> +		/* reset the asic during freeze */
> +		r = amdgpu_asic_reset(adev);
> +	} else if (suspend) {
>   		/* Shut down the device */
>   		pci_disable_device(dev->pdev);
>   		pci_set_power_state(dev->pdev, PCI_D3hot);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 58b1db8..eb4c9b0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -395,7 +395,7 @@ static int amdgpu_pmops_suspend(struct device *dev)
>   {
>   	struct pci_dev *pdev = to_pci_dev(dev);
>   	struct drm_device *drm_dev = pci_get_drvdata(pdev);
> -	return amdgpu_suspend_kms(drm_dev, true, true);
> +	return amdgpu_suspend_kms(drm_dev, true, true, false);
>   }
>   
>   static int amdgpu_pmops_resume(struct device *dev)
> @@ -409,7 +409,7 @@ static int amdgpu_pmops_freeze(struct device *dev)
>   {
>   	struct pci_dev *pdev = to_pci_dev(dev);
>   	struct drm_device *drm_dev = pci_get_drvdata(pdev);
> -	return amdgpu_suspend_kms(drm_dev, false, true);
> +	return amdgpu_suspend_kms(drm_dev, false, true, true);
>   }
>   
>   static int amdgpu_pmops_thaw(struct device *dev)
> @@ -434,7 +434,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
>   	drm_kms_helper_poll_disable(drm_dev);
>   	vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF);
>   
> -	ret = amdgpu_suspend_kms(drm_dev, false, false);
> +	ret = amdgpu_suspend_kms(drm_dev, false, false, false);
>   	pci_save_state(pdev);
>   	pci_disable_device(pdev);
>   	pci_ignore_hotplug(pdev);

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* 答复: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating
       [not found]     ` <57BBAC6A.6010803-5C7GfCeVMHo@public.gmane.org>
@ 2016-08-23  2:04       ` Qu, Jim
       [not found]         ` <BY2PR12MB0614D30441286DA319B5BB5A99EB0-K//h7OWB4q5SmL+xRiD5tgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Qu, Jim @ 2016-08-23  2:04 UTC (permalink / raw)
  To: Zhou, David(ChunMing),
	Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Deucher, Alexander

I have a question:

if driver reset the asic in freeze(), Does not need to re-init the asic in thaw()?

Thanks
JimQu

________________________________________
发件人: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 zhoucm1 <david1.zhou@amd.com>
发送时间: 2016年8月23日 9:52:42
收件人: Alex Deucher; amd-gfx@lists.freedesktop.org
抄送: Deucher, Alexander
主题: Re: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating

This series is Reviewed-by: Chunming Zhou <david1.zhou@amd.com>



On 2016年08月23日 00:05, Alex Deucher wrote:
> Some blocks require a reset to properly resume if there
> is no power down of the asic like during various
> hibernation steps.
>
> Port of:
> 274ad65c9d02bdcbee9bae045517864c3521d530
> (drm/radeon: hard reset r600 and newer GPU when hibernating.)
> from radeon.
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  3 ++-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +++++++---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 +++---
>   3 files changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 6fa8268..d0d0588 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -2436,7 +2436,8 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
>                                struct drm_file *file_priv);
>   void amdgpu_driver_preclose_kms(struct drm_device *dev,
>                               struct drm_file *file_priv);
> -int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon);
> +int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon,
> +                    bool freeze);
>   int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
>   u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
>   int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 21f4b74..5747e37 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -1037,7 +1037,7 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero
>               printk(KERN_INFO "amdgpu: switched off\n");
>               drm_kms_helper_poll_disable(dev);
>               dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
> -             amdgpu_suspend_kms(dev, true, true);
> +             amdgpu_suspend_kms(dev, true, true, false);
>               dev->switch_power_state = DRM_SWITCH_POWER_OFF;
>       }
>   }
> @@ -1780,7 +1780,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
>    * Returns 0 for success or an error on failure.
>    * Called at driver suspend.
>    */
> -int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
> +int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon,
> +                    bool freeze)
>   {
>       struct amdgpu_device *adev;
>       struct drm_crtc *crtc;
> @@ -1844,7 +1845,10 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
>       amdgpu_bo_evict_vram(adev);
>
>       pci_save_state(dev->pdev);
> -     if (suspend) {
> +     if (freeze) {
> +             /* reset the asic during freeze */
> +             r = amdgpu_asic_reset(adev);
> +     } else if (suspend) {
>               /* Shut down the device */
>               pci_disable_device(dev->pdev);
>               pci_set_power_state(dev->pdev, PCI_D3hot);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 58b1db8..eb4c9b0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -395,7 +395,7 @@ static int amdgpu_pmops_suspend(struct device *dev)
>   {
>       struct pci_dev *pdev = to_pci_dev(dev);
>       struct drm_device *drm_dev = pci_get_drvdata(pdev);
> -     return amdgpu_suspend_kms(drm_dev, true, true);
> +     return amdgpu_suspend_kms(drm_dev, true, true, false);
>   }
>
>   static int amdgpu_pmops_resume(struct device *dev)
> @@ -409,7 +409,7 @@ static int amdgpu_pmops_freeze(struct device *dev)
>   {
>       struct pci_dev *pdev = to_pci_dev(dev);
>       struct drm_device *drm_dev = pci_get_drvdata(pdev);
> -     return amdgpu_suspend_kms(drm_dev, false, true);
> +     return amdgpu_suspend_kms(drm_dev, false, true, true);
>   }
>
>   static int amdgpu_pmops_thaw(struct device *dev)
> @@ -434,7 +434,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
>       drm_kms_helper_poll_disable(drm_dev);
>       vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF);
>
> -     ret = amdgpu_suspend_kms(drm_dev, false, false);
> +     ret = amdgpu_suspend_kms(drm_dev, false, false, false);
>       pci_save_state(pdev);
>       pci_disable_device(pdev);
>       pci_ignore_hotplug(pdev);

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating
       [not found]         ` <BY2PR12MB0614D30441286DA319B5BB5A99EB0-K//h7OWB4q5SmL+xRiD5tgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
@ 2016-08-23  2:42           ` Deucher, Alexander
       [not found]             ` <MWHPR12MB169439C210055B00095BA4EEF7EB0-Gy0DoCVfaSW4WA4dJ5YXGAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Deucher, Alexander @ 2016-08-23  2:42 UTC (permalink / raw)
  To: Qu, Jim, Zhou, David(ChunMing),
	Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

> -----Original Message-----
> From: Qu, Jim
> Sent: Monday, August 22, 2016 10:05 PM
> To: Zhou, David(ChunMing); Alex Deucher; amd-gfx@lists.freedesktop.org
> Cc: Deucher, Alexander
> Subject: 答复: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating
> 
> I have a question:
> 
> if driver reset the asic in freeze(), Does not need to re-init the asic in thaw()?

Yes, it should already be taken care of in thaw.  Thaw calls amdgpu_resume_kms() which calls amdgpu_asic_init() if the card isn’t posted which I think should be the case after a GPU reset.

Alex

> 
> Thanks
> JimQu
> 
> ________________________________________
> 发件人: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 zhoucm1
> <david1.zhou@amd.com>
> 发送时间: 2016年8月23日 9:52:42
> 收件人: Alex Deucher; amd-gfx@lists.freedesktop.org
> 抄送: Deucher, Alexander
> 主题: Re: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating
> 
> This series is Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
> 
> 
> 
> On 2016年08月23日 00:05, Alex Deucher wrote:
> > Some blocks require a reset to properly resume if there
> > is no power down of the asic like during various
> > hibernation steps.
> >
> > Port of:
> > 274ad65c9d02bdcbee9bae045517864c3521d530
> > (drm/radeon: hard reset r600 and newer GPU when hibernating.)
> > from radeon.
> >
> > Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  3 ++-
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +++++++---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 +++---
> >   3 files changed, 12 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > index 6fa8268..d0d0588 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > @@ -2436,7 +2436,8 @@ void amdgpu_driver_postclose_kms(struct
> drm_device *dev,
> >                                struct drm_file *file_priv);
> >   void amdgpu_driver_preclose_kms(struct drm_device *dev,
> >                               struct drm_file *file_priv);
> > -int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool
> fbcon);
> > +int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool
> fbcon,
> > +                    bool freeze);
> >   int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool
> fbcon);
> >   u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned
> int pipe);
> >   int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int
> pipe);
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > index 21f4b74..5747e37 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > @@ -1037,7 +1037,7 @@ static void amdgpu_switcheroo_set_state(struct
> pci_dev *pdev, enum vga_switchero
> >               printk(KERN_INFO "amdgpu: switched off\n");
> >               drm_kms_helper_poll_disable(dev);
> >               dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
> > -             amdgpu_suspend_kms(dev, true, true);
> > +             amdgpu_suspend_kms(dev, true, true, false);
> >               dev->switch_power_state = DRM_SWITCH_POWER_OFF;
> >       }
> >   }
> > @@ -1780,7 +1780,8 @@ void amdgpu_device_fini(struct amdgpu_device
> *adev)
> >    * Returns 0 for success or an error on failure.
> >    * Called at driver suspend.
> >    */
> > -int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool
> fbcon)
> > +int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool
> fbcon,
> > +                    bool freeze)
> >   {
> >       struct amdgpu_device *adev;
> >       struct drm_crtc *crtc;
> > @@ -1844,7 +1845,10 @@ int amdgpu_suspend_kms(struct drm_device
> *dev, bool suspend, bool fbcon)
> >       amdgpu_bo_evict_vram(adev);
> >
> >       pci_save_state(dev->pdev);
> > -     if (suspend) {
> > +     if (freeze) {
> > +             /* reset the asic during freeze */
> > +             r = amdgpu_asic_reset(adev);
> > +     } else if (suspend) {
> >               /* Shut down the device */
> >               pci_disable_device(dev->pdev);
> >               pci_set_power_state(dev->pdev, PCI_D3hot);
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > index 58b1db8..eb4c9b0 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > @@ -395,7 +395,7 @@ static int amdgpu_pmops_suspend(struct device
> *dev)
> >   {
> >       struct pci_dev *pdev = to_pci_dev(dev);
> >       struct drm_device *drm_dev = pci_get_drvdata(pdev);
> > -     return amdgpu_suspend_kms(drm_dev, true, true);
> > +     return amdgpu_suspend_kms(drm_dev, true, true, false);
> >   }
> >
> >   static int amdgpu_pmops_resume(struct device *dev)
> > @@ -409,7 +409,7 @@ static int amdgpu_pmops_freeze(struct device
> *dev)
> >   {
> >       struct pci_dev *pdev = to_pci_dev(dev);
> >       struct drm_device *drm_dev = pci_get_drvdata(pdev);
> > -     return amdgpu_suspend_kms(drm_dev, false, true);
> > +     return amdgpu_suspend_kms(drm_dev, false, true, true);
> >   }
> >
> >   static int amdgpu_pmops_thaw(struct device *dev)
> > @@ -434,7 +434,7 @@ static int amdgpu_pmops_runtime_suspend(struct
> device *dev)
> >       drm_kms_helper_poll_disable(drm_dev);
> >       vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF);
> >
> > -     ret = amdgpu_suspend_kms(drm_dev, false, false);
> > +     ret = amdgpu_suspend_kms(drm_dev, false, false, false);
> >       pci_save_state(pdev);
> >       pci_disable_device(pdev);
> >       pci_ignore_hotplug(pdev);
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* 答复: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating
       [not found]             ` <MWHPR12MB169439C210055B00095BA4EEF7EB0-Gy0DoCVfaSW4WA4dJ5YXGAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
@ 2016-08-23  2:48               ` Qu, Jim
  0 siblings, 0 replies; 11+ messages in thread
From: Qu, Jim @ 2016-08-23  2:48 UTC (permalink / raw)
  To: Deucher, Alexander, Zhou, David(ChunMing),
	Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Oh.yes, I see it!

Reviewed-by: JimQu <Jim.Qu@amd.com>

Thanks
JimQu

________________________________________
发件人: Deucher, Alexander
发送时间: 2016年8月23日 10:42:59
收件人: Qu, Jim; Zhou, David(ChunMing); Alex Deucher; amd-gfx@lists.freedesktop.org
主题: RE: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating

> -----Original Message-----
> From: Qu, Jim
> Sent: Monday, August 22, 2016 10:05 PM
> To: Zhou, David(ChunMing); Alex Deucher; amd-gfx@lists.freedesktop.org
> Cc: Deucher, Alexander
> Subject: 答复: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating
>
> I have a question:
>
> if driver reset the asic in freeze(), Does not need to re-init the asic in thaw()?

Yes, it should already be taken care of in thaw.  Thaw calls amdgpu_resume_kms() which calls amdgpu_asic_init() if the card isn’t posted which I think should be the case after a GPU reset.

Alex

>
> Thanks
> JimQu
>
> ________________________________________
> 发件人: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 zhoucm1
> <david1.zhou@amd.com>
> 发送时间: 2016年8月23日 9:52:42
> 收件人: Alex Deucher; amd-gfx@lists.freedesktop.org
> 抄送: Deucher, Alexander
> 主题: Re: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating
>
> This series is Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
>
>
>
> On 2016年08月23日 00:05, Alex Deucher wrote:
> > Some blocks require a reset to properly resume if there
> > is no power down of the asic like during various
> > hibernation steps.
> >
> > Port of:
> > 274ad65c9d02bdcbee9bae045517864c3521d530
> > (drm/radeon: hard reset r600 and newer GPU when hibernating.)
> > from radeon.
> >
> > Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  3 ++-
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +++++++---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 +++---
> >   3 files changed, 12 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > index 6fa8268..d0d0588 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > @@ -2436,7 +2436,8 @@ void amdgpu_driver_postclose_kms(struct
> drm_device *dev,
> >                                struct drm_file *file_priv);
> >   void amdgpu_driver_preclose_kms(struct drm_device *dev,
> >                               struct drm_file *file_priv);
> > -int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool
> fbcon);
> > +int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool
> fbcon,
> > +                    bool freeze);
> >   int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool
> fbcon);
> >   u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned
> int pipe);
> >   int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int
> pipe);
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > index 21f4b74..5747e37 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > @@ -1037,7 +1037,7 @@ static void amdgpu_switcheroo_set_state(struct
> pci_dev *pdev, enum vga_switchero
> >               printk(KERN_INFO "amdgpu: switched off\n");
> >               drm_kms_helper_poll_disable(dev);
> >               dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
> > -             amdgpu_suspend_kms(dev, true, true);
> > +             amdgpu_suspend_kms(dev, true, true, false);
> >               dev->switch_power_state = DRM_SWITCH_POWER_OFF;
> >       }
> >   }
> > @@ -1780,7 +1780,8 @@ void amdgpu_device_fini(struct amdgpu_device
> *adev)
> >    * Returns 0 for success or an error on failure.
> >    * Called at driver suspend.
> >    */
> > -int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool
> fbcon)
> > +int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool
> fbcon,
> > +                    bool freeze)
> >   {
> >       struct amdgpu_device *adev;
> >       struct drm_crtc *crtc;
> > @@ -1844,7 +1845,10 @@ int amdgpu_suspend_kms(struct drm_device
> *dev, bool suspend, bool fbcon)
> >       amdgpu_bo_evict_vram(adev);
> >
> >       pci_save_state(dev->pdev);
> > -     if (suspend) {
> > +     if (freeze) {
> > +             /* reset the asic during freeze */
> > +             r = amdgpu_asic_reset(adev);
> > +     } else if (suspend) {
> >               /* Shut down the device */
> >               pci_disable_device(dev->pdev);
> >               pci_set_power_state(dev->pdev, PCI_D3hot);
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > index 58b1db8..eb4c9b0 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> > @@ -395,7 +395,7 @@ static int amdgpu_pmops_suspend(struct device
> *dev)
> >   {
> >       struct pci_dev *pdev = to_pci_dev(dev);
> >       struct drm_device *drm_dev = pci_get_drvdata(pdev);
> > -     return amdgpu_suspend_kms(drm_dev, true, true);
> > +     return amdgpu_suspend_kms(drm_dev, true, true, false);
> >   }
> >
> >   static int amdgpu_pmops_resume(struct device *dev)
> > @@ -409,7 +409,7 @@ static int amdgpu_pmops_freeze(struct device
> *dev)
> >   {
> >       struct pci_dev *pdev = to_pci_dev(dev);
> >       struct drm_device *drm_dev = pci_get_drvdata(pdev);
> > -     return amdgpu_suspend_kms(drm_dev, false, true);
> > +     return amdgpu_suspend_kms(drm_dev, false, true, true);
> >   }
> >
> >   static int amdgpu_pmops_thaw(struct device *dev)
> > @@ -434,7 +434,7 @@ static int amdgpu_pmops_runtime_suspend(struct
> device *dev)
> >       drm_kms_helper_poll_disable(drm_dev);
> >       vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF);
> >
> > -     ret = amdgpu_suspend_kms(drm_dev, false, false);
> > +     ret = amdgpu_suspend_kms(drm_dev, false, false, false);
> >       pci_save_state(pdev);
> >       pci_disable_device(pdev);
> >       pci_ignore_hotplug(pdev);
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* 答复: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating
       [not found] ` <1471881925-27757-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
  2016-08-22 16:05   ` [PATCH 2/2] drm/amdgpu: reset the asic on shutdown Alex Deucher
  2016-08-23  1:52   ` [PATCH 1/2] drm/amdgpu: reset the asic when hibernating zhoucm1
@ 2016-08-23  4:18   ` Qu, Jim
       [not found]     ` <BY2PR12MB061454ACDE5467ECE63934A599EB0-K//h7OWB4q5SmL+xRiD5tgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
  2016-08-23  8:05   ` Christian König
  3 siblings, 1 reply; 11+ messages in thread
From: Qu, Jim @ 2016-08-23  4:18 UTC (permalink / raw)
  To: Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Deucher, Alexander

Hi Alex:

Are you working on S4 issue ?

Thanks
JimQu

________________________________________
发件人: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 Alex Deucher <alexdeucher@gmail.com>
发送时间: 2016年8月23日 0:05:24
收件人: amd-gfx@lists.freedesktop.org
抄送: Deucher, Alexander
主题: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating

Some blocks require a reset to properly resume if there
is no power down of the asic like during various
hibernation steps.

Port of:
274ad65c9d02bdcbee9bae045517864c3521d530
(drm/radeon: hard reset r600 and newer GPU when hibernating.)
from radeon.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  3 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +++++++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 +++---
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 6fa8268..d0d0588 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -2436,7 +2436,8 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
                                 struct drm_file *file_priv);
 void amdgpu_driver_preclose_kms(struct drm_device *dev,
                                struct drm_file *file_priv);
-int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon);
+int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon,
+                      bool freeze);
 int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
 u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 21f4b74..5747e37 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1037,7 +1037,7 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero
                printk(KERN_INFO "amdgpu: switched off\n");
                drm_kms_helper_poll_disable(dev);
                dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
-               amdgpu_suspend_kms(dev, true, true);
+               amdgpu_suspend_kms(dev, true, true, false);
                dev->switch_power_state = DRM_SWITCH_POWER_OFF;
        }
 }
@@ -1780,7 +1780,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
  * Returns 0 for success or an error on failure.
  * Called at driver suspend.
  */
-int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
+int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon,
+                      bool freeze)
 {
        struct amdgpu_device *adev;
        struct drm_crtc *crtc;
@@ -1844,7 +1845,10 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
        amdgpu_bo_evict_vram(adev);

        pci_save_state(dev->pdev);
-       if (suspend) {
+       if (freeze) {
+               /* reset the asic during freeze */
+               r = amdgpu_asic_reset(adev);
+       } else if (suspend) {
                /* Shut down the device */
                pci_disable_device(dev->pdev);
                pci_set_power_state(dev->pdev, PCI_D3hot);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 58b1db8..eb4c9b0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -395,7 +395,7 @@ static int amdgpu_pmops_suspend(struct device *dev)
 {
        struct pci_dev *pdev = to_pci_dev(dev);
        struct drm_device *drm_dev = pci_get_drvdata(pdev);
-       return amdgpu_suspend_kms(drm_dev, true, true);
+       return amdgpu_suspend_kms(drm_dev, true, true, false);
 }

 static int amdgpu_pmops_resume(struct device *dev)
@@ -409,7 +409,7 @@ static int amdgpu_pmops_freeze(struct device *dev)
 {
        struct pci_dev *pdev = to_pci_dev(dev);
        struct drm_device *drm_dev = pci_get_drvdata(pdev);
-       return amdgpu_suspend_kms(drm_dev, false, true);
+       return amdgpu_suspend_kms(drm_dev, false, true, true);
 }

 static int amdgpu_pmops_thaw(struct device *dev)
@@ -434,7 +434,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
        drm_kms_helper_poll_disable(drm_dev);
        vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF);

-       ret = amdgpu_suspend_kms(drm_dev, false, false);
+       ret = amdgpu_suspend_kms(drm_dev, false, false, false);
        pci_save_state(pdev);
        pci_disable_device(pdev);
        pci_ignore_hotplug(pdev);
--
2.5.5

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* 答复: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating
       [not found]     ` <BY2PR12MB061454ACDE5467ECE63934A599EB0-K//h7OWB4q5SmL+xRiD5tgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
@ 2016-08-23  4:41       ` Qu, Jim
  2016-08-23  4:46       ` Alex Deucher
  1 sibling, 0 replies; 11+ messages in thread
From: Qu, Jim @ 2016-08-23  4:41 UTC (permalink / raw)
  To: Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Deucher, Alexander

Hi Alex:

I remember that the freeze() is called before hibernation image is made. So is it possible that driver lost some contents when restore hibernation image.

Thanks
JimQu

________________________________________
发件人: Qu, Jim
发送时间: 2016年8月23日 12:18:59
收件人: Alex Deucher; amd-gfx@lists.freedesktop.org
抄送: Deucher, Alexander
主题: 答复: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating

Hi Alex:

Are you working on S4 issue ?

Thanks
JimQu

________________________________________
发件人: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 Alex Deucher <alexdeucher@gmail.com>
发送时间: 2016年8月23日 0:05:24
收件人: amd-gfx@lists.freedesktop.org
抄送: Deucher, Alexander
主题: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating

Some blocks require a reset to properly resume if there
is no power down of the asic like during various
hibernation steps.

Port of:
274ad65c9d02bdcbee9bae045517864c3521d530
(drm/radeon: hard reset r600 and newer GPU when hibernating.)
from radeon.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  3 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +++++++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 +++---
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 6fa8268..d0d0588 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -2436,7 +2436,8 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
                                 struct drm_file *file_priv);
 void amdgpu_driver_preclose_kms(struct drm_device *dev,
                                struct drm_file *file_priv);
-int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon);
+int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon,
+                      bool freeze);
 int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
 u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
 int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 21f4b74..5747e37 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1037,7 +1037,7 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero
                printk(KERN_INFO "amdgpu: switched off\n");
                drm_kms_helper_poll_disable(dev);
                dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
-               amdgpu_suspend_kms(dev, true, true);
+               amdgpu_suspend_kms(dev, true, true, false);
                dev->switch_power_state = DRM_SWITCH_POWER_OFF;
        }
 }
@@ -1780,7 +1780,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
  * Returns 0 for success or an error on failure.
  * Called at driver suspend.
  */
-int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
+int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon,
+                      bool freeze)
 {
        struct amdgpu_device *adev;
        struct drm_crtc *crtc;
@@ -1844,7 +1845,10 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
        amdgpu_bo_evict_vram(adev);

        pci_save_state(dev->pdev);
-       if (suspend) {
+       if (freeze) {
+               /* reset the asic during freeze */
+               r = amdgpu_asic_reset(adev);
+       } else if (suspend) {
                /* Shut down the device */
                pci_disable_device(dev->pdev);
                pci_set_power_state(dev->pdev, PCI_D3hot);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 58b1db8..eb4c9b0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -395,7 +395,7 @@ static int amdgpu_pmops_suspend(struct device *dev)
 {
        struct pci_dev *pdev = to_pci_dev(dev);
        struct drm_device *drm_dev = pci_get_drvdata(pdev);
-       return amdgpu_suspend_kms(drm_dev, true, true);
+       return amdgpu_suspend_kms(drm_dev, true, true, false);
 }

 static int amdgpu_pmops_resume(struct device *dev)
@@ -409,7 +409,7 @@ static int amdgpu_pmops_freeze(struct device *dev)
 {
        struct pci_dev *pdev = to_pci_dev(dev);
        struct drm_device *drm_dev = pci_get_drvdata(pdev);
-       return amdgpu_suspend_kms(drm_dev, false, true);
+       return amdgpu_suspend_kms(drm_dev, false, true, true);
 }

 static int amdgpu_pmops_thaw(struct device *dev)
@@ -434,7 +434,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
        drm_kms_helper_poll_disable(drm_dev);
        vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF);

-       ret = amdgpu_suspend_kms(drm_dev, false, false);
+       ret = amdgpu_suspend_kms(drm_dev, false, false, false);
        pci_save_state(pdev);
        pci_disable_device(pdev);
        pci_ignore_hotplug(pdev);
--
2.5.5

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: 答复: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating
       [not found]     ` <BY2PR12MB061454ACDE5467ECE63934A599EB0-K//h7OWB4q5SmL+xRiD5tgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
  2016-08-23  4:41       ` Qu, Jim
@ 2016-08-23  4:46       ` Alex Deucher
       [not found]         ` <CADnq5_NvxFp3Z+wwPfZV2DzBwafyi8HoOGRPey+XNbuD7CFzdA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 1 reply; 11+ messages in thread
From: Alex Deucher @ 2016-08-23  4:46 UTC (permalink / raw)
  To: Qu, Jim; +Cc: Deucher, Alexander, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Tue, Aug 23, 2016 at 12:18 AM, Qu, Jim <Jim.Qu@amd.com> wrote:
> Hi Alex:
>
> Are you working on S4 issue ?

No, not specifically.  Just seemed like a more reliable way to deal with it.

Alex

>
> Thanks
> JimQu
>
> ________________________________________
> 发件人: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 Alex Deucher <alexdeucher@gmail.com>
> 发送时间: 2016年8月23日 0:05:24
> 收件人: amd-gfx@lists.freedesktop.org
> 抄送: Deucher, Alexander
> 主题: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating
>
> Some blocks require a reset to properly resume if there
> is no power down of the asic like during various
> hibernation steps.
>
> Port of:
> 274ad65c9d02bdcbee9bae045517864c3521d530
> (drm/radeon: hard reset r600 and newer GPU when hibernating.)
> from radeon.
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  3 ++-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +++++++---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 +++---
>  3 files changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 6fa8268..d0d0588 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -2436,7 +2436,8 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
>                                  struct drm_file *file_priv);
>  void amdgpu_driver_preclose_kms(struct drm_device *dev,
>                                 struct drm_file *file_priv);
> -int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon);
> +int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon,
> +                      bool freeze);
>  int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
>  u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
>  int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 21f4b74..5747e37 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -1037,7 +1037,7 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero
>                 printk(KERN_INFO "amdgpu: switched off\n");
>                 drm_kms_helper_poll_disable(dev);
>                 dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
> -               amdgpu_suspend_kms(dev, true, true);
> +               amdgpu_suspend_kms(dev, true, true, false);
>                 dev->switch_power_state = DRM_SWITCH_POWER_OFF;
>         }
>  }
> @@ -1780,7 +1780,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
>   * Returns 0 for success or an error on failure.
>   * Called at driver suspend.
>   */
> -int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
> +int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon,
> +                      bool freeze)
>  {
>         struct amdgpu_device *adev;
>         struct drm_crtc *crtc;
> @@ -1844,7 +1845,10 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
>         amdgpu_bo_evict_vram(adev);
>
>         pci_save_state(dev->pdev);
> -       if (suspend) {
> +       if (freeze) {
> +               /* reset the asic during freeze */
> +               r = amdgpu_asic_reset(adev);
> +       } else if (suspend) {
>                 /* Shut down the device */
>                 pci_disable_device(dev->pdev);
>                 pci_set_power_state(dev->pdev, PCI_D3hot);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 58b1db8..eb4c9b0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -395,7 +395,7 @@ static int amdgpu_pmops_suspend(struct device *dev)
>  {
>         struct pci_dev *pdev = to_pci_dev(dev);
>         struct drm_device *drm_dev = pci_get_drvdata(pdev);
> -       return amdgpu_suspend_kms(drm_dev, true, true);
> +       return amdgpu_suspend_kms(drm_dev, true, true, false);
>  }
>
>  static int amdgpu_pmops_resume(struct device *dev)
> @@ -409,7 +409,7 @@ static int amdgpu_pmops_freeze(struct device *dev)
>  {
>         struct pci_dev *pdev = to_pci_dev(dev);
>         struct drm_device *drm_dev = pci_get_drvdata(pdev);
> -       return amdgpu_suspend_kms(drm_dev, false, true);
> +       return amdgpu_suspend_kms(drm_dev, false, true, true);
>  }
>
>  static int amdgpu_pmops_thaw(struct device *dev)
> @@ -434,7 +434,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
>         drm_kms_helper_poll_disable(drm_dev);
>         vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF);
>
> -       ret = amdgpu_suspend_kms(drm_dev, false, false);
> +       ret = amdgpu_suspend_kms(drm_dev, false, false, false);
>         pci_save_state(pdev);
>         pci_disable_device(pdev);
>         pci_ignore_hotplug(pdev);
> --
> 2.5.5
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* 答复: 答复: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating
       [not found]         ` <CADnq5_NvxFp3Z+wwPfZV2DzBwafyi8HoOGRPey+XNbuD7CFzdA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2016-08-23  5:34           ` Qu, Jim
  0 siblings, 0 replies; 11+ messages in thread
From: Qu, Jim @ 2016-08-23  5:34 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Deucher, Alexander, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

All right, from my previous experience. In thaw() and restore(), there are always ring test fail on GFX, SDMA , sometimes fails on VCE.
I will try your change. Hope it is benefit to the issue.


Thanks
JimQu

________________________________________
发件人: Alex Deucher <alexdeucher@gmail.com>
发送时间: 2016年8月23日 12:46:43
收件人: Qu, Jim
抄送: amd-gfx@lists.freedesktop.org; Deucher, Alexander
主题: Re: 答复: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating

On Tue, Aug 23, 2016 at 12:18 AM, Qu, Jim <Jim.Qu@amd.com> wrote:
> Hi Alex:
>
> Are you working on S4 issue ?

No, not specifically.  Just seemed like a more reliable way to deal with it.

Alex

>
> Thanks
> JimQu
>
> ________________________________________
> 发件人: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> 代表 Alex Deucher <alexdeucher@gmail.com>
> 发送时间: 2016年8月23日 0:05:24
> 收件人: amd-gfx@lists.freedesktop.org
> 抄送: Deucher, Alexander
> 主题: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating
>
> Some blocks require a reset to properly resume if there
> is no power down of the asic like during various
> hibernation steps.
>
> Port of:
> 274ad65c9d02bdcbee9bae045517864c3521d530
> (drm/radeon: hard reset r600 and newer GPU when hibernating.)
> from radeon.
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  3 ++-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +++++++---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 +++---
>  3 files changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 6fa8268..d0d0588 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -2436,7 +2436,8 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
>                                  struct drm_file *file_priv);
>  void amdgpu_driver_preclose_kms(struct drm_device *dev,
>                                 struct drm_file *file_priv);
> -int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon);
> +int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon,
> +                      bool freeze);
>  int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
>  u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
>  int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 21f4b74..5747e37 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -1037,7 +1037,7 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero
>                 printk(KERN_INFO "amdgpu: switched off\n");
>                 drm_kms_helper_poll_disable(dev);
>                 dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
> -               amdgpu_suspend_kms(dev, true, true);
> +               amdgpu_suspend_kms(dev, true, true, false);
>                 dev->switch_power_state = DRM_SWITCH_POWER_OFF;
>         }
>  }
> @@ -1780,7 +1780,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
>   * Returns 0 for success or an error on failure.
>   * Called at driver suspend.
>   */
> -int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
> +int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon,
> +                      bool freeze)
>  {
>         struct amdgpu_device *adev;
>         struct drm_crtc *crtc;
> @@ -1844,7 +1845,10 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
>         amdgpu_bo_evict_vram(adev);
>
>         pci_save_state(dev->pdev);
> -       if (suspend) {
> +       if (freeze) {
> +               /* reset the asic during freeze */
> +               r = amdgpu_asic_reset(adev);
> +       } else if (suspend) {
>                 /* Shut down the device */
>                 pci_disable_device(dev->pdev);
>                 pci_set_power_state(dev->pdev, PCI_D3hot);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 58b1db8..eb4c9b0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -395,7 +395,7 @@ static int amdgpu_pmops_suspend(struct device *dev)
>  {
>         struct pci_dev *pdev = to_pci_dev(dev);
>         struct drm_device *drm_dev = pci_get_drvdata(pdev);
> -       return amdgpu_suspend_kms(drm_dev, true, true);
> +       return amdgpu_suspend_kms(drm_dev, true, true, false);
>  }
>
>  static int amdgpu_pmops_resume(struct device *dev)
> @@ -409,7 +409,7 @@ static int amdgpu_pmops_freeze(struct device *dev)
>  {
>         struct pci_dev *pdev = to_pci_dev(dev);
>         struct drm_device *drm_dev = pci_get_drvdata(pdev);
> -       return amdgpu_suspend_kms(drm_dev, false, true);
> +       return amdgpu_suspend_kms(drm_dev, false, true, true);
>  }
>
>  static int amdgpu_pmops_thaw(struct device *dev)
> @@ -434,7 +434,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
>         drm_kms_helper_poll_disable(drm_dev);
>         vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF);
>
> -       ret = amdgpu_suspend_kms(drm_dev, false, false);
> +       ret = amdgpu_suspend_kms(drm_dev, false, false, false);
>         pci_save_state(pdev);
>         pci_disable_device(pdev);
>         pci_ignore_hotplug(pdev);
> --
> 2.5.5
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating
       [not found] ` <1471881925-27757-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
                     ` (2 preceding siblings ...)
  2016-08-23  4:18   ` Qu, Jim
@ 2016-08-23  8:05   ` Christian König
  3 siblings, 0 replies; 11+ messages in thread
From: Christian König @ 2016-08-23  8:05 UTC (permalink / raw)
  To: Alex Deucher, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Alex Deucher

Am 22.08.2016 um 18:05 schrieb Alex Deucher:
> Some blocks require a reset to properly resume if there
> is no power down of the asic like during various
> hibernation steps.
>
> Port of:
> 274ad65c9d02bdcbee9bae045517864c3521d530
> (drm/radeon: hard reset r600 and newer GPU when hibernating.)
> from radeon.
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

I'm still not convinced that this is sufficient in all cases, but it 
should at least help for the most common once.

Both patches are Reviewed-by: Christian König <christian.koenig@amd.com>.

Regards,
Christian.

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  3 ++-
>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +++++++---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  6 +++---
>   3 files changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 6fa8268..d0d0588 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -2436,7 +2436,8 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
>   				 struct drm_file *file_priv);
>   void amdgpu_driver_preclose_kms(struct drm_device *dev,
>   				struct drm_file *file_priv);
> -int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon);
> +int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon,
> +		       bool freeze);
>   int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
>   u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe);
>   int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int pipe);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 21f4b74..5747e37 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -1037,7 +1037,7 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero
>   		printk(KERN_INFO "amdgpu: switched off\n");
>   		drm_kms_helper_poll_disable(dev);
>   		dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
> -		amdgpu_suspend_kms(dev, true, true);
> +		amdgpu_suspend_kms(dev, true, true, false);
>   		dev->switch_power_state = DRM_SWITCH_POWER_OFF;
>   	}
>   }
> @@ -1780,7 +1780,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
>    * Returns 0 for success or an error on failure.
>    * Called at driver suspend.
>    */
> -int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
> +int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon,
> +		       bool freeze)
>   {
>   	struct amdgpu_device *adev;
>   	struct drm_crtc *crtc;
> @@ -1844,7 +1845,10 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
>   	amdgpu_bo_evict_vram(adev);
>   
>   	pci_save_state(dev->pdev);
> -	if (suspend) {
> +	if (freeze) {
> +		/* reset the asic during freeze */
> +		r = amdgpu_asic_reset(adev);
> +	} else if (suspend) {
>   		/* Shut down the device */
>   		pci_disable_device(dev->pdev);
>   		pci_set_power_state(dev->pdev, PCI_D3hot);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> index 58b1db8..eb4c9b0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
> @@ -395,7 +395,7 @@ static int amdgpu_pmops_suspend(struct device *dev)
>   {
>   	struct pci_dev *pdev = to_pci_dev(dev);
>   	struct drm_device *drm_dev = pci_get_drvdata(pdev);
> -	return amdgpu_suspend_kms(drm_dev, true, true);
> +	return amdgpu_suspend_kms(drm_dev, true, true, false);
>   }
>   
>   static int amdgpu_pmops_resume(struct device *dev)
> @@ -409,7 +409,7 @@ static int amdgpu_pmops_freeze(struct device *dev)
>   {
>   	struct pci_dev *pdev = to_pci_dev(dev);
>   	struct drm_device *drm_dev = pci_get_drvdata(pdev);
> -	return amdgpu_suspend_kms(drm_dev, false, true);
> +	return amdgpu_suspend_kms(drm_dev, false, true, true);
>   }
>   
>   static int amdgpu_pmops_thaw(struct device *dev)
> @@ -434,7 +434,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
>   	drm_kms_helper_poll_disable(drm_dev);
>   	vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF);
>   
> -	ret = amdgpu_suspend_kms(drm_dev, false, false);
> +	ret = amdgpu_suspend_kms(drm_dev, false, false, false);
>   	pci_save_state(pdev);
>   	pci_disable_device(pdev);
>   	pci_ignore_hotplug(pdev);


_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-08-23  8:05 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-22 16:05 [PATCH 1/2] drm/amdgpu: reset the asic when hibernating Alex Deucher
     [not found] ` <1471881925-27757-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org>
2016-08-22 16:05   ` [PATCH 2/2] drm/amdgpu: reset the asic on shutdown Alex Deucher
2016-08-23  1:52   ` [PATCH 1/2] drm/amdgpu: reset the asic when hibernating zhoucm1
     [not found]     ` <57BBAC6A.6010803-5C7GfCeVMHo@public.gmane.org>
2016-08-23  2:04       ` 答复: " Qu, Jim
     [not found]         ` <BY2PR12MB0614D30441286DA319B5BB5A99EB0-K//h7OWB4q5SmL+xRiD5tgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2016-08-23  2:42           ` Deucher, Alexander
     [not found]             ` <MWHPR12MB169439C210055B00095BA4EEF7EB0-Gy0DoCVfaSW4WA4dJ5YXGAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2016-08-23  2:48               ` 答复: " Qu, Jim
2016-08-23  4:18   ` Qu, Jim
     [not found]     ` <BY2PR12MB061454ACDE5467ECE63934A599EB0-K//h7OWB4q5SmL+xRiD5tgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2016-08-23  4:41       ` Qu, Jim
2016-08-23  4:46       ` Alex Deucher
     [not found]         ` <CADnq5_NvxFp3Z+wwPfZV2DzBwafyi8HoOGRPey+XNbuD7CFzdA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-08-23  5:34           ` 答复: " Qu, Jim
2016-08-23  8:05   ` Christian König

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.