aboutsummaryrefslogtreecommitdiff
path: root/include/drm
diff options
context:
space:
mode:
authorThomas Hellström <thomas.hellstrom@linux.intel.com>2026-05-20 12:16:14 +0200
committerThomas Hellström <thomas.hellstrom@linux.intel.com>2026-05-25 10:45:38 +0200
commit25331d9d40d093dfe2805ab558e8ad238bd2a2dc (patch)
tree8a90f7ff1b014bfcad4e17b44419d8adeb18cd1c /include/drm
parentce44b78512e9102aea54ff6b6e521d6c8de9f31c (diff)
drm/exec: Make the drm_exec_until_all_locked() macro more readable
Use __UNIQUE_ID as done elsewhere in the kernel rather than a hand-rolled __PASTE to craft a unique id. Also use __maybe_unused rather than (void) to signify that a variable, althrough written to, may not actually be used. v2: - Move assignment to declaration (Christian) - Declare the retry pointer as void *const. Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Reviewed-by: Christian König <christian.koenig@amd.com> Link: https://patch.msgid.link/20260520101616.41284-3-thomas.hellstrom@linux.intel.com
Diffstat (limited to 'include/drm')
-rw-r--r--include/drm/drm_exec.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/include/drm/drm_exec.h b/include/drm/drm_exec.h
index dee6ebdbe416..18f84faabbb9 100644
--- a/include/drm/drm_exec.h
+++ b/include/drm/drm_exec.h
@@ -95,6 +95,17 @@ drm_exec_obj(struct drm_exec *exec, unsigned long index)
#define drm_exec_for_each_locked_object_reverse(exec, obj) \
__drm_exec_for_each_locked_object_reverse(exec, obj, __UNIQUE_ID(drm_exec))
+/*
+ * Helper to drm_exec_until_all_locked(). Don't use directly.
+ *
+ * Since labels can't be defined local to the loop's body we use a jump pointer
+ * to make sure that the retry is only used from within the loop's body.
+ */
+#define __drm_exec_until_all_locked(exec, _label) \
+_label: \
+ for (void *const __maybe_unused __drm_exec_retry_ptr = &&_label; \
+ drm_exec_cleanup(exec);)
+
/**
* drm_exec_until_all_locked - loop until all GEM objects are locked
* @exec: drm_exec object
@@ -102,17 +113,9 @@ drm_exec_obj(struct drm_exec *exec, unsigned long index)
* Core functionality of the drm_exec object. Loops until all GEM objects are
* locked and no more contention exists. At the beginning of the loop it is
* guaranteed that no GEM object is locked.
- *
- * Since labels can't be defined local to the loops body we use a jump pointer
- * to make sure that the retry is only used from within the loops body.
*/
#define drm_exec_until_all_locked(exec) \
-__PASTE(__drm_exec_, __LINE__): \
- for (void *__drm_exec_retry_ptr; ({ \
- __drm_exec_retry_ptr = &&__PASTE(__drm_exec_, __LINE__);\
- (void)__drm_exec_retry_ptr; \
- drm_exec_cleanup(exec); \
- });)
+ __drm_exec_until_all_locked(exec, __UNIQUE_ID(drm_exec))
/**
* drm_exec_retry_on_contention - restart the loop to grap all locks