[Intel-gfx] [PATCH 2/4] drm: Introduce drm_modeset_lock_all_ctx_retry()
Ville Syrjala
ville.syrjala at linux.intel.com
Thu Jul 15 18:49:52 UTC 2021
From: Ville Syrjälä <ville.syrjala at 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 at chromium.org>
Cc: Daniel Vetter <daniel at ffwll.ch>
Signed-off-by: Ville Syrjälä <ville.syrjala at 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
More information about the Intel-gfx
mailing list