Skip to contentSkip to conversation

drm/amd/amdgpu/amdgpu_drv.c: Replace drm_modeset_lock_all with drm_modeset_lock

PATCH Superseded Fabio M. De Francesco 3 participants 4 messages Apr 22, 2021 – Apr 26, 2021

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/amdgpu/amdgpu_drv.c: Replace drm_modeset_lock_all with drm_modeset_lock

drm_modeset_lock_all() is not needed here, so it is replaced with drm_modeset_lock(). The crtc list around which we are looping never changes, therefore the only lock we need is to protect access to crtc->state.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -5
index 671ec1002230..bce8f6793d8e 100644
@@ -1439,17 +1439,16 @@ static int amdgpu_pmops_runtime_idle(struct device *dev)
 	if (amdgpu_device_has_dc_support(adev)) {
 		struct drm_crtc *crtc;
 
-		drm_modeset_lock_all(drm_dev);
-
 		drm_for_each_crtc(crtc, drm_dev) {
+			drm_modeset_lock(&crtc->mutex, NULL);
 			if (crtc->state->active) {
 				ret = -EBUSY;
-				break;
 			}
+			drm_modeset_unlock(&crtc->mutex);
+			if (ret < 0)
+				break;
 		}
 
-		drm_modeset_unlock_all(drm_dev);
-
 	} else {
 		struct drm_connector *list_connector;
 		struct drm_connector_list_iter iter;
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Fabio M. De Francesco
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -2
-		drm_modeset_lock_all(drm_dev);
-
 		drm_for_each_crtc(crtc, drm_dev) {
+			drm_modeset_lock(&crtc->mutex, NULL);
 			if (crtc->state->active) {

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +3 -3
 				ret = -EBUSY;
-				break;
 			}
+			drm_modeset_unlock(&crtc->mutex);
+			if (ret < 0)
+				break;
 		}
 
-		drm_modeset_unlock_all(drm_dev);
-

I might remove the {} around ret = -EBUSY, but this is good.

#2 lore raw
Quoted 14 lines · Matthew Wilcox
Quoted 13 lines · Fabio M. De Francesco
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -3
-		drm_modeset_lock_all(drm_dev);
-
 		drm_for_each_crtc(crtc, drm_dev) {
+			drm_modeset_lock(&crtc->mutex, NULL);
 			if (crtc->state->active) {
 				ret = -EBUSY;
-				break;
 			}
+			drm_modeset_unlock(&crtc->mutex);
+			if (ret < 0)
+				break;
 		}
Quoted 6 lines

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

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -2
-		drm_modeset_unlock_all(drm_dev);
-

I might remove the {} around ret = -EBUSY, but this is good.

Yup patch looks good, but it's not cc'ed to drm/amdgpu maintainers/m-l, so likely won't get picked up. Can you pls check scripts/get_maintainers for anything you've missed, add those and resend with Willy's r-b tag included?

Then Alex can pick it up for merging.

Thanks, Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#3 lore raw
Quoted 30 lines · CEST Daniel Vetter
Quoted 20 lines · Matthew Wilcox
Quoted 19 lines · Fabio M. De Francesco
(quoted diff) +4 -3
-		drm_modeset_lock_all(drm_dev);
-
 
 		drm_for_each_crtc(crtc, drm_dev) {
 
+			drm_modeset_lock(&crtc->mutex, NULL);
 
 			if (crtc->state->active) {
 
 				ret = -EBUSY;
 
-				break;
 
 			}
 
+			drm_modeset_unlock(&crtc->mutex);
+			if (ret < 0)
+				break;
Quoted 8 lines

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

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -2
 		}
 
-		drm_modeset_unlock_all(drm_dev);
-

I might remove the {} around ret = -EBUSY, but this is good.

Quoted 9 lines

Yup patch looks good, but it's not cc'ed to drm/amdgpu maintainers/m-l, so likely won't get picked up. Can you pls check scripts/get_maintainers for anything you've missed, add those and resend with Willy's r-b tag included?

Then Alex can pick it up for merging.

Thanks, Daniel

I had already submitted a v2 of this patch with an added 'Review-by' Matthew Wilcox under my name. It removed the unnecessary braces that willy pointed out. However I see that not all maintainers had been cc'ed, so I'm going to resend it as v3.

Thanks,

Fabio