From: Daniel Vetter <daniel@ffwll.ch>
To: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 7/7] drm/atomic: Reduce setplane locking
Date: Tue, 19 Nov 2019 11:47:11 +0100 [thread overview]
Message-ID: <20191119104711.GD30416@phenom.ffwll.local> (raw)
Message-ID: <20191119104711.CkjDxnRqVsHH4Kee5S8iDXxorv2XYGg8G4lNssGqp0g@z> (raw)
In-Reply-To: <20191115194204.22244-8-ville.syrjala@linux.intel.com>
On Fri, Nov 15, 2019 at 09:42:04PM +0200, Ville Syrjala wrote:
> 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;
There's pre-nv50 nouveau and shmob which have planes and aren't atomic (if
I checked correctly), so we could probably forgo this, but also feels
like totally not worth the audit trouble.
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> +
> /* 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
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2019-11-19 10:47 UTC|newest]
Thread overview: 29+ 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 ` Ville Syrjala
2019-11-15 19:41 ` [PATCH 1/7] drm: Move page_flip fb lookup earlier 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 ` Ville Syrjala
2019-11-15 19:42 ` [PATCH 3/7] drm: Extract page_flip_{internal, atomic}() 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-22 18:35 ` Ville Syrjälä
2019-11-22 18:35 ` [Intel-gfx] " Ville Syrjälä
2019-11-25 9:02 ` Daniel Vetter
2019-11-25 9:02 ` [Intel-gfx] " Daniel Vetter
2019-11-25 15:05 ` Ville Syrjälä
2019-11-25 15:05 ` [Intel-gfx] " Ville Syrjälä
2019-11-25 17:24 ` Daniel Vetter
2019-11-25 17:24 ` [Intel-gfx] " 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 ` 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 ` Ville Syrjala
2019-11-19 10:39 ` 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-19 10:20 ` Daniel Vetter
2019-11-19 10:20 ` Daniel Vetter
2019-11-15 19:42 ` [PATCH 7/7] drm/atomic: Reduce setplane locking Ville Syrjala
2019-11-19 10:47 ` Daniel Vetter [this message]
2019-11-19 10:47 ` Daniel Vetter
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=20191119104711.GD30416@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=ville.syrjala@linux.intel.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).