diff options
author | Jason Ekstrand <jason@jlekstrand.net> | 2017-08-28 10:39:25 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2017-08-28 16:26:42 -0400 |
commit | 9c19fb10a5893d6501df4d0fb93d954d5fc1d91b (patch) | |
tree | 16d582e263ef5ac45a1b8987e63e4c0a47799021 /include/drm/drm_syncobj.h | |
parent | 5e60a10eaebab93f823295cd7ec3848ba3b6e553 (diff) |
drm/syncobj: Add a callback mechanism for replace_fence (v3)
It is useful in certain circumstances to know when the fence is replaced
in a syncobj. Specifically, it may be useful to know when the fence
goes from NULL to something valid. This does make syncobj_replace_fence
a little more expensive because it has to take a lock but, in the common
case where there is no callback list, it spends a very short amount of
time inside the lock.
v2:
- Don't lock in drm_syncobj_fence_get. We only really need to lock
around fence_replace to make the callback work.
v3:
- Fix the cb_list comment to make kbuild happy
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include/drm/drm_syncobj.h')
-rw-r--r-- | include/drm/drm_syncobj.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/include/drm/drm_syncobj.h b/include/drm/drm_syncobj.h index ce94d14c5087..c00fee539822 100644 --- a/include/drm/drm_syncobj.h +++ b/include/drm/drm_syncobj.h | |||
@@ -28,6 +28,8 @@ | |||
28 | 28 | ||
29 | #include "linux/dma-fence.h" | 29 | #include "linux/dma-fence.h" |
30 | 30 | ||
31 | struct drm_syncobj_cb; | ||
32 | |||
31 | /** | 33 | /** |
32 | * struct drm_syncobj - sync object. | 34 | * struct drm_syncobj - sync object. |
33 | * | 35 | * |
@@ -43,15 +45,47 @@ struct drm_syncobj { | |||
43 | /** | 45 | /** |
44 | * @fence: | 46 | * @fence: |
45 | * NULL or a pointer to the fence bound to this object. | 47 | * NULL or a pointer to the fence bound to this object. |
48 | * | ||
49 | * This field should not be used directly. Use drm_syncobj_fence_get | ||
50 | * and drm_syncobj_replace_fence instead. | ||
46 | */ | 51 | */ |
47 | struct dma_fence *fence; | 52 | struct dma_fence *fence; |
48 | /** | 53 | /** |
54 | * @cb_list: | ||
55 | * List of callbacks to call when the fence gets replaced | ||
56 | */ | ||
57 | struct list_head cb_list; | ||
58 | /** | ||
59 | * @lock: | ||
60 | * locks cb_list and write-locks fence. | ||
61 | */ | ||
62 | spinlock_t lock; | ||
63 | /** | ||
49 | * @file: | 64 | * @file: |
50 | * a file backing for this syncobj. | 65 | * a file backing for this syncobj. |
51 | */ | 66 | */ |
52 | struct file *file; | 67 | struct file *file; |
53 | }; | 68 | }; |
54 | 69 | ||
70 | typedef void (*drm_syncobj_func_t)(struct drm_syncobj *syncobj, | ||
71 | struct drm_syncobj_cb *cb); | ||
72 | |||
73 | /** | ||
74 | * struct drm_syncobj_cb - callback for drm_syncobj_add_callback | ||
75 | * @node: used by drm_syncob_add_callback to append this struct to | ||
76 | * syncobj::cb_list | ||
77 | * @func: drm_syncobj_func_t to call | ||
78 | * | ||
79 | * This struct will be initialized by drm_syncobj_add_callback, additional | ||
80 | * data can be passed along by embedding drm_syncobj_cb in another struct. | ||
81 | * The callback will get called the next time drm_syncobj_replace_fence is | ||
82 | * called. | ||
83 | */ | ||
84 | struct drm_syncobj_cb { | ||
85 | struct list_head node; | ||
86 | drm_syncobj_func_t func; | ||
87 | }; | ||
88 | |||
55 | void drm_syncobj_free(struct kref *kref); | 89 | void drm_syncobj_free(struct kref *kref); |
56 | 90 | ||
57 | /** | 91 | /** |
@@ -91,6 +125,11 @@ drm_syncobj_fence_get(struct drm_syncobj *syncobj) | |||
91 | 125 | ||
92 | struct drm_syncobj *drm_syncobj_find(struct drm_file *file_private, | 126 | struct drm_syncobj *drm_syncobj_find(struct drm_file *file_private, |
93 | u32 handle); | 127 | u32 handle); |
128 | void drm_syncobj_add_callback(struct drm_syncobj *syncobj, | ||
129 | struct drm_syncobj_cb *cb, | ||
130 | drm_syncobj_func_t func); | ||
131 | void drm_syncobj_remove_callback(struct drm_syncobj *syncobj, | ||
132 | struct drm_syncobj_cb *cb); | ||
94 | void drm_syncobj_replace_fence(struct drm_syncobj *syncobj, | 133 | void drm_syncobj_replace_fence(struct drm_syncobj *syncobj, |
95 | struct dma_fence *fence); | 134 | struct dma_fence *fence); |
96 | int drm_syncobj_find_fence(struct drm_file *file_private, | 135 | int drm_syncobj_find_fence(struct drm_file *file_private, |