Skip to contentSkip to conversation

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

PATCH In review Jim Qu 2 participants 3 messages Mar 1, 2017 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Jim Qu

author
#0 lore raw

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

Change-Id I3baae1419cb33a25e4fd84039bb382a347e3a12c
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 ++++++++++++++++--------------
 2 files changed, 19 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
index 8a5f8cb..cf75f6b 100644
@@ -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)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +18 -15
index c0679d3..62083a3 100644
@@ -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);
 		}
 	}
 
Signature · 6 lines
1.9.1

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

Typo in the subject: "atomit"

drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1504

Quoted 12 lines · Jim Qu
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -1
index 8a5f8cb..cf75f6b 100644
@@ -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;

Don't remove the empty line.

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
 static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -1
index c0679d3..62083a3 100644
@@ -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)) {

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) · line 2071

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

I think this needs to be

			if (fbcon) {
				console_lock();
				amdgpu_fbdev_set_suspend(adev, 0);
				console_unlock();
			}

Maybe refactor this sequence into a helper function in a preparatory patch.

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon) · line 2222

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

These also need to be called in the non-fbcon case, don't they?

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
author
#4 lore raw
In reply to a message not in the archive

Thanks to Michel. I have sent new patches, please help review.

Thanks
JimQu

________________________________________
发件人: Michel Dänzer <[email protected]>
发送时间: 2017年3月1日 14:27
收件人: Qu, Jim
抄送: [email protected]
主题: Re: [PATCH] drm/amd/amdgpu: add atomit helper function into suspend/resume functions

Typo in the subject: "atomit"

drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1504

Quoted 12 lines · Jim Qu
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -1
index 8a5f8cb..cf75f6b 100644
@@ -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;

Don't remove the empty line.

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
 static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -1
index c0679d3..62083a3 100644
@@ -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)) {

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) · line 2071

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

I think this needs to be

                        if (fbcon) {
                                console_lock();
                                amdgpu_fbdev_set_suspend(adev, 0);
                                console_unlock();
                        }

Maybe refactor this sequence into a helper function in a preparatory patch.

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon) · line 2222

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

These also need to be called in the non-fbcon case, don't they?

--
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