diff options
author | Gustavo Padovan <gustavo.padovan@collabora.com> | 2017-07-29 11:22:15 -0400 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.com> | 2017-07-31 13:10:33 -0400 |
commit | 150b6a9d7d6fffb95c0a5349960a10569e8218b5 (patch) | |
tree | 7b62b6ea2efbb73a4f087c0d88c4a3cabcf97278 /drivers/dma-buf | |
parent | 0cac6ac19807722f066c1927015b4fba7303643d (diff) |
dma-buf/sw_sync: move timeline_fence_ops around
We are going to use timeline_fence_signaled() in a internal function in
the next commit.
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20170729152217.8362-1-gustavo@padovan.org
Diffstat (limited to 'drivers/dma-buf')
-rw-r--r-- | drivers/dma-buf/sw_sync.c | 138 |
1 files changed, 69 insertions, 69 deletions
diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c index af1bc84802e5..ef0cc08f5dfb 100644 --- a/drivers/dma-buf/sw_sync.c +++ b/drivers/dma-buf/sw_sync.c | |||
@@ -125,6 +125,75 @@ static void sync_timeline_put(struct sync_timeline *obj) | |||
125 | kref_put(&obj->kref, sync_timeline_free); | 125 | kref_put(&obj->kref, sync_timeline_free); |
126 | } | 126 | } |
127 | 127 | ||
128 | static const char *timeline_fence_get_driver_name(struct dma_fence *fence) | ||
129 | { | ||
130 | return "sw_sync"; | ||
131 | } | ||
132 | |||
133 | static const char *timeline_fence_get_timeline_name(struct dma_fence *fence) | ||
134 | { | ||
135 | struct sync_timeline *parent = dma_fence_parent(fence); | ||
136 | |||
137 | return parent->name; | ||
138 | } | ||
139 | |||
140 | static void timeline_fence_release(struct dma_fence *fence) | ||
141 | { | ||
142 | struct sync_pt *pt = dma_fence_to_sync_pt(fence); | ||
143 | struct sync_timeline *parent = dma_fence_parent(fence); | ||
144 | |||
145 | if (!list_empty(&pt->link)) { | ||
146 | unsigned long flags; | ||
147 | |||
148 | spin_lock_irqsave(fence->lock, flags); | ||
149 | if (!list_empty(&pt->link)) { | ||
150 | list_del(&pt->link); | ||
151 | rb_erase(&pt->node, &parent->pt_tree); | ||
152 | } | ||
153 | spin_unlock_irqrestore(fence->lock, flags); | ||
154 | } | ||
155 | |||
156 | sync_timeline_put(parent); | ||
157 | dma_fence_free(fence); | ||
158 | } | ||
159 | |||
160 | static bool timeline_fence_signaled(struct dma_fence *fence) | ||
161 | { | ||
162 | struct sync_timeline *parent = dma_fence_parent(fence); | ||
163 | |||
164 | return !__dma_fence_is_later(fence->seqno, parent->value); | ||
165 | } | ||
166 | |||
167 | static bool timeline_fence_enable_signaling(struct dma_fence *fence) | ||
168 | { | ||
169 | return true; | ||
170 | } | ||
171 | |||
172 | static void timeline_fence_value_str(struct dma_fence *fence, | ||
173 | char *str, int size) | ||
174 | { | ||
175 | snprintf(str, size, "%d", fence->seqno); | ||
176 | } | ||
177 | |||
178 | static void timeline_fence_timeline_value_str(struct dma_fence *fence, | ||
179 | char *str, int size) | ||
180 | { | ||
181 | struct sync_timeline *parent = dma_fence_parent(fence); | ||
182 | |||
183 | snprintf(str, size, "%d", parent->value); | ||
184 | } | ||
185 | |||
186 | static const struct dma_fence_ops timeline_fence_ops = { | ||
187 | .get_driver_name = timeline_fence_get_driver_name, | ||
188 | .get_timeline_name = timeline_fence_get_timeline_name, | ||
189 | .enable_signaling = timeline_fence_enable_signaling, | ||
190 | .signaled = timeline_fence_signaled, | ||
191 | .wait = dma_fence_default_wait, | ||
192 | .release = timeline_fence_release, | ||
193 | .fence_value_str = timeline_fence_value_str, | ||
194 | .timeline_value_str = timeline_fence_timeline_value_str, | ||
195 | }; | ||
196 | |||
128 | /** | 197 | /** |
129 | * sync_timeline_signal() - signal a status change on a sync_timeline | 198 | * sync_timeline_signal() - signal a status change on a sync_timeline |
130 | * @obj: sync_timeline to signal | 199 | * @obj: sync_timeline to signal |
@@ -216,75 +285,6 @@ unlock: | |||
216 | return pt; | 285 | return pt; |
217 | } | 286 | } |
218 | 287 | ||
219 | static const char *timeline_fence_get_driver_name(struct dma_fence *fence) | ||
220 | { | ||
221 | return "sw_sync"; | ||
222 | } | ||
223 | |||
224 | static const char *timeline_fence_get_timeline_name(struct dma_fence *fence) | ||
225 | { | ||
226 | struct sync_timeline *parent = dma_fence_parent(fence); | ||
227 | |||
228 | return parent->name; | ||
229 | } | ||
230 | |||
231 | static void timeline_fence_release(struct dma_fence *fence) | ||
232 | { | ||
233 | struct sync_pt *pt = dma_fence_to_sync_pt(fence); | ||
234 | struct sync_timeline *parent = dma_fence_parent(fence); | ||
235 | |||
236 | if (!list_empty(&pt->link)) { | ||
237 | unsigned long flags; | ||
238 | |||
239 | spin_lock_irqsave(fence->lock, flags); | ||
240 | if (!list_empty(&pt->link)) { | ||
241 | list_del(&pt->link); | ||
242 | rb_erase(&pt->node, &parent->pt_tree); | ||
243 | } | ||
244 | spin_unlock_irqrestore(fence->lock, flags); | ||
245 | } | ||
246 | |||
247 | sync_timeline_put(parent); | ||
248 | dma_fence_free(fence); | ||
249 | } | ||
250 | |||
251 | static bool timeline_fence_signaled(struct dma_fence *fence) | ||
252 | { | ||
253 | struct sync_timeline *parent = dma_fence_parent(fence); | ||
254 | |||
255 | return !__dma_fence_is_later(fence->seqno, parent->value); | ||
256 | } | ||
257 | |||
258 | static bool timeline_fence_enable_signaling(struct dma_fence *fence) | ||
259 | { | ||
260 | return true; | ||
261 | } | ||
262 | |||
263 | static void timeline_fence_value_str(struct dma_fence *fence, | ||
264 | char *str, int size) | ||
265 | { | ||
266 | snprintf(str, size, "%d", fence->seqno); | ||
267 | } | ||
268 | |||
269 | static void timeline_fence_timeline_value_str(struct dma_fence *fence, | ||
270 | char *str, int size) | ||
271 | { | ||
272 | struct sync_timeline *parent = dma_fence_parent(fence); | ||
273 | |||
274 | snprintf(str, size, "%d", parent->value); | ||
275 | } | ||
276 | |||
277 | static const struct dma_fence_ops timeline_fence_ops = { | ||
278 | .get_driver_name = timeline_fence_get_driver_name, | ||
279 | .get_timeline_name = timeline_fence_get_timeline_name, | ||
280 | .enable_signaling = timeline_fence_enable_signaling, | ||
281 | .signaled = timeline_fence_signaled, | ||
282 | .wait = dma_fence_default_wait, | ||
283 | .release = timeline_fence_release, | ||
284 | .fence_value_str = timeline_fence_value_str, | ||
285 | .timeline_value_str = timeline_fence_timeline_value_str, | ||
286 | }; | ||
287 | |||
288 | /* | 288 | /* |
289 | * *WARNING* | 289 | * *WARNING* |
290 | * | 290 | * |