From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> 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@xxxxxxxxxxxx> Cc: Daniel Vetter <daniel@xxxxxxxx> Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> --- 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