drm/syncobj: Deal with signalled fences in drm_syncobj_find_fence.
authorjsg <jsg@openbsd.org>
Tue, 14 Dec 2021 13:32:09 +0000 (13:32 +0000)
committerjsg <jsg@openbsd.org>
Tue, 14 Dec 2021 13:32:09 +0000 (13:32 +0000)
From Bas Nieuwenhuizen
2737d0bc21b6db199b4145e12b9f1745577d7944 in linux 5.10.y/5.10.85
b19926d4f3a660a8b76e5d989ffd1168e619a5c4 in mainline linux

sys/dev/pci/drm/drm_syncobj.c

index 2d157a1..f792dd1 100644 (file)
@@ -395,8 +395,17 @@ int drm_syncobj_find_fence(struct drm_file *file_private,
 
        if (*fence) {
                ret = dma_fence_chain_find_seqno(fence, point);
-               if (!ret)
+               if (!ret) {
+                       /* If the requested seqno is already signaled
+                        * drm_syncobj_find_fence may return a NULL
+                        * fence. To make sure the recipient gets
+                        * signalled, use a new fence instead.
+                        */
+                       if (!*fence)
+                               *fence = dma_fence_get_stub();
+
                        goto out;
+               }
                dma_fence_put(*fence);
        } else {
                ret = -EINVAL;