Hey, Can't you simply add if (!timeout) return !reservation_object_test_signaled_rcu(obj, wait_all); to the beginning instead? Waiting with timeout = 0 is not really defined. Look at fence_default_wait for example. It returns timeout if the fence is signaled, but since this is 0 you can't distinguish between timed out wait and succesful wait.
Also why do you need this? Why not simply return 0 with timeout = 0. ~Maarten On 13-01-15 06:50, Jammy Zhou wrote: > When the timeout value passed to reservation_object_wait_timeout_rcu > is zero, no wait should be done if the fences are not signaled. > > Return '1' for idle and '0' for busy if the specified timeout is '0' > to keep consistent with the case of non-zero timeout. > > v2: call fence_put if not signaled in the case of timeout==0 > > Signed-off-by: Jammy Zhou <Jammy.Zhou at amd.com> > Reviewed-by: Christian König <christian.koenig at amd.com> > Reviewed-by: Alex Deucher <alexander.deucher at amd.com> > --- > drivers/dma-buf/reservation.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c > index 3c97c8f..b1d554f 100644 > --- a/drivers/dma-buf/reservation.c > +++ b/drivers/dma-buf/reservation.c > @@ -380,12 +380,19 @@ retry: > } > > rcu_read_unlock(); > - if (fence) { > + if (fence && timeout) { > ret = fence_wait_timeout(fence, intr, ret); > fence_put(fence); > if (ret > 0 && wait_all && (i + 1 < shared_count)) > goto retry; > } > + > + if (fence && !timeout) > + fence_put(fence); > + > + if (!fence && !timeout) > + ret = 1; > + > return ret; > > unlock_retry: >