Commit | Line | Data |
---|---|---|
1802d0be | 1 | // SPDX-License-Identifier: GPL-2.0-only |
606b23ad ML |
2 | /* |
3 | * seqno-fence, using a dma-buf to synchronize fencing | |
4 | * | |
5 | * Copyright (C) 2012 Texas Instruments | |
6 | * Copyright (C) 2012-2014 Canonical Ltd | |
7 | * Authors: | |
8 | * Rob Clark <robdclark@gmail.com> | |
9 | * Maarten Lankhorst <maarten.lankhorst@canonical.com> | |
606b23ad ML |
10 | */ |
11 | ||
12 | #include <linux/slab.h> | |
13 | #include <linux/export.h> | |
14 | #include <linux/seqno-fence.h> | |
15 | ||
f54d1867 | 16 | static const char *seqno_fence_get_driver_name(struct dma_fence *fence) |
606b23ad ML |
17 | { |
18 | struct seqno_fence *seqno_fence = to_seqno_fence(fence); | |
5136629d | 19 | |
606b23ad ML |
20 | return seqno_fence->ops->get_driver_name(fence); |
21 | } | |
22 | ||
f54d1867 | 23 | static const char *seqno_fence_get_timeline_name(struct dma_fence *fence) |
606b23ad ML |
24 | { |
25 | struct seqno_fence *seqno_fence = to_seqno_fence(fence); | |
5136629d | 26 | |
606b23ad ML |
27 | return seqno_fence->ops->get_timeline_name(fence); |
28 | } | |
29 | ||
f54d1867 | 30 | static bool seqno_enable_signaling(struct dma_fence *fence) |
606b23ad ML |
31 | { |
32 | struct seqno_fence *seqno_fence = to_seqno_fence(fence); | |
5136629d | 33 | |
606b23ad ML |
34 | return seqno_fence->ops->enable_signaling(fence); |
35 | } | |
36 | ||
f54d1867 | 37 | static bool seqno_signaled(struct dma_fence *fence) |
606b23ad ML |
38 | { |
39 | struct seqno_fence *seqno_fence = to_seqno_fence(fence); | |
5136629d | 40 | |
606b23ad ML |
41 | return seqno_fence->ops->signaled && seqno_fence->ops->signaled(fence); |
42 | } | |
43 | ||
f54d1867 | 44 | static void seqno_release(struct dma_fence *fence) |
606b23ad ML |
45 | { |
46 | struct seqno_fence *f = to_seqno_fence(fence); | |
47 | ||
48 | dma_buf_put(f->sync_buf); | |
49 | if (f->ops->release) | |
50 | f->ops->release(fence); | |
51 | else | |
f54d1867 | 52 | dma_fence_free(&f->base); |
606b23ad ML |
53 | } |
54 | ||
f54d1867 CW |
55 | static signed long seqno_wait(struct dma_fence *fence, bool intr, |
56 | signed long timeout) | |
606b23ad ML |
57 | { |
58 | struct seqno_fence *f = to_seqno_fence(fence); | |
5136629d | 59 | |
606b23ad ML |
60 | return f->ops->wait(fence, intr, timeout); |
61 | } | |
62 | ||
f54d1867 | 63 | const struct dma_fence_ops seqno_fence_ops = { |
606b23ad ML |
64 | .get_driver_name = seqno_fence_get_driver_name, |
65 | .get_timeline_name = seqno_fence_get_timeline_name, | |
66 | .enable_signaling = seqno_enable_signaling, | |
67 | .signaled = seqno_signaled, | |
68 | .wait = seqno_wait, | |
69 | .release = seqno_release, | |
70 | }; | |
71 | EXPORT_SYMBOL(seqno_fence_ops); |