Skip to content

Commit c745744

Browse files
ChristianKoenigAMDgregkh
authored andcommitted
dma-buf: fix timeout handling in dma_resv_wait_timeout v2
commit 2b95a7d upstream. Even the kerneldoc says that with a zero timeout the function should not wait for anything, but still return 1 to indicate that the fences are signaled now. Unfortunately that isn't what was implemented, instead of only returning 1 we also waited for at least one jiffies. Fix that by adjusting the handling to what the function is actually documented to do. v2: improve code readability Reported-by: Marek Olšák <[email protected]> Reported-by: Lucas Stach <[email protected]> Signed-off-by: Christian König <[email protected]> Reviewed-by: Lucas Stach <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 631f9de commit c745744

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/dma-buf/dma-resv.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -685,11 +685,13 @@ long dma_resv_wait_timeout(struct dma_resv *obj, enum dma_resv_usage usage,
685685
dma_resv_iter_begin(&cursor, obj, usage);
686686
dma_resv_for_each_fence_unlocked(&cursor, fence) {
687687

688-
ret = dma_fence_wait_timeout(fence, intr, ret);
689-
if (ret <= 0) {
690-
dma_resv_iter_end(&cursor);
691-
return ret;
692-
}
688+
ret = dma_fence_wait_timeout(fence, intr, timeout);
689+
if (ret <= 0)
690+
break;
691+
692+
/* Even for zero timeout the return value is 1 */
693+
if (timeout)
694+
timeout = ret;
693695
}
694696
dma_resv_iter_end(&cursor);
695697

0 commit comments

Comments
 (0)