Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 1 | /* |
| 2 | * include/linux/sync.h |
| 3 | * |
| 4 | * Copyright (C) 2012 Google, Inc. |
| 5 | * |
| 6 | * This program is distributed in the hope that it will be useful, |
| 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 9 | * GNU General Public License for more details. |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | #ifndef _LINUX_SYNC_H |
| 14 | #define _LINUX_SYNC_H |
| 15 | |
| 16 | #include <linux/types.h> |
Erik Gilling | 0154417 | 2013-02-28 16:43:10 -0800 | [diff] [blame] | 17 | #include <linux/kref.h> |
Erik Gilling | 97a8484 | 2013-02-28 16:42:59 -0800 | [diff] [blame] | 18 | #include <linux/ktime.h> |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 19 | #include <linux/list.h> |
| 20 | #include <linux/spinlock.h> |
| 21 | #include <linux/wait.h> |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 22 | #include <linux/fence.h> |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 23 | |
Colin Cross | 64907b9 | 2014-02-17 13:58:32 -0800 | [diff] [blame] | 24 | #include "uapi/sync.h" |
| 25 | |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 26 | struct sync_timeline; |
| 27 | struct sync_pt; |
| 28 | struct sync_fence; |
| 29 | |
| 30 | /** |
| 31 | * struct sync_timeline_ops - sync object implementation ops |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 32 | * @driver_name: name of the implementation |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 33 | * @dup: duplicate a sync_pt |
| 34 | * @has_signaled: returns: |
| 35 | * 1 if pt has signaled |
| 36 | * 0 if pt has not signaled |
| 37 | * <0 on error |
| 38 | * @compare: returns: |
| 39 | * 1 if b will signal before a |
| 40 | * 0 if a and b will signal at the same time |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 41 | * -1 if a will signal before b |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 42 | * @free_pt: called before sync_pt is freed |
| 43 | * @release_obj: called before sync_timeline is freed |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 44 | * @fill_driver_data: write implementation specific driver data to data. |
Erik Gilling | 79ba152 | 2013-02-28 16:43:02 -0800 | [diff] [blame] | 45 | * should return an error if there is not enough room |
| 46 | * as specified by size. This information is returned |
| 47 | * to userspace by SYNC_IOC_FENCE_INFO. |
Erik Gilling | dbd5239 | 2013-02-28 16:43:21 -0800 | [diff] [blame] | 48 | * @timeline_value_str: fill str with the value of the sync_timeline's counter |
| 49 | * @pt_value_str: fill str with the value of the sync_pt |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 50 | */ |
| 51 | struct sync_timeline_ops { |
| 52 | const char *driver_name; |
| 53 | |
| 54 | /* required */ |
Daeseok Youn | 393f539 | 2014-02-10 14:36:48 +0900 | [diff] [blame] | 55 | struct sync_pt * (*dup)(struct sync_pt *pt); |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 56 | |
| 57 | /* required */ |
| 58 | int (*has_signaled)(struct sync_pt *pt); |
| 59 | |
| 60 | /* required */ |
| 61 | int (*compare)(struct sync_pt *a, struct sync_pt *b); |
| 62 | |
| 63 | /* optional */ |
| 64 | void (*free_pt)(struct sync_pt *sync_pt); |
| 65 | |
| 66 | /* optional */ |
| 67 | void (*release_obj)(struct sync_timeline *sync_timeline); |
Erik Gilling | af7582f | 2013-02-28 16:43:00 -0800 | [diff] [blame] | 68 | |
Erik Gilling | 79ba152 | 2013-02-28 16:43:02 -0800 | [diff] [blame] | 69 | /* optional */ |
| 70 | int (*fill_driver_data)(struct sync_pt *syncpt, void *data, int size); |
Erik Gilling | dbd5239 | 2013-02-28 16:43:21 -0800 | [diff] [blame] | 71 | |
| 72 | /* optional */ |
| 73 | void (*timeline_value_str)(struct sync_timeline *timeline, char *str, |
| 74 | int size); |
| 75 | |
| 76 | /* optional */ |
| 77 | void (*pt_value_str)(struct sync_pt *pt, char *str, int size); |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | /** |
| 81 | * struct sync_timeline - sync object |
Erik Gilling | c5b86b7 | 2013-02-28 16:43:11 -0800 | [diff] [blame] | 82 | * @kref: reference count on fence. |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 83 | * @ops: ops that define the implementation of the sync_timeline |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 84 | * @name: name of the sync_timeline. Useful for debugging |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 85 | * @destroyed: set when sync_timeline is destroyed |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 86 | * @child_list_head: list of children sync_pts for this sync_timeline |
| 87 | * @child_list_lock: lock protecting @child_list_head, destroyed, and |
| 88 | * sync_pt.status |
| 89 | * @active_list_head: list of active (unsignaled/errored) sync_pts |
Erik Gilling | af7582f | 2013-02-28 16:43:00 -0800 | [diff] [blame] | 90 | * @sync_timeline_list: membership in global sync_timeline_list |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 91 | */ |
| 92 | struct sync_timeline { |
Erik Gilling | c5b86b7 | 2013-02-28 16:43:11 -0800 | [diff] [blame] | 93 | struct kref kref; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 94 | const struct sync_timeline_ops *ops; |
| 95 | char name[32]; |
| 96 | |
| 97 | /* protected by child_list_lock */ |
| 98 | bool destroyed; |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 99 | int context, value; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 100 | |
| 101 | struct list_head child_list_head; |
| 102 | spinlock_t child_list_lock; |
| 103 | |
| 104 | struct list_head active_list_head; |
Erik Gilling | af7582f | 2013-02-28 16:43:00 -0800 | [diff] [blame] | 105 | |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 106 | #ifdef CONFIG_DEBUG_FS |
Erik Gilling | af7582f | 2013-02-28 16:43:00 -0800 | [diff] [blame] | 107 | struct list_head sync_timeline_list; |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 108 | #endif |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | /** |
| 112 | * struct sync_pt - sync point |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 113 | * @fence: base fence class |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 114 | * @child_list: membership in sync_timeline.child_list_head |
| 115 | * @active_list: membership in sync_timeline.active_list_head |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 116 | * @signaled_list: membership in temporary signaled_list on stack |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 117 | * @fence: sync_fence to which the sync_pt belongs |
| 118 | * @pt_list: membership in sync_fence.pt_list_head |
| 119 | * @status: 1: signaled, 0:active, <0: error |
Erik Gilling | 97a8484 | 2013-02-28 16:42:59 -0800 | [diff] [blame] | 120 | * @timestamp: time which sync_pt status transitioned from active to |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 121 | * signaled or error. |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 122 | */ |
| 123 | struct sync_pt { |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 124 | struct fence base; |
| 125 | |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 126 | struct list_head child_list; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 127 | struct list_head active_list; |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 128 | }; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 129 | |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 130 | static inline struct sync_timeline *sync_pt_parent(struct sync_pt *pt) |
| 131 | { |
| 132 | return container_of(pt->base.lock, struct sync_timeline, |
| 133 | child_list_lock); |
| 134 | } |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 135 | |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 136 | struct sync_fence_cb { |
| 137 | struct fence_cb cb; |
| 138 | struct fence *sync_pt; |
| 139 | struct sync_fence *fence; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 140 | }; |
| 141 | |
| 142 | /** |
| 143 | * struct sync_fence - sync fence |
| 144 | * @file: file representing this fence |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 145 | * @kref: reference count on fence. |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 146 | * @name: name of sync_fence. Useful for debugging |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 147 | * @pt_list_head: list of sync_pts in the fence. immutable once fence |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 148 | * is created |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 149 | * @status: 0: signaled, >0:active, <0: error |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 150 | * |
| 151 | * @wq: wait queue for fence signaling |
Erik Gilling | af7582f | 2013-02-28 16:43:00 -0800 | [diff] [blame] | 152 | * @sync_fence_list: membership in global fence list |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 153 | */ |
| 154 | struct sync_fence { |
| 155 | struct file *file; |
Erik Gilling | 0154417 | 2013-02-28 16:43:10 -0800 | [diff] [blame] | 156 | struct kref kref; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 157 | char name[32]; |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 158 | #ifdef CONFIG_DEBUG_FS |
| 159 | struct list_head sync_fence_list; |
| 160 | #endif |
| 161 | int num_fences; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 162 | |
| 163 | wait_queue_head_t wq; |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 164 | atomic_t status; |
Erik Gilling | af7582f | 2013-02-28 16:43:00 -0800 | [diff] [blame] | 165 | |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 166 | struct sync_fence_cb cbs[]; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 167 | }; |
| 168 | |
Erik Gilling | c0f61a4 | 2013-02-28 16:43:05 -0800 | [diff] [blame] | 169 | struct sync_fence_waiter; |
| 170 | typedef void (*sync_callback_t)(struct sync_fence *fence, |
| 171 | struct sync_fence_waiter *waiter); |
| 172 | |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 173 | /** |
| 174 | * struct sync_fence_waiter - metadata for asynchronous waiter on a fence |
| 175 | * @waiter_list: membership in sync_fence.waiter_list_head |
| 176 | * @callback: function pointer to call when fence signals |
| 177 | * @callback_data: pointer to pass to @callback |
| 178 | */ |
| 179 | struct sync_fence_waiter { |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 180 | wait_queue_t work; |
| 181 | sync_callback_t callback; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 182 | }; |
| 183 | |
Erik Gilling | c0f61a4 | 2013-02-28 16:43:05 -0800 | [diff] [blame] | 184 | static inline void sync_fence_waiter_init(struct sync_fence_waiter *waiter, |
| 185 | sync_callback_t callback) |
| 186 | { |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 187 | INIT_LIST_HEAD(&waiter->work.task_list); |
Erik Gilling | c0f61a4 | 2013-02-28 16:43:05 -0800 | [diff] [blame] | 188 | waiter->callback = callback; |
| 189 | } |
| 190 | |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 191 | /* |
| 192 | * API for sync_timeline implementers |
| 193 | */ |
| 194 | |
| 195 | /** |
| 196 | * sync_timeline_create() - creates a sync object |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 197 | * @ops: specifies the implementation ops for the object |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 198 | * @size: size to allocate for this obj |
| 199 | * @name: sync_timeline name |
| 200 | * |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 201 | * Creates a new sync_timeline which will use the implementation specified by |
| 202 | * @ops. @size bytes will be allocated allowing for implementation specific |
| 203 | * data to be kept after the generic sync_timeline struct. |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 204 | */ |
| 205 | struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops, |
| 206 | int size, const char *name); |
| 207 | |
| 208 | /** |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 209 | * sync_timeline_destroy() - destroys a sync object |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 210 | * @obj: sync_timeline to destroy |
| 211 | * |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 212 | * A sync implementation should call this when the @obj is going away |
| 213 | * (i.e. module unload.) @obj won't actually be freed until all its children |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 214 | * sync_pts are freed. |
| 215 | */ |
| 216 | void sync_timeline_destroy(struct sync_timeline *obj); |
| 217 | |
| 218 | /** |
| 219 | * sync_timeline_signal() - signal a status change on a sync_timeline |
| 220 | * @obj: sync_timeline to signal |
| 221 | * |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 222 | * A sync implementation should call this any time one of it's sync_pts |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 223 | * has signaled or has an error condition. |
| 224 | */ |
| 225 | void sync_timeline_signal(struct sync_timeline *obj); |
| 226 | |
| 227 | /** |
| 228 | * sync_pt_create() - creates a sync pt |
| 229 | * @parent: sync_pt's parent sync_timeline |
| 230 | * @size: size to allocate for this pt |
| 231 | * |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 232 | * Creates a new sync_pt as a child of @parent. @size bytes will be |
| 233 | * allocated allowing for implementation specific data to be kept after |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 234 | * the generic sync_timeline struct. |
| 235 | */ |
| 236 | struct sync_pt *sync_pt_create(struct sync_timeline *parent, int size); |
| 237 | |
| 238 | /** |
| 239 | * sync_pt_free() - frees a sync pt |
| 240 | * @pt: sync_pt to free |
| 241 | * |
| 242 | * This should only be called on sync_pts which have been created but |
| 243 | * not added to a fence. |
| 244 | */ |
| 245 | void sync_pt_free(struct sync_pt *pt); |
| 246 | |
| 247 | /** |
| 248 | * sync_fence_create() - creates a sync fence |
| 249 | * @name: name of fence to create |
| 250 | * @pt: sync_pt to add to the fence |
| 251 | * |
| 252 | * Creates a fence containg @pt. Once this is called, the fence takes |
| 253 | * ownership of @pt. |
| 254 | */ |
| 255 | struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt); |
| 256 | |
Maarten Lankhorst | 0f477c6 | 2015-12-11 13:11:50 +0000 | [diff] [blame] | 257 | /** |
| 258 | * sync_fence_create_dma() - creates a sync fence from dma-fence |
| 259 | * @name: name of fence to create |
| 260 | * @pt: dma-fence to add to the fence |
| 261 | * |
| 262 | * Creates a fence containg @pt. Once this is called, the fence takes |
| 263 | * ownership of @pt. |
| 264 | */ |
| 265 | struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt); |
| 266 | |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 267 | /* |
| 268 | * API for sync_fence consumers |
| 269 | */ |
| 270 | |
| 271 | /** |
| 272 | * sync_fence_merge() - merge two fences |
| 273 | * @name: name of new fence |
| 274 | * @a: fence a |
| 275 | * @b: fence b |
| 276 | * |
| 277 | * Creates a new fence which contains copies of all the sync_pts in both |
| 278 | * @a and @b. @a and @b remain valid, independent fences. |
| 279 | */ |
| 280 | struct sync_fence *sync_fence_merge(const char *name, |
| 281 | struct sync_fence *a, struct sync_fence *b); |
| 282 | |
| 283 | /** |
| 284 | * sync_fence_fdget() - get a fence from an fd |
| 285 | * @fd: fd referencing a fence |
| 286 | * |
| 287 | * Ensures @fd references a valid fence, increments the refcount of the backing |
| 288 | * file, and returns the fence. |
| 289 | */ |
| 290 | struct sync_fence *sync_fence_fdget(int fd); |
| 291 | |
| 292 | /** |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 293 | * sync_fence_put() - puts a reference of a sync fence |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 294 | * @fence: fence to put |
| 295 | * |
| 296 | * Puts a reference on @fence. If this is the last reference, the fence and |
| 297 | * all it's sync_pts will be freed |
| 298 | */ |
| 299 | void sync_fence_put(struct sync_fence *fence); |
| 300 | |
| 301 | /** |
| 302 | * sync_fence_install() - installs a fence into a file descriptor |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 303 | * @fence: fence to install |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 304 | * @fd: file descriptor in which to install the fence |
| 305 | * |
Heinrich Schuchardt | ae66475 | 2014-09-27 10:52:37 +0200 | [diff] [blame] | 306 | * Installs @fence into @fd. @fd's should be acquired through |
| 307 | * get_unused_fd_flags(O_CLOEXEC). |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 308 | */ |
| 309 | void sync_fence_install(struct sync_fence *fence, int fd); |
| 310 | |
| 311 | /** |
| 312 | * sync_fence_wait_async() - registers and async wait on the fence |
| 313 | * @fence: fence to wait on |
Erik Gilling | c0f61a4 | 2013-02-28 16:43:05 -0800 | [diff] [blame] | 314 | * @waiter: waiter callback struck |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 315 | * |
| 316 | * Returns 1 if @fence has already signaled. |
| 317 | * |
Erik Gilling | c0f61a4 | 2013-02-28 16:43:05 -0800 | [diff] [blame] | 318 | * Registers a callback to be called when @fence signals or has an error. |
| 319 | * @waiter should be initialized with sync_fence_waiter_init(). |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 320 | */ |
| 321 | int sync_fence_wait_async(struct sync_fence *fence, |
Erik Gilling | c0f61a4 | 2013-02-28 16:43:05 -0800 | [diff] [blame] | 322 | struct sync_fence_waiter *waiter); |
| 323 | |
| 324 | /** |
| 325 | * sync_fence_cancel_async() - cancels an async wait |
| 326 | * @fence: fence to wait on |
| 327 | * @waiter: waiter callback struck |
| 328 | * |
| 329 | * returns 0 if waiter was removed from fence's async waiter list. |
| 330 | * returns -ENOENT if waiter was not found on fence's async waiter list. |
| 331 | * |
| 332 | * Cancels a previously registered async wait. Will fail gracefully if |
| 333 | * @waiter was never registered or if @fence has already signaled @waiter. |
| 334 | */ |
| 335 | int sync_fence_cancel_async(struct sync_fence *fence, |
| 336 | struct sync_fence_waiter *waiter); |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 337 | |
| 338 | /** |
| 339 | * sync_fence_wait() - wait on fence |
| 340 | * @fence: fence to wait on |
| 341 | * @tiemout: timeout in ms |
| 342 | * |
Erik Gilling | 3b640f5 | 2013-02-28 16:43:14 -0800 | [diff] [blame] | 343 | * Wait for @fence to be signaled or have an error. Waits indefinitely |
| 344 | * if @timeout < 0 |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 345 | */ |
| 346 | int sync_fence_wait(struct sync_fence *fence, long timeout); |
| 347 | |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 348 | #ifdef CONFIG_DEBUG_FS |
| 349 | |
Joe Perches | d30649a | 2015-08-10 14:51:16 -0700 | [diff] [blame] | 350 | void sync_timeline_debug_add(struct sync_timeline *obj); |
| 351 | void sync_timeline_debug_remove(struct sync_timeline *obj); |
| 352 | void sync_fence_debug_add(struct sync_fence *fence); |
| 353 | void sync_fence_debug_remove(struct sync_fence *fence); |
| 354 | void sync_dump(void); |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 355 | |
| 356 | #else |
| 357 | # define sync_timeline_debug_add(obj) |
| 358 | # define sync_timeline_debug_remove(obj) |
| 359 | # define sync_fence_debug_add(fence) |
| 360 | # define sync_fence_debug_remove(fence) |
| 361 | # define sync_dump() |
| 362 | #endif |
| 363 | int sync_fence_wake_up_wq(wait_queue_t *curr, unsigned mode, |
| 364 | int wake_flags, void *key); |
| 365 | |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 366 | #endif /* _LINUX_SYNC_H */ |