[PATCH] drm/amd/amdgpu: add atomit helper function into suspend/resume functions

Jim Qu Jim.Qu at amd.com
Wed Mar 1 03:24:55 UTC 2017


Change-Id: I3baae1419cb33a25e4fd84039bb382a347e3a12c
Signed-off-by: Jim Qu <Jim.Qu at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 ++++++++++++++++--------------
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 8a5f8cb..cf75f6b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1500,10 +1500,10 @@ struct amdgpu_device {
 	/* link all gtt */
 	spinlock_t			gtt_list_lock;
 	struct list_head                gtt_list;
-
 	/* record hw reset is performed */
 	bool has_hw_reset;
 
+	struct drm_atomic_state *atomic_state;
 };
 
 static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index c0679d3..62083a3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2059,7 +2059,20 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
 
 	drm_kms_helper_poll_disable(dev);
 
-	if (!amdgpu_device_has_dc_support(adev)) {
+	if (fbcon) {
+		console_lock();
+		amdgpu_fbdev_set_suspend(adev, 1);
+		console_unlock();
+	}
+
+	if (amdgpu_device_has_dc_support(adev)) {
+		adev->atomic_state = drm_atomic_helper_suspend(adev->ddev);
+		if (IS_ERR(adev->atomic_state)) {
+			amdgpu_fbdev_set_suspend(adev, 0);
+			drm_kms_helper_poll_enable(adev->ddev);
+			return PTR_ERR(adev->atomic_state);
+		}
+	} else {
 		/* turn off display hw */
 		drm_modeset_lock_all(dev);
 		list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
@@ -2121,11 +2134,6 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon)
 			DRM_ERROR("amdgpu asic reset failed\n");
 	}
 
-	if (fbcon) {
-		console_lock();
-		amdgpu_fbdev_set_suspend(adev, 1);
-		console_unlock();
-	}
 	return 0;
 }
 
@@ -2209,7 +2217,10 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
 
 	/* blat the mode back in */
 	if (fbcon) {
-		if (!amdgpu_device_has_dc_support(adev)) {
+		if (amdgpu_device_has_dc_support(adev)) {
+			drm_atomic_helper_resume(adev->ddev, adev->atomic_state);
+			amdgpu_dm_display_resume(adev);
+		} else {
 			/* pre DCE11 */
 			drm_helper_resume_force_mode(dev);
 
@@ -2219,14 +2230,6 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon)
 				drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON);
 			}
 			drm_modeset_unlock_all(dev);
-		} else {
-			/*
-			 * There is no equivalent atomic helper to turn on
-			 * display, so we defined our own function for this,
-			 * once suspend resume is supported by the atomic
-			 * framework this will be reworked
-			 */
-			amdgpu_dm_display_resume(adev);
 		}
 	}
 
-- 
1.9.1



More information about the amd-gfx mailing list