From: Chris Wilson Date: Thu, 29 Jun 2017 12:59:24 +0000 (+0100) Subject: dma-buf/dma-fence: Extract __dma_fence_is_later() X-Git-Tag: C0P2-H0.0--20200415~6401 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=b53525eaac5590d06785f5fbdd8265b73ecbc911;p=linux.git dma-buf/dma-fence: Extract __dma_fence_is_later() commit 8111477663813caa1a4469cfe6afaae36cd04513 upstream. Often we have the task of comparing two seqno known to be on the same context, so provide a common __dma_fence_is_later(). Signed-off-by: Chris Wilson Cc: Sumit Semwal Cc: Sean Paul Cc: Gustavo Padovan Reviewed-by: Sean Paul Signed-off-by: Gustavo Padovan Link: http://patchwork.freedesktop.org/patch/msgid/20170629125930.821-1-chris@chris-wilson.co.uk [renamed to __fence_is_later() - gregkh] Cc: Jisheng Zhang Signed-off-by: Greg Kroah-Hartman --- diff --git a/include/linux/fence.h b/include/linux/fence.h index 0d763053f97a..fcb69f99d717 100644 --- a/include/linux/fence.h +++ b/include/linux/fence.h @@ -280,6 +280,19 @@ fence_is_signaled(struct fence *fence) return false; } +/** + * __fence_is_later - return if f1 is chronologically later than f2 + * @f1: [in] the first fence's seqno + * @f2: [in] the second fence's seqno 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 common across contexts. + */ +static inline bool __fence_is_later(u32 f1, u32 f2) +{ + return (int)(f1 - f2) > 0; +} + /** * fence_is_later - return if f1 is chronologically later than f2 * @f1: [in] the first fence from the same context @@ -293,7 +306,7 @@ static inline bool fence_is_later(struct fence *f1, struct fence *f2) if (WARN_ON(f1->context != f2->context)) return false; - return (int)(f1->seqno - f2->seqno) > 0; + return __fence_is_later(f1->seqno, f2->seqno); } /**