[PATCH] reservation: wait only with non-zero timeout specified (v3)

Daniel Vetter daniel at ffwll.ch
Tue Jan 13 14:10:02 PST 2015


On Tue, Jan 13, 2015 at 11:18:19AM +0100, Maarten Lankhorst wrote:
> Op 13-01-15 om 10:22 schreef Christian König:
> > Am 13.01.2015 um 10:04 schrieb Maarten Lankhorst:
> >> Op 13-01-15 om 10:36 schreef Jammy Zhou:
> >>> 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
> >>>
> >>>
> >> Looks more sane, but where do you need this?
> >
> > The rational is that we want a single function to call from the driver no matter what timeout we have and get a zero if the call timed out and a non zero value otherwise.
> >
> > When we called reservation_object_wait_timeout_rcu with a timeout of zero we got a return value of zero as well independent of whether or not the fences were signaled. That behavior looked inconsistent and Jammy is trying to fix this with this patch.
> >
> > We could of course do the check in the calling code as well, but to me it rather looked like the calling convention of reservation_object_wait_timeout_rcu should be thought over one more time.
> >
> > Either calling it with timeout=0 is invalid and the driver needs to call reservation_object_test_signaled_rcu directly instead or we apply this patch or something similar to get an useful behavior in the case of timeout=0.
> I think it would be best to leave timeout=0 returning 0. Not handling it differently gives the same semantics as used by fence_wait_time and wait_event_timeout.
> Are there really many cases in which you don't know if timeout = 0 before or not?

Yeah I think with this it's more important to be consistent with all the
other wait_something primitives the kernel exposes.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


More information about the dri-devel mailing list