Lines Matching refs:cl
171 void closure_sub(struct closure *cl, int v);
172 void closure_put(struct closure *cl);
174 bool closure_wait(struct closure_waitlist *list, struct closure *cl);
175 void __closure_sync(struct closure *cl);
177 static inline unsigned closure_nr_remaining(struct closure *cl) in closure_nr_remaining() argument
179 return atomic_read(&cl->remaining) & CLOSURE_REMAINING_MASK; in closure_nr_remaining()
188 static inline void closure_sync(struct closure *cl) in closure_sync() argument
191 BUG_ON(closure_nr_remaining(cl) != 1 && !cl->closure_get_happened); in closure_sync()
194 if (cl->closure_get_happened) in closure_sync()
195 __closure_sync(cl); in closure_sync()
198 int __closure_sync_timeout(struct closure *cl, unsigned long timeout);
200 static inline int closure_sync_timeout(struct closure *cl, unsigned long timeout) in closure_sync_timeout() argument
203 BUG_ON(closure_nr_remaining(cl) != 1 && !cl->closure_get_happened); in closure_sync_timeout()
205 return cl->closure_get_happened in closure_sync_timeout()
206 ? __closure_sync_timeout(cl, timeout) in closure_sync_timeout()
212 void closure_debug_create(struct closure *cl);
213 void closure_debug_destroy(struct closure *cl);
217 static inline void closure_debug_create(struct closure *cl) {} in closure_debug_create() argument
218 static inline void closure_debug_destroy(struct closure *cl) {} in closure_debug_destroy() argument
222 static inline void closure_set_ip(struct closure *cl) in closure_set_ip() argument
225 cl->ip = _THIS_IP_; in closure_set_ip()
229 static inline void closure_set_ret_ip(struct closure *cl) in closure_set_ret_ip() argument
232 cl->ip = _RET_IP_; in closure_set_ret_ip()
236 static inline void closure_set_waiting(struct closure *cl, unsigned long f) in closure_set_waiting() argument
239 cl->waiting_on = f; in closure_set_waiting()
243 static inline void closure_set_stopped(struct closure *cl) in closure_set_stopped() argument
245 atomic_sub(CLOSURE_RUNNING, &cl->remaining); in closure_set_stopped()
248 static inline void set_closure_fn(struct closure *cl, closure_fn *fn, in set_closure_fn() argument
251 closure_set_ip(cl); in set_closure_fn()
252 cl->fn = fn; in set_closure_fn()
253 cl->wq = wq; in set_closure_fn()
256 static inline void closure_queue(struct closure *cl) in closure_queue() argument
258 struct workqueue_struct *wq = cl->wq; in closure_queue()
267 INIT_WORK(&cl->work, cl->work.func); in closure_queue()
268 BUG_ON(!queue_work(wq, &cl->work)); in closure_queue()
270 cl->fn(&cl->work); in closure_queue()
276 static inline void closure_get(struct closure *cl) in closure_get() argument
278 cl->closure_get_happened = true; in closure_get()
281 BUG_ON((atomic_inc_return(&cl->remaining) & in closure_get()
284 atomic_inc(&cl->remaining); in closure_get()
291 static inline bool closure_get_not_zero(struct closure *cl) in closure_get_not_zero() argument
293 unsigned old = atomic_read(&cl->remaining); in closure_get_not_zero()
298 } while (!atomic_try_cmpxchg_acquire(&cl->remaining, &old, old + 1)); in closure_get_not_zero()
309 static inline void closure_init(struct closure *cl, struct closure *parent) in closure_init() argument
311 cl->fn = NULL; in closure_init()
312 cl->parent = parent; in closure_init()
316 atomic_set(&cl->remaining, CLOSURE_REMAINING_INITIALIZER); in closure_init()
317 cl->closure_get_happened = false; in closure_init()
319 closure_debug_create(cl); in closure_init()
320 closure_set_ip(cl); in closure_init()
323 static inline void closure_init_stack(struct closure *cl) in closure_init_stack() argument
325 memset(cl, 0, sizeof(struct closure)); in closure_init_stack()
326 atomic_set(&cl->remaining, CLOSURE_REMAINING_INITIALIZER); in closure_init_stack()
328 cl->magic = CLOSURE_MAGIC_STACK; in closure_init_stack()
332 static inline void closure_init_stack_release(struct closure *cl) in closure_init_stack_release() argument
334 memset(cl, 0, sizeof(struct closure)); in closure_init_stack_release()
335 atomic_set_release(&cl->remaining, CLOSURE_REMAINING_INITIALIZER); in closure_init_stack_release()
337 cl->magic = CLOSURE_MAGIC_STACK; in closure_init_stack_release()
354 struct closure *cl = container_of(ws, struct closure, work); \
355 type *name = container_of(cl, type, member)
386 void closure_return_sync(struct closure *cl);
427 static inline void closure_call(struct closure *cl, closure_fn fn, in closure_call() argument
431 closure_init(cl, parent); in closure_call()
432 continue_at_nobarrier(cl, fn, wq); in closure_call()
437 struct closure cl; \
439 closure_init_stack(&cl); \
442 closure_wait(waitlist, &cl); \
445 closure_sync(&cl); \
448 closure_sync(&cl); \
459 struct closure cl; \
462 closure_init_stack(&cl); \
465 closure_wait(waitlist, &cl); \
473 closure_sync_timeout(&cl, _t); \
476 closure_sync(&cl); \