Skip to contentSkip to conversation

drm/amdgpu: reset the asic when hibernating

PATCH In review Alex Deucher 5 participants 11 messages Aug 22, 2016 – Aug 23, 2016 6 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -1
index 6fa8268..d0d0588 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -3
index 21f4b74..5747e37 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3 -3
index 58b1db8..eb4c9b0 100644
@@ -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);
Signature · 6 lines
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1471881925-27757-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/2 drm/amdgpu: reset the asic on shutdown

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

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
index 5747e37..9fb9f59 100644
@@ -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;
Signature · 6 lines
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw
In reply to a message not in the archive

This series is Reviewed-by: Chunming Zhou <[email protected]>

Quoted 88 lines · 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.

---
  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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -1
index 6fa8268..d0d0588 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -3
index 21f4b74..5747e37 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -2
index 58b1db8..eb4c9b0 100644
@@ -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)

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_runtime_suspend(struct device *dev) · line 440

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

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 <[email protected]> 代表 zhoucm1 <[email protected]> 发送时间: 2016年8月23日 9:52:42
收件人: Alex Deucher; [email protected]
抄送: Deucher, Alexander
主题: Re: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating

This series is Reviewed-by: Chunming Zhou <[email protected]>

Quoted 88 lines · 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.

---
  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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -1
index 6fa8268..d0d0588 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -3
index 21f4b74..5747e37 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -2
index 58b1db8..eb4c9b0 100644
@@ -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)

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_runtime_suspend(struct device *dev) · line 440

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BY2PR12MB0614D30441286DA319B5BB5A99EB0-K//h7OWB4q5SmL+xRiD5tgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#7 lore raw
Quoted 10 lines

-----Original Message-----
From: Qu, Jim
Sent: Monday, August 22, 2016 10:05 PM
To: Zhou, David(ChunMing); Alex Deucher; [email protected]
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

Quoted 131 lines

Thanks
JimQu

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

This series is Reviewed-by: Chunming Zhou <[email protected]>

Quoted 9 lines · 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.

Review

Quoted 8 lines
---
  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(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu.h

drivers/gpu/drm/amd/amdgpu/amdgpu.h void amdgpu_driver_postclose_kms(struct

Quoted 4 lines

index 6fa8268..d0d0588 100644

drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
@@ -2436,7 +2436,8 @@ void amdgpu_driver_postclose_kms(struct

drm_device *dev,

drivers/gpu/drm/amd/amdgpu/amdgpu.h void amdgpu_driver_postclose_kms(struct drm_device *dev,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -1
                               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);

drivers/gpu/drm/amd/amdgpu/amdgpu.h void amdgpu_driver_postclose_kms(struct · line 2439

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
+int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool

fbcon,

drivers/gpu/drm/amd/amdgpu/amdgpu.h void amdgpu_driver_postclose_kms(struct · line 2441

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
+                    bool freeze);
  int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool

fbcon);

drivers/gpu/drm/amd/amdgpu/amdgpu.h void amdgpu_driver_postclose_kms(struct · line 2442

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
  u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned

int pipe);

drivers/gpu/drm/amd/amdgpu/amdgpu.h void amdgpu_driver_postclose_kms(struct · line 2443

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
  int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int

pipe);

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static void amdgpu_switcheroo_set_state(struct

Quoted 4 lines

index 21f4b74..5747e37 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -1037,7 +1037,7 @@ static void amdgpu_switcheroo_set_state(struct

pci_dev *pdev, enum vga_switchero

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_device_fini(struct amdgpu_device

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
              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)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_device_fini(struct amdgpu_device *adev)

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -1
   * 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)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_device_fini(struct amdgpu_device · line 1783

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool

fbcon,

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_suspend_kms(struct drm_device

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+                    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)

Review

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -1
      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);
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_suspend(struct device

Quoted 4 lines

index 58b1db8..eb4c9b0 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
@@ -395,7 +395,7 @@ static int amdgpu_pmops_suspend(struct device

*dev)

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_freeze(struct device

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
  {
      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)

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_runtime_suspend(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
  {
      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)

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_runtime_suspend(struct device *dev) · line 440

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
      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);
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): MWHPR12MB169439C210055B00095BA4EEF7EB0-Gy0DoCVfaSW4WA4dJ5YXGAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

Reviewed-by JimQu
#9 lore raw

Oh.yes, I see it!

Thanks
JimQu

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

Quoted 10 lines

-----Original Message-----
From: Qu, Jim
Sent: Monday, August 22, 2016 10:05 PM
To: Zhou, David(ChunMing); Alex Deucher; [email protected]
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

Quoted 131 lines

Thanks
JimQu

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

This series is Reviewed-by: Chunming Zhou <[email protected]>

Quoted 9 lines · 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.

Review

Quoted 8 lines
---
  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(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu.h

drivers/gpu/drm/amd/amdgpu/amdgpu.h void amdgpu_driver_postclose_kms(struct

Quoted 4 lines

index 6fa8268..d0d0588 100644

drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
@@ -2436,7 +2436,8 @@ void amdgpu_driver_postclose_kms(struct

drm_device *dev,

drivers/gpu/drm/amd/amdgpu/amdgpu.h void amdgpu_driver_postclose_kms(struct · line 2439

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -1
                               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);

drivers/gpu/drm/amd/amdgpu/amdgpu.h void amdgpu_driver_postclose_kms(struct · line 2439

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
+int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool

fbcon,

drivers/gpu/drm/amd/amdgpu/amdgpu.h void amdgpu_driver_postclose_kms(struct · line 2441

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
+                    bool freeze);
  int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool

fbcon);

drivers/gpu/drm/amd/amdgpu/amdgpu.h void amdgpu_driver_postclose_kms(struct · line 2442

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
  u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned

int pipe);

drivers/gpu/drm/amd/amdgpu/amdgpu.h void amdgpu_driver_postclose_kms(struct · line 2443

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
  int amdgpu_enable_vblank_kms(struct drm_device *dev, unsigned int

pipe);

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static void amdgpu_switcheroo_set_state(struct

Quoted 4 lines

index 21f4b74..5747e37 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -1037,7 +1037,7 @@ static void amdgpu_switcheroo_set_state(struct

pci_dev *pdev, enum vga_switchero

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_device_fini(struct amdgpu_device

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
              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)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_device_fini(struct amdgpu_device · line 1783

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -1
   * 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)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_device_fini(struct amdgpu_device · line 1783

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool

fbcon,

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_suspend_kms(struct drm_device

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+                    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)

Review

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -1
      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);
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_suspend(struct device

Quoted 4 lines

index 58b1db8..eb4c9b0 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
@@ -395,7 +395,7 @@ static int amdgpu_pmops_suspend(struct device

*dev)

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_freeze(struct device

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
  {
      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)

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_runtime_suspend(struct

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
  {
      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)

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_runtime_suspend(struct · line 440

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
      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);
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#10 lore raw
In reply to a message not in the archive

Hi Alex:

Are you working on S4 issue ?

Thanks
JimQu

________________________________________
发件人: amd-gfx <[email protected]> 代表 Alex Deucher <[email protected]> 发送时间: 2016年8月23日 0:05:24
收件人: [email protected]
抄送: 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.

---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -1
index 6fa8268..d0d0588 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -3
index 21f4b74..5747e37 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3 -3
index 58b1db8..eb4c9b0 100644
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BY2PR12MB061454ACDE5467ECE63934A599EB0-K//h7OWB4q5SmL+xRiD5tgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#12 lore raw

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; [email protected]
抄送: Deucher, Alexander
主题: 答复: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating

Hi Alex:

Are you working on S4 issue ?

Thanks
JimQu

________________________________________
发件人: amd-gfx <[email protected]> 代表 Alex Deucher <[email protected]> 发送时间: 2016年8月23日 0:05:24
收件人: [email protected]
抄送: 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.

---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -1
index 6fa8268..d0d0588 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -3
index 21f4b74..5747e37 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3 -3
index 58b1db8..eb4c9b0 100644
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#13 lore raw
In reply to a message not in the archive
Quoted 3 lines · Jim

Hi Alex:

Are you working on S4 issue ?

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

Alex

Quoted 110 lines

Thanks
JimQu

________________________________________
发件人: amd-gfx <[email protected]> 代表 Alex Deucher <[email protected]> 发送时间: 2016年8月23日 0:05:24
收件人: [email protected]
抄送: 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.

---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -1
index 6fa8268..d0d0588 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -3
index 21f4b74..5747e37 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3 -4
index 58b1db8..eb4c9b0 100644
@@ -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

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CADnq5_NvxFp3Z+wwPfZV2DzBwafyi8HoOGRPey+XNbuD7CFzdA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#15 lore raw

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 <[email protected]>
发送时间: 2016年8月23日 12:46:43
收件人: Qu, Jim
抄送: [email protected]; Deucher, Alexander 主题: Re: 答复: [PATCH 1/2] drm/amdgpu: reset the asic when hibernating

Quoted 3 lines · Jim

Hi Alex:

Are you working on S4 issue ?

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

Alex

Quoted 110 lines

Thanks
JimQu

________________________________________
发件人: amd-gfx <[email protected]> 代表 Alex Deucher <[email protected]> 发送时间: 2016年8月23日 0:05:24
收件人: [email protected]
抄送: 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.

---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -1
index 6fa8268..d0d0588 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -3
index 21f4b74..5747e37 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3 -4
index 58b1db8..eb4c9b0 100644
@@ -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

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#16 lore raw
In reply to a message not in the archive

Am 22.08.2016 um 18:05 schrieb Alex Deucher:

Quoted 10 lines

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.

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 <[email protected]>.

Regards,
Christian.

Quoted 78 lines
---
  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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -1
index 6fa8268..d0d0588 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -3
index 21f4b74..5747e37 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -2
index 58b1db8..eb4c9b0 100644
@@ -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)

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c static int amdgpu_pmops_runtime_suspend(struct device *dev) · line 440

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx