Skip to content

Commit 9253006

Browse files
ChristianKoenigAMDgregkh
authored andcommitted
dma-buf: fix timeout handling in dma_resv_wait_timeout v2
commit 2b95a7db6e0f75587bffddbb490399cbb87e4985 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 c2b47b8 commit 9253006

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
@@ -673,11 +673,13 @@ long dma_resv_wait_timeout(struct dma_resv *obj, enum dma_resv_usage usage,
673673
dma_resv_iter_begin(&cursor, obj, usage);
674674
dma_resv_for_each_fence_unlocked(&cursor, fence) {
675675

676-
ret = dma_fence_wait_timeout(fence, intr, ret);
677-
if (ret <= 0) {
678-
dma_resv_iter_end(&cursor);
679-
return ret;
680-
}
676+
ret = dma_fence_wait_timeout(fence, intr, timeout);
677+
if (ret <= 0)
678+
break;
679+
680+
/* Even for zero timeout the return value is 1 */
681+
if (timeout)
682+
timeout = ret;
681683
}
682684
dma_resv_iter_end(&cursor);
683685

0 commit comments

Comments
 (0)