From: Alex Deucher Date: Mon, 7 Nov 2016 21:16:13 +0000 (-0500) Subject: dma-buf/fence: make timeout handling in fence_default_wait consistent (v2) X-Git-Tag: v4.10-rc1~154^2~36^2~13 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=bcc004b629d22ae202988e4c5424564e0b4f1217;p=karo-tx-linux.git dma-buf/fence: make timeout handling in fence_default_wait consistent (v2) Kernel functions taking a timeout usually return 1 on success even when they get a zero timeout. v2: agd: rebase on drm-next Reviewed-by: Alex Deucher Signed-off-by: Christian König Reviewed-by: Chunming Zhou Reviewed-by: Gustavo Padovan Signed-off-by: Alex Deucher Signed-off-by: Sumit Semwal Link: http://patchwork.freedesktop.org/patch/msgid/1478553376-18575-1-git-send-email-alexander.deucher@amd.com --- diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c index cda40cbd8c43..70f4fcc0bc03 100644 --- a/drivers/dma-buf/dma-fence.c +++ b/drivers/dma-buf/dma-fence.c @@ -339,18 +339,20 @@ dma_fence_default_wait_cb(struct dma_fence *fence, struct dma_fence_cb *cb) * @timeout: [in] timeout value in jiffies, or MAX_SCHEDULE_TIMEOUT * * Returns -ERESTARTSYS if interrupted, 0 if the wait timed out, or the - * remaining timeout in jiffies on success. + * remaining timeout in jiffies on success. If timeout is zero the value one is + * returned if the fence is already signaled for consistency with other + * functions taking a jiffies timeout. */ signed long dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout) { struct default_wait_cb cb; unsigned long flags; - signed long ret = timeout; + signed long ret = timeout ? timeout : 1; bool was_set; if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) - return timeout; + return ret; spin_lock_irqsave(fence->lock, flags);