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 <alexander.deucher@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1478553376-18575-1-git-send-email-alexander.deucher@amd.com
This commit is contained in:
Alex Deucher 2016-11-07 16:16:13 -05:00 коммит произвёл Sumit Semwal
Родитель eef18a827a
Коммит bcc004b629
1 изменённых файлов: 5 добавлений и 3 удалений

Просмотреть файл

@ -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 * @timeout: [in] timeout value in jiffies, or MAX_SCHEDULE_TIMEOUT
* *
* Returns -ERESTARTSYS if interrupted, 0 if the wait timed out, or the * 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 signed long
dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout) dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout)
{ {
struct default_wait_cb cb; struct default_wait_cb cb;
unsigned long flags; unsigned long flags;
signed long ret = timeout; signed long ret = timeout ? timeout : 1;
bool was_set; bool was_set;
if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
return timeout; return ret;
spin_lock_irqsave(fence->lock, flags); spin_lock_irqsave(fence->lock, flags);