]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.68/dma-buf-sw_sync-move-timeline_fence_ops-around.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.68 / dma-buf-sw_sync-move-timeline_fence_ops-around.patch
1 From 150b6a9d7d6fffb95c0a5349960a10569e8218b5 Mon Sep 17 00:00:00 2001
2 From: Gustavo Padovan <gustavo.padovan@collabora.com>
3 Date: Sat, 29 Jul 2017 12:22:15 -0300
4 Subject: dma-buf/sw_sync: move timeline_fence_ops around
5
6 From: Gustavo Padovan <gustavo.padovan@collabora.com>
7
8 commit 150b6a9d7d6fffb95c0a5349960a10569e8218b5 upstream.
9
10 We are going to use timeline_fence_signaled() in a internal function in
11 the next commit.
12
13 Cc: Chris Wilson <chris@chris-wilson.co.uk>
14 Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
15 Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
16 Link: https://patchwork.freedesktop.org/patch/msgid/20170729152217.8362-1-gustavo@padovan.org
17 [s/dma_fence/fence/g - gregkh]
18 Cc: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21 ---
22 drivers/dma-buf/sw_sync.c | 138 +++++++++++++++++++++++-----------------------
23 1 file changed, 69 insertions(+), 69 deletions(-)
24
25 --- a/drivers/dma-buf/sw_sync.c
26 +++ b/drivers/dma-buf/sw_sync.c
27 @@ -125,6 +125,75 @@ static void sync_timeline_put(struct syn
28 kref_put(&obj->kref, sync_timeline_free);
29 }
30
31 +static const char *timeline_fence_get_driver_name(struct fence *fence)
32 +{
33 + return "sw_sync";
34 +}
35 +
36 +static const char *timeline_fence_get_timeline_name(struct fence *fence)
37 +{
38 + struct sync_timeline *parent = fence_parent(fence);
39 +
40 + return parent->name;
41 +}
42 +
43 +static void timeline_fence_release(struct fence *fence)
44 +{
45 + struct sync_pt *pt = fence_to_sync_pt(fence);
46 + struct sync_timeline *parent = fence_parent(fence);
47 +
48 + if (!list_empty(&pt->link)) {
49 + unsigned long flags;
50 +
51 + spin_lock_irqsave(fence->lock, flags);
52 + if (!list_empty(&pt->link)) {
53 + list_del(&pt->link);
54 + rb_erase(&pt->node, &parent->pt_tree);
55 + }
56 + spin_unlock_irqrestore(fence->lock, flags);
57 + }
58 +
59 + sync_timeline_put(parent);
60 + fence_free(fence);
61 +}
62 +
63 +static bool timeline_fence_signaled(struct fence *fence)
64 +{
65 + struct sync_timeline *parent = fence_parent(fence);
66 +
67 + return !__fence_is_later(fence->seqno, parent->value);
68 +}
69 +
70 +static bool timeline_fence_enable_signaling(struct fence *fence)
71 +{
72 + return true;
73 +}
74 +
75 +static void timeline_fence_value_str(struct fence *fence,
76 + char *str, int size)
77 +{
78 + snprintf(str, size, "%d", fence->seqno);
79 +}
80 +
81 +static void timeline_fence_timeline_value_str(struct fence *fence,
82 + char *str, int size)
83 +{
84 + struct sync_timeline *parent = fence_parent(fence);
85 +
86 + snprintf(str, size, "%d", parent->value);
87 +}
88 +
89 +static const struct fence_ops timeline_fence_ops = {
90 + .get_driver_name = timeline_fence_get_driver_name,
91 + .get_timeline_name = timeline_fence_get_timeline_name,
92 + .enable_signaling = timeline_fence_enable_signaling,
93 + .signaled = timeline_fence_signaled,
94 + .wait = fence_default_wait,
95 + .release = timeline_fence_release,
96 + .fence_value_str = timeline_fence_value_str,
97 + .timeline_value_str = timeline_fence_timeline_value_str,
98 +};
99 +
100 /**
101 * sync_timeline_signal() - signal a status change on a sync_timeline
102 * @obj: sync_timeline to signal
103 @@ -216,75 +285,6 @@ unlock:
104 return pt;
105 }
106
107 -static const char *timeline_fence_get_driver_name(struct fence *fence)
108 -{
109 - return "sw_sync";
110 -}
111 -
112 -static const char *timeline_fence_get_timeline_name(struct fence *fence)
113 -{
114 - struct sync_timeline *parent = fence_parent(fence);
115 -
116 - return parent->name;
117 -}
118 -
119 -static void timeline_fence_release(struct fence *fence)
120 -{
121 - struct sync_pt *pt = fence_to_sync_pt(fence);
122 - struct sync_timeline *parent = fence_parent(fence);
123 -
124 - if (!list_empty(&pt->link)) {
125 - unsigned long flags;
126 -
127 - spin_lock_irqsave(fence->lock, flags);
128 - if (!list_empty(&pt->link)) {
129 - list_del(&pt->link);
130 - rb_erase(&pt->node, &parent->pt_tree);
131 - }
132 - spin_unlock_irqrestore(fence->lock, flags);
133 - }
134 -
135 - sync_timeline_put(parent);
136 - fence_free(fence);
137 -}
138 -
139 -static bool timeline_fence_signaled(struct fence *fence)
140 -{
141 - struct sync_timeline *parent = fence_parent(fence);
142 -
143 - return !__fence_is_later(fence->seqno, parent->value);
144 -}
145 -
146 -static bool timeline_fence_enable_signaling(struct fence *fence)
147 -{
148 - return true;
149 -}
150 -
151 -static void timeline_fence_value_str(struct fence *fence,
152 - char *str, int size)
153 -{
154 - snprintf(str, size, "%d", fence->seqno);
155 -}
156 -
157 -static void timeline_fence_timeline_value_str(struct fence *fence,
158 - char *str, int size)
159 -{
160 - struct sync_timeline *parent = fence_parent(fence);
161 -
162 - snprintf(str, size, "%d", parent->value);
163 -}
164 -
165 -static const struct fence_ops timeline_fence_ops = {
166 - .get_driver_name = timeline_fence_get_driver_name,
167 - .get_timeline_name = timeline_fence_get_timeline_name,
168 - .enable_signaling = timeline_fence_enable_signaling,
169 - .signaled = timeline_fence_signaled,
170 - .wait = fence_default_wait,
171 - .release = timeline_fence_release,
172 - .fence_value_str = timeline_fence_value_str,
173 - .timeline_value_str = timeline_fence_timeline_value_str,
174 -};
175 -
176 /*
177 * *WARNING*
178 *