Skip to contentSkip to conversation

drm/amdgpu: rename suspend_kms and resume_kms

PATCH In review Alex Deucher 3 participants 5 messages Aug 23, 2016 – Aug 24, 2016 3 messages not in the archive

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

PATCH 1/3 drm/amdgpu: rename suspend_kms and resume_kms

The old names were dragged over from radeon. The new ones better match the naming conventions used in the driver.

No functional change.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 ++++++------
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 12 ++++++------
 3 files changed, 14 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -2
index 3cc2629..8494514 100644
@@ -2434,8 +2434,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_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
+int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon);
+int amdgpu_device_resume(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);
 void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -6
index 6459d5c..3b5f893 100644
@@ -1027,7 +1027,7 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero
 		/* don't suspend or resume card normally */
 		dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
 
-		amdgpu_resume_kms(dev, true, true);
+		amdgpu_device_resume(dev, true, true);
 
 		dev->pdev->d3_delay = d3_delay;
 
@@ -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_device_suspend(dev, true, true);
 		dev->switch_power_state = DRM_SWITCH_POWER_OFF;
 	}
 }
@@ -1776,7 +1776,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
  * Suspend & resume.
  */
 /**
- * amdgpu_suspend_kms - initiate device suspend
+ * amdgpu_device_suspend - initiate device suspend
  *
  * @pdev: drm dev pointer
  * @state: suspend state
@@ -1785,7 +1785,7 @@ 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_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
 {
 	struct amdgpu_device *adev;
 	struct drm_crtc *crtc;
@@ -1864,7 +1864,7 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
 }
 
 /**
- * amdgpu_resume_kms - initiate device resume
+ * amdgpu_device_resume - initiate device resume
  *
  * @pdev: drm dev pointer
  *
@@ -1872,7 +1872,7 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
  * Returns 0 for success or an error on failure.
  * Called at driver resume.
  */
-int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon)
+int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
 {
 	struct drm_connector *connector;
 	struct amdgpu_device *adev = dev->dev_private;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +6 -6
index 7556879..81466ec 100644
@@ -409,28 +409,28 @@ 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_device_suspend(drm_dev, true, true);
 }
 
 static int amdgpu_pmops_resume(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
-	return amdgpu_resume_kms(drm_dev, true, true);
+	return amdgpu_device_resume(drm_dev, true, true);
 }
 
 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_device_suspend(drm_dev, false, true);
 }
 
 static int amdgpu_pmops_thaw(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
-	return amdgpu_resume_kms(drm_dev, false, true);
+	return amdgpu_device_resume(drm_dev, false, true);
 }
 
 static int amdgpu_pmops_runtime_suspend(struct device *dev)
@@ -448,7 +448,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_device_suspend(drm_dev, false, false);
 	pci_save_state(pdev);
 	pci_disable_device(pdev);
 	pci_ignore_hotplug(pdev);
@@ -481,7 +481,7 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)
 		return ret;
 	pci_set_master(pdev);
 
-	ret = amdgpu_resume_kms(drm_dev, false, false);
+	ret = amdgpu_device_resume(drm_dev, false, false);
 	drm_kms_helper_poll_enable(drm_dev);
 	vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON);
 	drm_dev->switch_power_state = DRM_SWITCH_POWER_ON;
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): 1471974331-9280-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/3 drm/amdgpu: add new device suspend and resume parameters

Add support for asic_reset and asic_init to the device suspend and resume functions.

No change in functionality.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  6 ++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 +++++++++-----
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 12 ++++++------
 3 files changed, 19 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -2
index 8494514..6f94754 100644
@@ -2434,8 +2434,10 @@ 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_device_suspend(struct drm_device *dev, bool suspend, bool fbcon);
-int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon);
+int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon,
+			  bool asic_reset);
+int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon,
+			 bool asic_init);
 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);
 void amdgpu_disable_vblank_kms(struct drm_device *dev, unsigned int pipe);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +9 -5
index 3b5f893..797337c 100644
@@ -1027,7 +1027,7 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero
 		/* don't suspend or resume card normally */
 		dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
 
-		amdgpu_device_resume(dev, true, true);
+		amdgpu_device_resume(dev, true, true, false);
 
 		dev->pdev->d3_delay = d3_delay;
 
@@ -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_device_suspend(dev, true, true);
+		amdgpu_device_suspend(dev, true, true, false);
 		dev->switch_power_state = DRM_SWITCH_POWER_OFF;
 	}
 }
@@ -1785,7 +1785,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
  * Returns 0 for success or an error on failure.
  * Called at driver suspend.
  */
-int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
+int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon,
+			  bool asic_reset)
 {
 	struct amdgpu_device *adev;
 	struct drm_crtc *crtc;
@@ -1849,6 +1850,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
 	amdgpu_bo_evict_vram(adev);
 
 	pci_save_state(dev->pdev);
+	if (asic_reset)
+		r = amdgpu_asic_reset(adev);
 	if (suspend) {
 		/* Shut down the device */
 		pci_disable_device(dev->pdev);
@@ -1872,7 +1875,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
  * Returns 0 for success or an error on failure.
  * Called at driver resume.
  */
-int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
+int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon,
+			 bool asic_init)
 {
 	struct drm_connector *connector;
 	struct amdgpu_device *adev = dev->dev_private;
@@ -1896,7 +1900,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
 	}
 
 	/* post card */
-	if (!amdgpu_card_posted(adev))
+	if (!amdgpu_card_posted(adev) || asic_init)
 		amdgpu_atom_asic_init(adev->mode_info.atom_context);
 
 	r = amdgpu_resume(adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +6 -6
index 81466ec..d0f65d4 100644
@@ -409,28 +409,28 @@ 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_device_suspend(drm_dev, true, true);
+	return amdgpu_device_suspend(drm_dev, true, true, false);
 }
 
 static int amdgpu_pmops_resume(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
-	return amdgpu_device_resume(drm_dev, true, true);
+	return amdgpu_device_resume(drm_dev, true, true, false);
 }
 
 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_device_suspend(drm_dev, false, true);
+	return amdgpu_device_suspend(drm_dev, false, true, false);
 }
 
 static int amdgpu_pmops_thaw(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
-	return amdgpu_device_resume(drm_dev, false, true);
+	return amdgpu_device_resume(drm_dev, false, true, false);
 }
 
 static int amdgpu_pmops_runtime_suspend(struct device *dev)
@@ -448,7 +448,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_device_suspend(drm_dev, false, false);
+	ret = amdgpu_device_suspend(drm_dev, false, false, false);
 	pci_save_state(pdev);
 	pci_disable_device(pdev);
 	pci_ignore_hotplug(pdev);
@@ -481,7 +481,7 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)
 		return ret;
 	pci_set_master(pdev);
 
-	ret = amdgpu_device_resume(drm_dev, false, false);
+	ret = amdgpu_device_resume(drm_dev, false, false, false);
 	drm_kms_helper_poll_enable(drm_dev);
 	vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON);
 	drm_dev->switch_power_state = DRM_SWITCH_POWER_ON;
Signature · 6 lines
2.5.5

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

PATCH 3/3 drm/amdgpu: reset the asic when hibernating v2

In reply to a message not in the archive

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

Reset the asic on freeze and force asic_init on thaw.

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

v2: split out just the freeze change and force init on thaw

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -2
index d0f65d4..2b57d68 100644
@@ -423,14 +423,14 @@ 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_device_suspend(drm_dev, false, true, false);
+	return amdgpu_device_suspend(drm_dev, false, true, true);
 }
 
 static int amdgpu_pmops_thaw(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
-	return amdgpu_device_resume(drm_dev, false, true, false);
+	return amdgpu_device_resume(drm_dev, false, true, true);
 }
 
 static int amdgpu_pmops_runtime_suspend(struct device *dev)
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): 1471974331-9280-3-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#5 lore raw

Re: [PATCH 3/3] drm/amdgpu: reset the asic when hibernating v2

Quoted 22 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.

Reset the asic on freeze and force asic_init on thaw.

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

v2: split out just the freeze change and force init on thaw

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
index d0f65d4..2b57d68 100644

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

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
@@ -423,14 +423,14 @@ 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_device_suspend(drm_dev, false, true, false);
+	return amdgpu_device_suspend(drm_dev, false, true, true);
 }

FWIW, using a single flags parameter tends to be more readable than multiple boolean parameters. Just a suggestion for possible further improvement, not a blocker for this patch.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
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): c73ef6d9-f852-afb4-122e-16ec11980392-otUistvHUpPR7s880joybQ@public.gmane.org

#7 lore raw

答复: [PATCH 3/3] drm/amdgpu: reset the asic when hibernating v2

Or, we also can use PM_EVENT_ messages to separate freeze, thaw, suspend, resume, poweroff and restore.

Thanks
JimQu

________________________________________
发件人: amd-gfx <[email protected]> 代表 Michel Dänzer <[email protected]> 发送时间: 2016年8月24日 9:03:20
收件人: Alex Deucher
抄送: [email protected]
主题: Re: [PATCH 3/3] drm/amdgpu: reset the asic when hibernating v2

Quoted 22 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.

Reset the asic on freeze and force asic_init on thaw.

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

v2: split out just the freeze change and force init on thaw

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
index d0f65d4..2b57d68 100644

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

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
@@ -423,14 +423,14 @@ 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_device_suspend(drm_dev, false, true, false);
+     return amdgpu_device_suspend(drm_dev, false, true, true);
 }

FWIW, using a single flags parameter tends to be more readable than multiple boolean parameters. Just a suggestion for possible further improvement, not a blocker for this patch.

--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
_______________________________________________
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