Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Sean Paul <seanpaul@chromium.org>, dri-devel@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH 2/4] drm: Introduce drm_modeset_lock_all_ctx_retry()
Date: Thu, 15 Jul 2021 21:49:52 +0300	[thread overview]
Message-ID: <20210715184954.7794-3-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20210715184954.7794-1-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Layer drm_modeset_lock_all_ctx_retry() on top of
drm_modeset_lock_ctx_retry() to make the fairly common
"let's lock everything" pattern nicer.

Currently we have DRM_MODESET_LOCK_ALL_{BEGIN,END}() for this
but I don't really like it due to the magic gotos within,
which makes it hard to use if you want to do multiple steps
between the BEGING/END. One would either have to know the
name of the magic label, or always wrap the whole thing into
a function so only the single call appears between the BEGIN/END.

Cc: Sean Paul <seanpaul@chromium.org>
Cc: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 include/drm/drm_modeset_lock.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/drm/drm_modeset_lock.h b/include/drm/drm_modeset_lock.h
index 5eaad2533de5..2e2548680aaa 100644
--- a/include/drm/drm_modeset_lock.h
+++ b/include/drm/drm_modeset_lock.h
@@ -223,4 +223,10 @@ void _drm_modeset_lock_end(struct drm_modeset_acquire_ctx *ctx,
 	     _drm_modeset_lock_loop(&(ret)); \
 	     _drm_modeset_lock_end((ctx), (state), &(ret)))
 
+#define drm_modeset_lock_all_ctx_retry(dev, ctx, state, flags, ret) \
+	for (_drm_modeset_lock_begin((ctx), (state), (flags), &(ret)); \
+	     _drm_modeset_lock_loop(&(ret)); \
+	     _drm_modeset_lock_end((ctx), (state), &(ret))) \
+		for_each_if(((ret) = drm_modeset_lock_all_ctx((dev), (ctx))) == 0)
+
 #endif /* DRM_MODESET_LOCK_H_ */
-- 
2.31.1

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

  parent reply	other threads:[~2021-07-15 18:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15 18:49 [Intel-gfx] [PATCH 0/4] drm: Make modeset locking easier Ville Syrjala
2021-07-15 18:49 ` [Intel-gfx] [PATCH 1/4] drm: Introduce drm_modeset_lock_ctx_retry() Ville Syrjala
2021-07-20 13:44   ` Daniel Vetter
2021-10-04 11:15     ` Ville Syrjälä
2021-10-13 11:59       ` Daniel Vetter
2021-10-13 12:06         ` Ville Syrjälä
2021-10-13 21:00           ` Fernando Ramos
2021-10-14 13:23             ` Daniel Vetter
2021-07-15 18:49 ` Ville Syrjala [this message]
2021-07-15 18:49 ` [Intel-gfx] [PATCH 3/4] drm/i915: Extract intel_crtc_initial_commit() Ville Syrjala
2021-07-15 18:49 ` [Intel-gfx] [PATCH 4/4] drm/i915: Use drm_modeset_lock_ctx_retry() & co Ville Syrjala
2021-07-16 22:21 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm: Make modeset locking easier Patchwork
2021-07-16 22:24 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-07-16 22:27 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2021-07-16 22:50 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-07-17  7:20 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " 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=20210715184954.7794-3-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=seanpaul@chromium.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: 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