[PATCH 7/7] drm/atomic: Reduce setplane locking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>

Currently setplane grabs all modeset locks, which seems a bit
excessive. Let's reduce that to just the locks we really need
on atomic drivers. For non-atomic drivers let's stick to the
current scheme for now.

Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
---
 drivers/gpu/drm/drm_plane.c | 56 +++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index ef0cc33b43ce..e40d8a93294b 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -680,10 +680,14 @@ static int __setplane_internal(struct drm_plane *plane,
 			       uint32_t src_w, uint32_t src_h,
 			       struct drm_modeset_acquire_ctx *ctx)
 {
-	int ret = 0;
+	int ret;
 
 	WARN_ON(drm_drv_uses_atomic_modeset(plane->dev));
 
+	ret = drm_modeset_lock_all_ctx(plane->dev, ctx);
+	if (ret)
+		return ret;
+
 	/* No fb means shut it down */
 	if (!fb) {
 		plane->old_fb = plane->fb;
@@ -767,32 +771,24 @@ static int setplane_internal(struct drm_plane *plane,
 			     uint32_t crtc_w, uint32_t crtc_h,
 			     /* src_{x,y,w,h} values are 16.16 fixed point */
 			     uint32_t src_x, uint32_t src_y,
-			     uint32_t src_w, uint32_t src_h)
+			     uint32_t src_w, uint32_t src_h,
+			     struct drm_modeset_acquire_ctx *ctx)
 {
-	struct drm_modeset_acquire_ctx ctx;
-	int ret;
-
-	DRM_MODESET_LOCK_ALL_BEGIN(plane->dev, ctx,
-				   DRM_MODESET_ACQUIRE_INTERRUPTIBLE, ret);
-
 	if (drm_drv_uses_atomic_modeset(plane->dev))
-		ret = __setplane_atomic(plane, crtc, fb,
-					crtc_x, crtc_y, crtc_w, crtc_h,
-					src_x, src_y, src_w, src_h, &ctx);
+		return __setplane_atomic(plane, crtc, fb,
+					 crtc_x, crtc_y, crtc_w, crtc_h,
+					 src_x, src_y, src_w, src_h, ctx);
 	else
-		ret = __setplane_internal(plane, crtc, fb,
-					  crtc_x, crtc_y, crtc_w, crtc_h,
-					  src_x, src_y, src_w, src_h, &ctx);
-
-	DRM_MODESET_LOCK_ALL_END(ctx, ret);
-
-	return ret;
+		return __setplane_internal(plane, crtc, fb,
+					   crtc_x, crtc_y, crtc_w, crtc_h,
+					   src_x, src_y, src_w, src_h, ctx);
 }
 
 int drm_mode_setplane(struct drm_device *dev, void *data,
 		      struct drm_file *file_priv)
 {
 	struct drm_mode_set_plane *plane_req = data;
+	struct drm_modeset_acquire_ctx ctx;
 	struct drm_plane *plane;
 	struct drm_crtc *crtc = NULL;
 	struct drm_framebuffer *fb = NULL;
@@ -829,11 +825,22 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
 		}
 	}
 
+	drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
+
+retry:
 	ret = setplane_internal(plane, crtc, fb,
 				plane_req->crtc_x, plane_req->crtc_y,
 				plane_req->crtc_w, plane_req->crtc_h,
 				plane_req->src_x, plane_req->src_y,
-				plane_req->src_w, plane_req->src_h);
+				plane_req->src_w, plane_req->src_h, &ctx);
+	if (ret == -EDEADLK) {
+		ret = drm_modeset_backoff(&ctx);
+		if (!ret)
+			goto retry;
+	}
+
+	drm_modeset_drop_locks(&ctx);
+	drm_modeset_acquire_fini(&ctx);
 
 	if (fb)
 		drm_framebuffer_put(fb);
@@ -907,14 +914,9 @@ static int drm_mode_cursor_universal(struct drm_crtc *crtc,
 		src_h = fb->height << 16;
 	}
 
-	if (drm_drv_uses_atomic_modeset(dev))
-		ret = __setplane_atomic(plane, crtc, fb,
-					crtc_x, crtc_y, crtc_w, crtc_h,
-					0, 0, src_w, src_h, ctx);
-	else
-		ret = __setplane_internal(plane, crtc, fb,
-					  crtc_x, crtc_y, crtc_w, crtc_h,
-					  0, 0, src_w, src_h, ctx);
+	ret = setplane_internal(plane, crtc, fb,
+				crtc_x, crtc_y, crtc_w, crtc_h,
+				0, 0, src_w, src_h, ctx);
 
 	if (fb)
 		drm_framebuffer_put(fb);
-- 
2.23.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux