Skip to content

Commit 2aa6f5b

Browse files
Erik Kurzingeremersion
authored andcommitted
drm/syncobj: handle NULL fence in syncobj_eventfd_entry_func
During syncobj_eventfd_entry_func, dma_fence_chain_find_seqno may set the fence to NULL if the given seqno is signaled and a later seqno has already been submitted. In that case, the eventfd should be signaled immediately which currently does not happen. This is a similar issue to the one addressed by commit b19926d ("drm/syncobj: Deal with signalled fences in drm_syncobj_find_fence."). As a fix, if the return value of dma_fence_chain_find_seqno indicates success but it sets the fence to NULL, we will assign a stub fence to ensure the following code still signals the eventfd. v1 -> v2: assign a stub fence instead of signaling the eventfd Signed-off-by: Erik Kurzinger <[email protected]> Fixes: c7a4722 ("drm/syncobj: add IOCTL to register an eventfd") Signed-off-by: Simon Ser <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 3c43177 commit 2aa6f5b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/gpu/drm/drm_syncobj.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1418,10 +1418,21 @@ syncobj_eventfd_entry_func(struct drm_syncobj *syncobj,
14181418

14191419
/* This happens inside the syncobj lock */
14201420
fence = dma_fence_get(rcu_dereference_protected(syncobj->fence, 1));
1421+
if (!fence)
1422+
return;
1423+
14211424
ret = dma_fence_chain_find_seqno(&fence, entry->point);
1422-
if (ret != 0 || !fence) {
1425+
if (ret != 0) {
1426+
/* The given seqno has not been submitted yet. */
14231427
dma_fence_put(fence);
14241428
return;
1429+
} else if (!fence) {
1430+
/* If dma_fence_chain_find_seqno returns 0 but sets the fence
1431+
* to NULL, it implies that the given seqno is signaled and a
1432+
* later seqno has already been submitted. Assign a stub fence
1433+
* so that the eventfd still gets signaled below.
1434+
*/
1435+
fence = dma_fence_get_stub();
14251436
}
14261437

14271438
list_del_init(&entry->node);

0 commit comments

Comments
 (0)