]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.68/dma-buf-dma-fence-extract-__dma_fence_is_later.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.68 / dma-buf-dma-fence-extract-__dma_fence_is_later.patch
CommitLineData
722dfc38
GKH
1From 8111477663813caa1a4469cfe6afaae36cd04513 Mon Sep 17 00:00:00 2001
2From: Chris Wilson <chris@chris-wilson.co.uk>
3Date: Thu, 29 Jun 2017 13:59:24 +0100
4Subject: dma-buf/dma-fence: Extract __dma_fence_is_later()
5
6From: Chris Wilson <chris@chris-wilson.co.uk>
7
8commit 8111477663813caa1a4469cfe6afaae36cd04513 upstream.
9
10Often we have the task of comparing two seqno known to be on the same
11context, so provide a common __dma_fence_is_later().
12
13Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
14Cc: Sumit Semwal <sumit.semwal@linaro.org>
15Cc: Sean Paul <seanpaul@chromium.org>
16Cc: Gustavo Padovan <gustavo@padovan.org>
17Reviewed-by: Sean Paul <seanpaul@chromium.org>
18Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
19Link: http://patchwork.freedesktop.org/patch/msgid/20170629125930.821-1-chris@chris-wilson.co.uk
20[renamed to __fence_is_later() - gregkh]
21Cc: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
22Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23
24---
25 include/linux/fence.h | 15 ++++++++++++++-
26 1 file changed, 14 insertions(+), 1 deletion(-)
27
28--- a/include/linux/fence.h
29+++ b/include/linux/fence.h
30@@ -281,6 +281,19 @@ fence_is_signaled(struct fence *fence)
31 }
32
33 /**
34+ * __fence_is_later - return if f1 is chronologically later than f2
35+ * @f1: [in] the first fence's seqno
36+ * @f2: [in] the second fence's seqno from the same context
37+ *
38+ * Returns true if f1 is chronologically later than f2. Both fences must be
39+ * from the same context, since a seqno is not common across contexts.
40+ */
41+static inline bool __fence_is_later(u32 f1, u32 f2)
42+{
43+ return (int)(f1 - f2) > 0;
44+}
45+
46+/**
47 * fence_is_later - return if f1 is chronologically later than f2
48 * @f1: [in] the first fence from the same context
49 * @f2: [in] the second fence from the same context
50@@ -293,7 +306,7 @@ static inline bool fence_is_later(struct
51 if (WARN_ON(f1->context != f2->context))
52 return false;
53
54- return (int)(f1->seqno - f2->seqno) > 0;
55+ return __fence_is_later(f1->seqno, f2->seqno);
56 }
57
58 /**