dma-buf/dma-fence: Extract __dma_fence_is_later()
authorChris Wilson <[email protected]>
Thu, 29 Jun 2017 12:59:24 +0000 (13:59 +0100)
committerGustavo Padovan <[email protected]>
Thu, 29 Jun 2017 21:51:07 +0000 (18:51 -0300)
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 <[email protected]>
Cc: Sumit Semwal <[email protected]>
Cc: Sean Paul <[email protected]>
Cc: Gustavo Padovan <[email protected]>
Reviewed-by: Sean Paul <[email protected]>
Signed-off-by: Gustavo Padovan <[email protected]>
Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
include/linux/dma-fence.h

index a5195a7d6f77e40d23d29ba2793c7b393f4eb0bb..ac5987989e9a473aa904a9537aaea9785412e0a8 100644 (file)
@@ -335,6 +335,19 @@ dma_fence_is_signaled(struct dma_fence *fence)
        return false;
 }
 
+/**
+ * __dma_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 __dma_fence_is_later(u32 f1, u32 f2)
+{
+       return (int)(f1 - f2) > 0;
+}
+
 /**
  * dma_fence_is_later - return if f1 is chronologically later than f2
  * @f1:        [in]    the first fence from the same context
@@ -349,7 +362,7 @@ static inline bool dma_fence_is_later(struct dma_fence *f1,
        if (WARN_ON(f1->context != f2->context))
                return false;
 
-       return (int)(f1->seqno - f2->seqno) > 0;
+       return __dma_fence_is_later(f1->seqno, f2->seqno);
 }
 
 /**