[PATCH] amdgpu: Replace drm_modeset_(un)lock_all()

Joseph Schulte joeschulte.js at gmail.com
Tue Jan 12 18:35:26 UTC 2021


This patch repaces drm_modeset_lock_all() and drm_modeset_unlock_all
with DRM_MODESET_LOCK_ALL_BEGIN() and DRM_MODESET_LOCK_ALL_END()
respectivley according to Documentation/gpu/todo.rst.

r is used for the ret value in DRM_MODESET_LOCK_ALL_BEGIN since r is set
before any branches.

Signed-off-by: Joseph Schulte <joeschulte.js at gmail.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index b69c34074d8d..2e92d020e8c1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -32,6 +32,8 @@
 #include <linux/slab.h>
 
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_modeset_lock.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/amdgpu_drm.h>
 #include <linux/vgaarb.h>
@@ -3662,6 +3664,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
 	struct drm_crtc *crtc;
 	struct drm_connector *connector;
 	struct drm_connector_list_iter iter;
+	struct drm_modeset_acquire_ctx ctx;
 	int r;
 
 	adev = drm_to_adev(dev);
@@ -3679,13 +3682,13 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
 
 	if (!amdgpu_device_has_dc_support(adev)) {
 		/* turn off display hw */
-		drm_modeset_lock_all(dev);
+		DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, r);
 		drm_connector_list_iter_begin(dev, &iter);
 		drm_for_each_connector_iter(connector, &iter)
 			drm_helper_connector_dpms(connector,
 						  DRM_MODE_DPMS_OFF);
 		drm_connector_list_iter_end(&iter);
-		drm_modeset_unlock_all(dev);
+		DRM_MODESET_LOCK_ALL_END(dev, ctx, r);
 			/* unpin the front buffers and cursors */
 		list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
 			struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
@@ -3754,6 +3757,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
 {
 	struct drm_connector *connector;
 	struct drm_connector_list_iter iter;
+	struct drm_modeset_acquire_ctx ctx;
 	struct amdgpu_device *adev = drm_to_adev(dev);
 	struct drm_crtc *crtc;
 	int r = 0;
@@ -3818,7 +3822,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
 			drm_helper_resume_force_mode(dev);
 
 			/* turn on display hw */
-			drm_modeset_lock_all(dev);
+			DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, 0, r);
 
 			drm_connector_list_iter_begin(dev, &iter);
 			drm_for_each_connector_iter(connector, &iter)
@@ -3826,7 +3830,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool fbcon)
 							  DRM_MODE_DPMS_ON);
 			drm_connector_list_iter_end(&iter);
 
-			drm_modeset_unlock_all(dev);
+			DRM_MODESET_LOCK_ALL_END(dev, ctx, r);
 		}
 		amdgpu_fbdev_set_suspend(adev, 0);
 	}
-- 
2.30.0



More information about the amd-gfx mailing list