aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/drm_syncobj.h
diff options
context:
space:
mode:
authorJason Ekstrand <jason@jlekstrand.net>2017-08-28 10:39:25 -0400
committerDave Airlie <airlied@redhat.com>2017-08-28 16:26:42 -0400
commit9c19fb10a5893d6501df4d0fb93d954d5fc1d91b (patch)
tree16d582e263ef5ac45a1b8987e63e4c0a47799021 /include/drm/drm_syncobj.h
parent5e60a10eaebab93f823295cd7ec3848ba3b6e553 (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.h39
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
31struct 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
70typedef 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 */
84struct drm_syncobj_cb {
85 struct list_head node;
86 drm_syncobj_func_t func;
87};
88
55void drm_syncobj_free(struct kref *kref); 89void drm_syncobj_free(struct kref *kref);
56 90
57/** 91/**
@@ -91,6 +125,11 @@ drm_syncobj_fence_get(struct drm_syncobj *syncobj)
91 125
92struct drm_syncobj *drm_syncobj_find(struct drm_file *file_private, 126struct drm_syncobj *drm_syncobj_find(struct drm_file *file_private,
93 u32 handle); 127 u32 handle);
128void drm_syncobj_add_callback(struct drm_syncobj *syncobj,
129 struct drm_syncobj_cb *cb,
130 drm_syncobj_func_t func);
131void drm_syncobj_remove_callback(struct drm_syncobj *syncobj,
132 struct drm_syncobj_cb *cb);
94void drm_syncobj_replace_fence(struct drm_syncobj *syncobj, 133void drm_syncobj_replace_fence(struct drm_syncobj *syncobj,
95 struct dma_fence *fence); 134 struct dma_fence *fence);
96int drm_syncobj_find_fence(struct drm_file *file_private, 135int drm_syncobj_find_fence(struct drm_file *file_private,