hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/dma-buf/sw_sync.c
....@@ -1,17 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Sync File validation framework
34 *
45 * Copyright (C) 2012 Google, Inc.
5
- *
6
- * This software is licensed under the terms of the GNU General Public
7
- * License version 2, as published by the Free Software Foundation, and
8
- * may be copied, distributed, and modified under those terms.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
156 */
167
178 #include <linux/file.h>
....@@ -160,7 +151,7 @@
160151 {
161152 struct sync_timeline *parent = dma_fence_parent(fence);
162153
163
- return !__dma_fence_is_later(fence->seqno, parent->value);
154
+ return !__dma_fence_is_later(fence->seqno, parent->value, fence->ops);
164155 }
165156
166157 static bool timeline_fence_enable_signaling(struct dma_fence *fence)
....@@ -171,7 +162,7 @@
171162 static void timeline_fence_value_str(struct dma_fence *fence,
172163 char *str, int size)
173164 {
174
- snprintf(str, size, "%d", fence->seqno);
165
+ snprintf(str, size, "%lld", fence->seqno);
175166 }
176167
177168 static void timeline_fence_timeline_value_str(struct dma_fence *fence,
....@@ -200,12 +191,10 @@
200191 * A sync implementation should call this any time one of it's fences
201192 * has signaled or has an error condition.
202193 */
203
-void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc)
194
+static void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc)
204195 {
196
+ LIST_HEAD(signalled);
205197 struct sync_pt *pt, *next;
206
-
207
- if (WARN_ON(!obj))
208
- return;
209198
210199 trace_sync_timeline(obj);
211200
....@@ -217,23 +206,21 @@
217206 if (!timeline_fence_signaled(&pt->base))
218207 break;
219208
220
- list_del_init(&pt->link);
209
+ dma_fence_get(&pt->base);
210
+
211
+ list_move_tail(&pt->link, &signalled);
221212 rb_erase(&pt->node, &obj->pt_tree);
222213
223
- /*
224
- * A signal callback may release the last reference to this
225
- * fence, causing it to be freed. That operation has to be
226
- * last to avoid a use after free inside this loop, and must
227
- * be after we remove the fence from the timeline in order to
228
- * prevent deadlocking on timeline->lock inside
229
- * timeline_fence_release().
230
- */
231214 dma_fence_signal_locked(&pt->base);
232215 }
233216
234217 spin_unlock_irq(&obj->lock);
218
+
219
+ list_for_each_entry_safe(pt, next, &signalled, link) {
220
+ list_del_init(&pt->link);
221
+ dma_fence_put(&pt->base);
222
+ }
235223 }
236
-EXPORT_SYMBOL(sync_timeline_signal);
237224
238225 /**
239226 * sync_pt_create() - creates a sync pt
....@@ -423,7 +410,7 @@
423410 .open = sw_sync_debugfs_open,
424411 .release = sw_sync_debugfs_release,
425412 .unlocked_ioctl = sw_sync_ioctl,
426
- .compat_ioctl = sw_sync_ioctl,
413
+ .compat_ioctl = compat_ptr_ioctl,
427414 };
428415
429416 static struct miscdevice sw_sync_dev = {