| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Sync File validation framework |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * 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 | | - * |
|---|
| 15 | 6 | */ |
|---|
| 16 | 7 | |
|---|
| 17 | 8 | #include <linux/file.h> |
|---|
| .. | .. |
|---|
| 160 | 151 | { |
|---|
| 161 | 152 | struct sync_timeline *parent = dma_fence_parent(fence); |
|---|
| 162 | 153 | |
|---|
| 163 | | - return !__dma_fence_is_later(fence->seqno, parent->value); |
|---|
| 154 | + return !__dma_fence_is_later(fence->seqno, parent->value, fence->ops); |
|---|
| 164 | 155 | } |
|---|
| 165 | 156 | |
|---|
| 166 | 157 | static bool timeline_fence_enable_signaling(struct dma_fence *fence) |
|---|
| .. | .. |
|---|
| 171 | 162 | static void timeline_fence_value_str(struct dma_fence *fence, |
|---|
| 172 | 163 | char *str, int size) |
|---|
| 173 | 164 | { |
|---|
| 174 | | - snprintf(str, size, "%d", fence->seqno); |
|---|
| 165 | + snprintf(str, size, "%lld", fence->seqno); |
|---|
| 175 | 166 | } |
|---|
| 176 | 167 | |
|---|
| 177 | 168 | static void timeline_fence_timeline_value_str(struct dma_fence *fence, |
|---|
| .. | .. |
|---|
| 200 | 191 | * A sync implementation should call this any time one of it's fences |
|---|
| 201 | 192 | * has signaled or has an error condition. |
|---|
| 202 | 193 | */ |
|---|
| 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) |
|---|
| 204 | 195 | { |
|---|
| 196 | + LIST_HEAD(signalled); |
|---|
| 205 | 197 | struct sync_pt *pt, *next; |
|---|
| 206 | | - |
|---|
| 207 | | - if (WARN_ON(!obj)) |
|---|
| 208 | | - return; |
|---|
| 209 | 198 | |
|---|
| 210 | 199 | trace_sync_timeline(obj); |
|---|
| 211 | 200 | |
|---|
| .. | .. |
|---|
| 217 | 206 | if (!timeline_fence_signaled(&pt->base)) |
|---|
| 218 | 207 | break; |
|---|
| 219 | 208 | |
|---|
| 220 | | - list_del_init(&pt->link); |
|---|
| 209 | + dma_fence_get(&pt->base); |
|---|
| 210 | + |
|---|
| 211 | + list_move_tail(&pt->link, &signalled); |
|---|
| 221 | 212 | rb_erase(&pt->node, &obj->pt_tree); |
|---|
| 222 | 213 | |
|---|
| 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 | | - */ |
|---|
| 231 | 214 | dma_fence_signal_locked(&pt->base); |
|---|
| 232 | 215 | } |
|---|
| 233 | 216 | |
|---|
| 234 | 217 | 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 | + } |
|---|
| 235 | 223 | } |
|---|
| 236 | | -EXPORT_SYMBOL(sync_timeline_signal); |
|---|
| 237 | 224 | |
|---|
| 238 | 225 | /** |
|---|
| 239 | 226 | * sync_pt_create() - creates a sync pt |
|---|
| .. | .. |
|---|
| 423 | 410 | .open = sw_sync_debugfs_open, |
|---|
| 424 | 411 | .release = sw_sync_debugfs_release, |
|---|
| 425 | 412 | .unlocked_ioctl = sw_sync_ioctl, |
|---|
| 426 | | - .compat_ioctl = sw_sync_ioctl, |
|---|
| 413 | + .compat_ioctl = compat_ptr_ioctl, |
|---|
| 427 | 414 | }; |
|---|
| 428 | 415 | |
|---|
| 429 | 416 | static struct miscdevice sw_sync_dev = { |
|---|