Lines Matching +full:wait +full:- +full:state

1 // SPDX-License-Identifier: GPL-2.0
4 * Generic wait-for-completion handler;
7 * wait_for_completion default blocks whereas semaphore default non-block. The
17 * complete: - signals a single thread waiting on this completion
18 * @x: holds the state of this particular completion
26 * accessing the task state.
32 raw_spin_lock_irqsave(&x->wait.lock, flags); in complete()
34 if (x->done != UINT_MAX) in complete()
35 x->done++; in complete()
36 swake_up_locked(&x->wait); in complete()
37 raw_spin_unlock_irqrestore(&x->wait.lock, flags); in complete()
42 * complete_all: - signals all threads waiting on this completion
43 * @x: holds the state of this particular completion
48 * accessing the task state.
63 raw_spin_lock_irqsave(&x->wait.lock, flags); in complete_all()
64 x->done = UINT_MAX; in complete_all()
65 swake_up_all_locked(&x->wait); in complete_all()
66 raw_spin_unlock_irqrestore(&x->wait.lock, flags); in complete_all()
72 long (*action)(long), long timeout, int state) in do_wait_for_common() argument
74 if (!x->done) { in do_wait_for_common()
75 DECLARE_SWAITQUEUE(wait); in do_wait_for_common()
78 if (signal_pending_state(state, current)) { in do_wait_for_common()
79 timeout = -ERESTARTSYS; in do_wait_for_common()
82 __prepare_to_swait(&x->wait, &wait); in do_wait_for_common()
83 __set_current_state(state); in do_wait_for_common()
84 raw_spin_unlock_irq(&x->wait.lock); in do_wait_for_common()
86 raw_spin_lock_irq(&x->wait.lock); in do_wait_for_common()
87 } while (!x->done && timeout); in do_wait_for_common()
88 __finish_swait(&x->wait, &wait); in do_wait_for_common()
89 if (!x->done) in do_wait_for_common()
92 if (x->done != UINT_MAX) in do_wait_for_common()
93 x->done--; in do_wait_for_common()
99 long (*action)(long), long timeout, int state) in __wait_for_common() argument
105 raw_spin_lock_irq(&x->wait.lock); in __wait_for_common()
106 timeout = do_wait_for_common(x, action, timeout, state); in __wait_for_common()
107 raw_spin_unlock_irq(&x->wait.lock); in __wait_for_common()
115 wait_for_common(struct completion *x, long timeout, int state) in wait_for_common() argument
117 return __wait_for_common(x, schedule_timeout, timeout, state); in wait_for_common()
121 wait_for_common_io(struct completion *x, long timeout, int state) in wait_for_common_io() argument
123 return __wait_for_common(x, io_schedule_timeout, timeout, state); in wait_for_common_io()
127 * wait_for_completion: - waits for completion of a task
128 * @x: holds the state of this particular completion
143 * wait_for_completion_timeout: - waits for completion of a task (w/timeout)
144 * @x: holds the state of this particular completion
162 * wait_for_completion_io: - waits for completion of a task
163 * @x: holds the state of this particular completion
176 * wait_for_completion_io_timeout: - waits for completion of a task (w/timeout)
177 * @x: holds the state of this particular completion
196 * wait_for_completion_interruptible: - waits for completion of a task (w/intr)
197 * @x: holds the state of this particular completion
202 * Return: -ERESTARTSYS if interrupted, 0 if completed.
208 if (t == -ERESTARTSYS) in wait_for_completion_interruptible()
215 * wait_for_completion_interruptible_timeout: - waits for completion (w/(to,intr))
216 * @x: holds the state of this particular completion
222 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
234 * wait_for_completion_killable: - waits for completion of a task (killable)
235 * @x: holds the state of this particular completion
240 * Return: -ERESTARTSYS if interrupted, 0 if completed.
246 if (t == -ERESTARTSYS) in wait_for_completion_killable()
252 int __sched wait_for_completion_state(struct completion *x, unsigned int state) in wait_for_completion_state() argument
254 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, state); in wait_for_completion_state()
256 if (t == -ERESTARTSYS) in wait_for_completion_state()
263 * wait_for_completion_killable_timeout: - waits for completion of a task (w/(to,killable))
264 * @x: holds the state of this particular completion
271 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
283 * try_wait_for_completion - try to decrement a completion without blocking
300 * Since x->done will need to be locked only in try_wait_for_completion()
301 * in the non-blocking case, we check x->done in try_wait_for_completion()
305 if (!READ_ONCE(x->done)) in try_wait_for_completion()
308 raw_spin_lock_irqsave(&x->wait.lock, flags); in try_wait_for_completion()
309 if (!x->done) in try_wait_for_completion()
311 else if (x->done != UINT_MAX) in try_wait_for_completion()
312 x->done--; in try_wait_for_completion()
313 raw_spin_unlock_irqrestore(&x->wait.lock, flags); in try_wait_for_completion()
319 * completion_done - Test to see if a completion has any waiters
331 if (!READ_ONCE(x->done)) in completion_done()
335 * If ->done, we need to wait for complete() to release ->wait.lock in completion_done()
339 raw_spin_lock_irqsave(&x->wait.lock, flags); in completion_done()
340 raw_spin_unlock_irqrestore(&x->wait.lock, flags); in completion_done()