diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2023-09-11 16:23:42 +0200 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2023-09-11 16:23:42 +0200 |
commit | afaf2b38025ab327c85e218f36d1819e777d4d45 (patch) | |
tree | f474985db8d99bde161ca9aaebad7f2a21a2751d /include | |
parent | Linux 6.6-rc1 (diff) | |
parent | drm/drm_exec: Work around a WW mutex lockdep oddity (diff) | |
download | linux-afaf2b38025ab327c85e218f36d1819e777d4d45.tar.xz linux-afaf2b38025ab327c85e218f36d1819e777d4d45.zip |
Merge tag 'drm-misc-next-fixes-2023-09-11' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
Short summary of fixes pull:
* nouveau: Lockdep workaround
* fbdev/g364fb: Build fix
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
From: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20230911141915.GA983@linux-uq9g
Diffstat (limited to 'include')
-rw-r--r-- | include/drm/drm_exec.h | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/include/drm/drm_exec.h b/include/drm/drm_exec.h index e0462361adf9..b5bf0b6da791 100644 --- a/include/drm/drm_exec.h +++ b/include/drm/drm_exec.h @@ -52,6 +52,20 @@ struct drm_exec { }; /** + * drm_exec_obj() - Return the object for a give drm_exec index + * @exec: Pointer to the drm_exec context + * @index: The index. + * + * Return: Pointer to the locked object corresponding to @index if + * index is within the number of locked objects. NULL otherwise. + */ +static inline struct drm_gem_object * +drm_exec_obj(struct drm_exec *exec, unsigned long index) +{ + return index < exec->num_objects ? exec->objects[index] : NULL; +} + +/** * drm_exec_for_each_locked_object - iterate over all the locked objects * @exec: drm_exec object * @index: unsigned long index for the iteration @@ -59,10 +73,23 @@ struct drm_exec { * * Iterate over all the locked GEM objects inside the drm_exec object. */ -#define drm_exec_for_each_locked_object(exec, index, obj) \ - for (index = 0, obj = (exec)->objects[0]; \ - index < (exec)->num_objects; \ - ++index, obj = (exec)->objects[index]) +#define drm_exec_for_each_locked_object(exec, index, obj) \ + for ((index) = 0; ((obj) = drm_exec_obj(exec, index)); ++(index)) + +/** + * drm_exec_for_each_locked_object_reverse - iterate over all the locked + * objects in reverse locking order + * @exec: drm_exec object + * @index: unsigned long index for the iteration + * @obj: the current GEM object + * + * Iterate over all the locked GEM objects inside the drm_exec object in + * reverse locking order. Note that @index may go below zero and wrap, + * but that will be caught by drm_exec_obj(), returning a NULL object. + */ +#define drm_exec_for_each_locked_object_reverse(exec, index, obj) \ + for ((index) = (exec)->num_objects - 1; \ + ((obj) = drm_exec_obj(exec, index)); --(index)) /** * drm_exec_until_all_locked - loop until all GEM objects are locked |