drm/syncobj: call might_sleep before waiting for fence submission
authorErik Kurzinger <ekurzinger@nvidia.com>
Fri, 19 Jan 2024 16:32:08 +0000 (08:32 -0800)
committerSimon Ser <contact@emersion.fr>
Thu, 22 Feb 2024 10:27:49 +0000 (11:27 +0100)
If either the DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT or
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE flags are passed to
drm_syncobj_array_wait_timeout, the function might sleep if the fence at
one of the given timeline points has not yet been submitted. Therefore,
we should call might_sleep in that case to catch potential bugs.

Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Simon Ser <contact@emersion.fr>
Link: https://patchwork.freedesktop.org/patch/msgid/20240119163208.3723457-3-ekurzinger@nvidia.com
drivers/gpu/drm/drm_syncobj.c

index fada77f04a8c31f27e5946c51f61c1a0d1233b5a..4dd79036776569b9a34a32076f3f4f56f7190e44 100644 (file)
@@ -1044,8 +1044,10 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
        uint32_t signaled_count, i;
 
        if (flags & (DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT |
-                    DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE))
+                    DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE)) {
+               might_sleep();
                lockdep_assert_none_held_once();
+       }
 
        points = kmalloc_array(count, sizeof(*points), GFP_KERNEL);
        if (points == NULL)