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 |
Gustavo Padovan | 9b32381 | 2016-01-21 10:49:14 -0200 | [diff] [blame^] | 113 | * @base: 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 |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 116 | */ |
| 117 | struct sync_pt { |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 118 | struct fence base; |
| 119 | |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 120 | struct list_head child_list; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 121 | struct list_head active_list; |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 122 | }; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 123 | |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 124 | static inline struct sync_timeline *sync_pt_parent(struct sync_pt *pt) |
| 125 | { |
| 126 | return container_of(pt->base.lock, struct sync_timeline, |
| 127 | child_list_lock); |
| 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 | struct sync_fence_cb { |
| 131 | struct fence_cb cb; |
| 132 | struct fence *sync_pt; |
| 133 | struct sync_fence *fence; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | /** |
| 137 | * struct sync_fence - sync fence |
| 138 | * @file: file representing this fence |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 139 | * @kref: reference count on fence. |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 140 | * @name: name of sync_fence. Useful for debugging |
Erik Gilling | af7582f | 2013-02-28 16:43:00 -0800 | [diff] [blame] | 141 | * @sync_fence_list: membership in global fence list |
Gustavo Padovan | 9b32381 | 2016-01-21 10:49:14 -0200 | [diff] [blame^] | 142 | * @num_fences number of sync_pts in the fence |
| 143 | * @wq: wait queue for fence signaling |
| 144 | * @status: 0: signaled, >0:active, <0: error |
| 145 | * @cbs: sync_pts callback information |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 146 | */ |
| 147 | struct sync_fence { |
| 148 | struct file *file; |
Erik Gilling | 0154417 | 2013-02-28 16:43:10 -0800 | [diff] [blame] | 149 | struct kref kref; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 150 | char name[32]; |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 151 | #ifdef CONFIG_DEBUG_FS |
| 152 | struct list_head sync_fence_list; |
| 153 | #endif |
| 154 | int num_fences; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 155 | |
| 156 | wait_queue_head_t wq; |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 157 | atomic_t status; |
Erik Gilling | af7582f | 2013-02-28 16:43:00 -0800 | [diff] [blame] | 158 | |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 159 | struct sync_fence_cb cbs[]; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 160 | }; |
| 161 | |
Erik Gilling | c0f61a4 | 2013-02-28 16:43:05 -0800 | [diff] [blame] | 162 | struct sync_fence_waiter; |
| 163 | typedef void (*sync_callback_t)(struct sync_fence *fence, |
| 164 | struct sync_fence_waiter *waiter); |
| 165 | |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 166 | /** |
| 167 | * struct sync_fence_waiter - metadata for asynchronous waiter on a fence |
Gustavo Padovan | 9b32381 | 2016-01-21 10:49:14 -0200 | [diff] [blame^] | 168 | * @work: wait_queue for the fence waiter |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 169 | * @callback: function pointer to call when fence signals |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 170 | */ |
| 171 | struct sync_fence_waiter { |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 172 | wait_queue_t work; |
| 173 | sync_callback_t callback; |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 174 | }; |
| 175 | |
Erik Gilling | c0f61a4 | 2013-02-28 16:43:05 -0800 | [diff] [blame] | 176 | static inline void sync_fence_waiter_init(struct sync_fence_waiter *waiter, |
| 177 | sync_callback_t callback) |
| 178 | { |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 179 | INIT_LIST_HEAD(&waiter->work.task_list); |
Erik Gilling | c0f61a4 | 2013-02-28 16:43:05 -0800 | [diff] [blame] | 180 | waiter->callback = callback; |
| 181 | } |
| 182 | |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 183 | /* |
| 184 | * API for sync_timeline implementers |
| 185 | */ |
| 186 | |
| 187 | /** |
| 188 | * sync_timeline_create() - creates a sync object |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 189 | * @ops: specifies the implementation ops for the object |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 190 | * @size: size to allocate for this obj |
| 191 | * @name: sync_timeline name |
| 192 | * |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 193 | * Creates a new sync_timeline which will use the implementation specified by |
| 194 | * @ops. @size bytes will be allocated allowing for implementation specific |
Gustavo Padovan | 9b32381 | 2016-01-21 10:49:14 -0200 | [diff] [blame^] | 195 | * data to be kept after the generic sync_timeline struct. Returns the |
| 196 | * sync_timeline object or NULL in case of error. |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 197 | */ |
| 198 | struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops, |
| 199 | int size, const char *name); |
| 200 | |
| 201 | /** |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 202 | * sync_timeline_destroy() - destroys a sync object |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 203 | * @obj: sync_timeline to destroy |
| 204 | * |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 205 | * A sync implementation should call this when the @obj is going away |
| 206 | * (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] | 207 | * sync_pts are freed. |
| 208 | */ |
| 209 | void sync_timeline_destroy(struct sync_timeline *obj); |
| 210 | |
| 211 | /** |
| 212 | * sync_timeline_signal() - signal a status change on a sync_timeline |
| 213 | * @obj: sync_timeline to signal |
| 214 | * |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 215 | * 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] | 216 | * has signaled or has an error condition. |
| 217 | */ |
| 218 | void sync_timeline_signal(struct sync_timeline *obj); |
| 219 | |
| 220 | /** |
| 221 | * sync_pt_create() - creates a sync pt |
| 222 | * @parent: sync_pt's parent sync_timeline |
| 223 | * @size: size to allocate for this pt |
| 224 | * |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 225 | * Creates a new sync_pt as a child of @parent. @size bytes will be |
| 226 | * allocated allowing for implementation specific data to be kept after |
Gustavo Padovan | 9b32381 | 2016-01-21 10:49:14 -0200 | [diff] [blame^] | 227 | * the generic sync_timeline struct. Returns the sync_pt object or |
| 228 | * NULL in case of error. |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 229 | */ |
| 230 | struct sync_pt *sync_pt_create(struct sync_timeline *parent, int size); |
| 231 | |
| 232 | /** |
| 233 | * sync_pt_free() - frees a sync pt |
| 234 | * @pt: sync_pt to free |
| 235 | * |
| 236 | * This should only be called on sync_pts which have been created but |
| 237 | * not added to a fence. |
| 238 | */ |
| 239 | void sync_pt_free(struct sync_pt *pt); |
| 240 | |
| 241 | /** |
| 242 | * sync_fence_create() - creates a sync fence |
| 243 | * @name: name of fence to create |
| 244 | * @pt: sync_pt to add to the fence |
| 245 | * |
| 246 | * Creates a fence containg @pt. Once this is called, the fence takes |
| 247 | * ownership of @pt. |
| 248 | */ |
| 249 | struct sync_fence *sync_fence_create(const char *name, struct sync_pt *pt); |
| 250 | |
Maarten Lankhorst | 0f477c6 | 2015-12-11 13:11:50 +0000 | [diff] [blame] | 251 | /** |
| 252 | * sync_fence_create_dma() - creates a sync fence from dma-fence |
| 253 | * @name: name of fence to create |
| 254 | * @pt: dma-fence to add to the fence |
| 255 | * |
| 256 | * Creates a fence containg @pt. Once this is called, the fence takes |
| 257 | * ownership of @pt. |
| 258 | */ |
| 259 | struct sync_fence *sync_fence_create_dma(const char *name, struct fence *pt); |
| 260 | |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 261 | /* |
| 262 | * API for sync_fence consumers |
| 263 | */ |
| 264 | |
| 265 | /** |
| 266 | * sync_fence_merge() - merge two fences |
| 267 | * @name: name of new fence |
| 268 | * @a: fence a |
| 269 | * @b: fence b |
| 270 | * |
| 271 | * Creates a new fence which contains copies of all the sync_pts in both |
Gustavo Padovan | 9b32381 | 2016-01-21 10:49:14 -0200 | [diff] [blame^] | 272 | * @a and @b. @a and @b remain valid, independent fences. Returns the |
| 273 | * new merged fence or NULL in case of error. |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 274 | */ |
| 275 | struct sync_fence *sync_fence_merge(const char *name, |
| 276 | struct sync_fence *a, struct sync_fence *b); |
| 277 | |
| 278 | /** |
| 279 | * sync_fence_fdget() - get a fence from an fd |
| 280 | * @fd: fd referencing a fence |
| 281 | * |
| 282 | * Ensures @fd references a valid fence, increments the refcount of the backing |
Gustavo Padovan | 9b32381 | 2016-01-21 10:49:14 -0200 | [diff] [blame^] | 283 | * file, and returns the fence. Returns the fence or NULL in case of error. |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 284 | */ |
| 285 | struct sync_fence *sync_fence_fdget(int fd); |
| 286 | |
| 287 | /** |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 288 | * sync_fence_put() - puts a reference of a sync fence |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 289 | * @fence: fence to put |
| 290 | * |
| 291 | * Puts a reference on @fence. If this is the last reference, the fence and |
| 292 | * all it's sync_pts will be freed |
| 293 | */ |
| 294 | void sync_fence_put(struct sync_fence *fence); |
| 295 | |
| 296 | /** |
| 297 | * sync_fence_install() - installs a fence into a file descriptor |
Masanari Iida | 4e20eff | 2013-10-31 14:20:25 +0900 | [diff] [blame] | 298 | * @fence: fence to install |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 299 | * @fd: file descriptor in which to install the fence |
| 300 | * |
Heinrich Schuchardt | ae66475 | 2014-09-27 10:52:37 +0200 | [diff] [blame] | 301 | * Installs @fence into @fd. @fd's should be acquired through |
| 302 | * get_unused_fd_flags(O_CLOEXEC). |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 303 | */ |
| 304 | void sync_fence_install(struct sync_fence *fence, int fd); |
| 305 | |
| 306 | /** |
| 307 | * sync_fence_wait_async() - registers and async wait on the fence |
| 308 | * @fence: fence to wait on |
Erik Gilling | c0f61a4 | 2013-02-28 16:43:05 -0800 | [diff] [blame] | 309 | * @waiter: waiter callback struck |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 310 | * |
Erik Gilling | c0f61a4 | 2013-02-28 16:43:05 -0800 | [diff] [blame] | 311 | * Registers a callback to be called when @fence signals or has an error. |
| 312 | * @waiter should be initialized with sync_fence_waiter_init(). |
Gustavo Padovan | 9b32381 | 2016-01-21 10:49:14 -0200 | [diff] [blame^] | 313 | * |
| 314 | * Returns 1 if @fence has already signaled, 0 if not or <0 if error. |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 315 | */ |
| 316 | int sync_fence_wait_async(struct sync_fence *fence, |
Erik Gilling | c0f61a4 | 2013-02-28 16:43:05 -0800 | [diff] [blame] | 317 | struct sync_fence_waiter *waiter); |
| 318 | |
| 319 | /** |
| 320 | * sync_fence_cancel_async() - cancels an async wait |
| 321 | * @fence: fence to wait on |
| 322 | * @waiter: waiter callback struck |
| 323 | * |
Erik Gilling | c0f61a4 | 2013-02-28 16:43:05 -0800 | [diff] [blame] | 324 | * Cancels a previously registered async wait. Will fail gracefully if |
| 325 | * @waiter was never registered or if @fence has already signaled @waiter. |
Gustavo Padovan | 9b32381 | 2016-01-21 10:49:14 -0200 | [diff] [blame^] | 326 | * |
| 327 | * Returns 0 if waiter was removed from fence's async waiter list. |
| 328 | * Returns -ENOENT if waiter was not found on fence's async waiter list. |
Erik Gilling | c0f61a4 | 2013-02-28 16:43:05 -0800 | [diff] [blame] | 329 | */ |
| 330 | int sync_fence_cancel_async(struct sync_fence *fence, |
| 331 | struct sync_fence_waiter *waiter); |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 332 | |
| 333 | /** |
| 334 | * sync_fence_wait() - wait on fence |
| 335 | * @fence: fence to wait on |
| 336 | * @tiemout: timeout in ms |
| 337 | * |
Erik Gilling | 3b640f5 | 2013-02-28 16:43:14 -0800 | [diff] [blame] | 338 | * Wait for @fence to be signaled or have an error. Waits indefinitely |
Gustavo Padovan | 9b32381 | 2016-01-21 10:49:14 -0200 | [diff] [blame^] | 339 | * if @timeout < 0. |
| 340 | * |
| 341 | * Returns 0 if fence signaled, > 0 if it is still active and <0 on error |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 342 | */ |
| 343 | int sync_fence_wait(struct sync_fence *fence, long timeout); |
| 344 | |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 345 | #ifdef CONFIG_DEBUG_FS |
| 346 | |
Joe Perches | d30649a | 2015-08-10 14:51:16 -0700 | [diff] [blame] | 347 | void sync_timeline_debug_add(struct sync_timeline *obj); |
| 348 | void sync_timeline_debug_remove(struct sync_timeline *obj); |
| 349 | void sync_fence_debug_add(struct sync_fence *fence); |
| 350 | void sync_fence_debug_remove(struct sync_fence *fence); |
| 351 | void sync_dump(void); |
Maarten Lankhorst | 0f0d840 | 2014-07-01 12:57:31 +0200 | [diff] [blame] | 352 | |
| 353 | #else |
| 354 | # define sync_timeline_debug_add(obj) |
| 355 | # define sync_timeline_debug_remove(obj) |
| 356 | # define sync_fence_debug_add(fence) |
| 357 | # define sync_fence_debug_remove(fence) |
| 358 | # define sync_dump() |
| 359 | #endif |
| 360 | int sync_fence_wake_up_wq(wait_queue_t *curr, unsigned mode, |
| 361 | int wake_flags, void *key); |
| 362 | |
Erik Gilling | 7ad530b | 2013-02-28 16:42:57 -0800 | [diff] [blame] | 363 | #endif /* _LINUX_SYNC_H */ |