Skip to content

Commit 2facdd6

Browse files
author
Thomas Hellström
committed
dma-buf/dma-fence: Use a successful read_trylock() annotation for dma_fence_begin_signalling()
Condsider the following call sequence: /* Upper layer */ dma_fence_begin_signalling(); lock(tainted_shared_lock); /* Driver callback */ dma_fence_begin_signalling(); ... The driver might here use a utility that is annotated as intended for the dma-fence signalling critical path. Now if the upper layer isn't correctly annotated yet for whatever reason, resulting in /* Upper layer */ lock(tainted_shared_lock); /* Driver callback */ dma_fence_begin_signalling(); We will receive a false lockdep locking order violation notification from dma_fence_begin_signalling(). However entering a dma-fence signalling critical section itself doesn't block and could not cause a deadlock. So use a successful read_trylock() annotation instead for dma_fence_begin_signalling(). That will make sure that the locking order is correctly registered in the first case, and doesn't register any locking order in the second case. The alternative is of course to make sure that the "Upper layer" is always correctly annotated. But experience shows that's not easily achievable in all cases. Signed-off-by: Thomas Hellström <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 0c4558a commit 2facdd6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/dma-buf/dma-fence.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ bool dma_fence_begin_signalling(void)
309309
if (in_atomic())
310310
return true;
311311

312-
/* ... and non-recursive readlock */
313-
lock_acquire(&dma_fence_lockdep_map, 0, 0, 1, 1, NULL, _RET_IP_);
312+
/* ... and non-recursive successful read_trylock */
313+
lock_acquire(&dma_fence_lockdep_map, 0, 1, 1, 1, NULL, _RET_IP_);
314314

315315
return false;
316316
}
@@ -341,7 +341,7 @@ void __dma_fence_might_wait(void)
341341
lock_map_acquire(&dma_fence_lockdep_map);
342342
lock_map_release(&dma_fence_lockdep_map);
343343
if (tmp)
344-
lock_acquire(&dma_fence_lockdep_map, 0, 0, 1, 1, NULL, _THIS_IP_);
344+
lock_acquire(&dma_fence_lockdep_map, 0, 1, 1, 1, NULL, _THIS_IP_);
345345
}
346346
#endif
347347

0 commit comments

Comments
 (0)