[PATCH 1/3] dma-buf/fence: make timeout handling in fence_default_wait consistent
On 2016å¹´10æ17æ¥ 21:55, Christian König wrote: > From: Christian König > > Kernel functions taking a timeout usually return 1 on success even > when they get a zero timeout. > > Signen-off-by: Christian König The series is Reviewed-by: Chunming Zhou > --- > drivers/dma-buf/fence.c | 8 +--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/dma-buf/fence.c b/drivers/dma-buf/fence.c > index 4d51f9e..fb915ab 100644 > --- a/drivers/dma-buf/fence.c > +++ b/drivers/dma-buf/fence.c > @@ -335,18 +335,20 @@ fence_default_wait_cb(struct fence *fence, struct > 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 > fence_default_wait(struct 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(FENCE_FLAG_SIGNALED_BIT, >flags)) > - return timeout; > + return ret; > > spin_lock_irqsave(fence->lock, flags); >
[PATCH 1/3] dma-buf/fence: make timeout handling in fence_default_wait consistent
From: Christian KönigKernel functions taking a timeout usually return 1 on success even when they get a zero timeout. Signen-off-by: Christian König --- drivers/dma-buf/fence.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/dma-buf/fence.c b/drivers/dma-buf/fence.c index 4d51f9e..fb915ab 100644 --- a/drivers/dma-buf/fence.c +++ b/drivers/dma-buf/fence.c @@ -335,18 +335,20 @@ fence_default_wait_cb(struct fence *fence, struct 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 fence_default_wait(struct 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(FENCE_FLAG_SIGNALED_BIT, >flags)) - return timeout; + return ret; spin_lock_irqsave(fence->lock, flags); -- 2.5.0