Message ID | 1446134703-32433-3-git-send-email-deathsimple@vodafone.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi Christian / Alex, On 29 October 2015 at 21:34, Christian König <deathsimple@vodafone.de> wrote: > From: Christian König <christian.koenig@amd.com> > > Return true when fence 1 is later than fence 2 without > checking if any of them are signaled. > > Useful for driver specific resource handling based on fences. > > Signed-off-by: Christian König <christian.koenig@amd.com> > Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Please feel free to add my Acked-by: Sumit Semwal <sumit.semwal@linaro.org> and take the dma-buf patches via the drm tree, if you'd like. > --- > include/linux/fence.h | 22 +++++++++++++++++++--- > 1 file changed, 19 insertions(+), 3 deletions(-) > > diff --git a/include/linux/fence.h b/include/linux/fence.h > index a4084d6..bb52201 100644 > --- a/include/linux/fence.h > +++ b/include/linux/fence.h > @@ -280,6 +280,22 @@ fence_is_signaled(struct fence *fence) > } > > /** > + * fence_is_later - return if f1 is chronologically later than f2 > + * @f1: [in] the first fence from the same context > + * @f2: [in] the second fence from the same context > + * > + * Returns true if f1 is chronologically later than f2. Both fences must be > + * from the same context, since a seqno is not re-used across contexts. > + */ > +static inline bool fence_is_later(struct fence *f1, struct fence *f2) > +{ > + if (WARN_ON(f1->context != f2->context)) > + return false; > + > + return f1->seqno - f2->seqno < INT_MAX; > +} > + > +/** > * fence_later - return the chronologically later fence > * @f1: [in] the first fence from the same context > * @f2: [in] the second fence from the same context > @@ -298,10 +314,10 @@ static inline struct fence *fence_later(struct fence *f1, struct fence *f2) > * set if enable_signaling wasn't called, and enabling that here is > * overkill. > */ > - if (f2->seqno - f1->seqno <= INT_MAX) > - return fence_is_signaled(f2) ? NULL : f2; > - else > + if (fence_is_later(f1, f2)) > return fence_is_signaled(f1) ? NULL : f1; > + else > + return fence_is_signaled(f2) ? NULL : f2; > } > > signed long fence_wait_timeout(struct fence *, bool intr, signed long timeout); > -- > 1.9.1 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/dri-devel
diff --git a/include/linux/fence.h b/include/linux/fence.h index a4084d6..bb52201 100644 --- a/include/linux/fence.h +++ b/include/linux/fence.h @@ -280,6 +280,22 @@ fence_is_signaled(struct fence *fence) } /** + * fence_is_later - return if f1 is chronologically later than f2 + * @f1: [in] the first fence from the same context + * @f2: [in] the second fence from the same context + * + * Returns true if f1 is chronologically later than f2. Both fences must be + * from the same context, since a seqno is not re-used across contexts. + */ +static inline bool fence_is_later(struct fence *f1, struct fence *f2) +{ + if (WARN_ON(f1->context != f2->context)) + return false; + + return f1->seqno - f2->seqno < INT_MAX; +} + +/** * fence_later - return the chronologically later fence * @f1: [in] the first fence from the same context * @f2: [in] the second fence from the same context @@ -298,10 +314,10 @@ static inline struct fence *fence_later(struct fence *f1, struct fence *f2) * set if enable_signaling wasn't called, and enabling that here is * overkill. */ - if (f2->seqno - f1->seqno <= INT_MAX) - return fence_is_signaled(f2) ? NULL : f2; - else + if (fence_is_later(f1, f2)) return fence_is_signaled(f1) ? NULL : f1; + else + return fence_is_signaled(f2) ? NULL : f2; } signed long fence_wait_timeout(struct fence *, bool intr, signed long timeout);