From: Ville Syrjala <ville.syrjala@linux.intel.com> To: dri-devel@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org Subject: [PATCH 7/7] drm/atomic: Reduce setplane locking Date: Fri, 15 Nov 2019 21:42:04 +0200 [thread overview] Message-ID: <20191115194204.22244-8-ville.syrjala@linux.intel.com> (raw) In-Reply-To: <20191115194204.22244-1-ville.syrjala@linux.intel.com> From: Ville Syrjälä <ville.syrjala@linux.intel.com> 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@linux.intel.com> --- 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 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: Ville Syrjala <ville.syrjala@linux.intel.com> To: dri-devel@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org Subject: [Intel-gfx] [PATCH 7/7] drm/atomic: Reduce setplane locking Date: Fri, 15 Nov 2019 21:42:04 +0200 [thread overview] Message-ID: <20191115194204.22244-8-ville.syrjala@linux.intel.com> (raw) Message-ID: <20191115194204.LrOV1tl8DBsVvCVxa_Ut1LD888kjPk3qLbnNW0x8yG0@z> (raw) In-Reply-To: <20191115194204.22244-1-ville.syrjala@linux.intel.com> From: Ville Syrjälä <ville.syrjala@linux.intel.com> 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@linux.intel.com> --- 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@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-11-15 19:42 UTC|newest] Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-11-15 19:41 [PATCH 0/7] drm: Random pile of core stuff Ville Syrjala 2019-11-15 19:41 ` [Intel-gfx] " Ville Syrjala 2019-11-15 19:41 ` Ville Syrjala 2019-11-15 19:41 ` [PATCH 1/7] drm: Move page_flip fb lookup earlier Ville Syrjala 2019-11-15 19:41 ` [Intel-gfx] " Ville Syrjala 2019-11-15 19:41 ` Ville Syrjala 2019-11-15 19:41 ` [PATCH 2/7] drm: Allocate the page flip event earlier Ville Syrjala 2019-11-15 19:41 ` [Intel-gfx] " Ville Syrjala 2019-11-15 19:41 ` Ville Syrjala 2019-11-15 19:42 ` [PATCH 3/7] drm: Extract page_flip_{internal, atomic}() Ville Syrjala 2019-11-15 19:42 ` [Intel-gfx] " Ville Syrjala 2019-11-15 19:42 ` [PATCH 3/7] drm: Extract page_flip_{internal,atomic}() Ville Syrjala 2019-11-19 10:14 ` [PATCH 3/7] drm: Extract page_flip_{internal, atomic}() Daniel Vetter 2019-11-19 10:14 ` [Intel-gfx] " Daniel Vetter 2019-11-19 10:14 ` Daniel Vetter 2019-11-22 18:35 ` Ville Syrjälä 2019-11-22 18:35 ` [Intel-gfx] " Ville Syrjälä 2019-11-22 18:35 ` Ville Syrjälä 2019-11-25 9:02 ` Daniel Vetter 2019-11-25 9:02 ` [Intel-gfx] " Daniel Vetter 2019-11-25 9:02 ` Daniel Vetter 2019-11-25 15:05 ` Ville Syrjälä 2019-11-25 15:05 ` [Intel-gfx] " Ville Syrjälä 2019-11-25 15:05 ` Ville Syrjälä 2019-11-25 17:24 ` Daniel Vetter 2019-11-25 17:24 ` [Intel-gfx] " Daniel Vetter 2019-11-25 17:24 ` Daniel Vetter 2019-11-15 19:42 ` [PATCH 4/7] drm: Simplify the setplane old_fb handling further Ville Syrjala 2019-11-15 19:42 ` [Intel-gfx] " Ville Syrjala 2019-11-15 19:42 ` Ville Syrjala 2019-11-15 19:42 ` [PATCH 5/7] drm/selftests: Add some selftests for drm_atomic_set_mode_for_crtc() Ville Syrjala 2019-11-15 19:42 ` [Intel-gfx] " Ville Syrjala 2019-11-15 19:42 ` Ville Syrjala 2019-11-19 10:39 ` Daniel Vetter 2019-11-19 10:39 ` [Intel-gfx] " Daniel Vetter 2019-11-15 19:42 ` [PATCH 6/7] drm/atomic: Fix the early return in drm_atomic_set_mode_for_crtc() Ville Syrjala 2019-11-15 19:42 ` [Intel-gfx] " Ville Syrjala 2019-11-19 10:20 ` Daniel Vetter 2019-11-19 10:20 ` [Intel-gfx] " Daniel Vetter 2019-11-19 10:20 ` Daniel Vetter 2019-11-15 19:42 ` Ville Syrjala [this message] 2019-11-15 19:42 ` [Intel-gfx] [PATCH 7/7] drm/atomic: Reduce setplane locking Ville Syrjala 2019-11-19 10:47 ` Daniel Vetter 2019-11-19 10:47 ` [Intel-gfx] " Daniel Vetter 2019-11-19 10:47 ` Daniel Vetter 2019-11-15 22:59 ` ✗ Fi.CI.CHECKPATCH: warning for drm: Random pile of core stuff Patchwork 2019-11-15 22:59 ` [Intel-gfx] " Patchwork 2019-11-15 23:20 ` ✓ Fi.CI.BAT: success " Patchwork 2019-11-15 23:20 ` [Intel-gfx] " Patchwork 2019-11-17 12:20 ` ✗ Fi.CI.IGT: failure " Patchwork 2019-11-17 12:20 ` [Intel-gfx] " Patchwork
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20191115194204.22244-8-ville.syrjala@linux.intel.com \ --to=ville.syrjala@linux.intel.com \ --cc=dri-devel@lists.freedesktop.org \ --cc=intel-gfx@lists.freedesktop.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.