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
20 raw_spin_lock_irqsave(&x->wait.lock, flags); in complete_with_flags()
22 if (x->done != UINT_MAX) in complete_with_flags()
23 x->done++; in complete_with_flags()
24 swake_up_locked(&x->wait, wake_flags); in complete_with_flags()
25 raw_spin_unlock_irqrestore(&x->wait.lock, flags); in complete_with_flags()
34 * complete: - signals a single thread waiting on this completion
35 * @x: holds the state of this particular completion
43 * accessing the task state.
52 * complete_all: - signals all threads waiting on this completion
53 * @x: holds the state of this particular completion
58 * accessing the task state.
73 raw_spin_lock_irqsave(&x->wait.lock, flags); in complete_all()
74 x->done = UINT_MAX; in complete_all()
75 swake_up_all_locked(&x->wait); in complete_all()
76 raw_spin_unlock_irqrestore(&x->wait.lock, flags); in complete_all()
82 long (*action)(long), long timeout, int state) in do_wait_for_common() argument
84 if (!x->done) { in do_wait_for_common()
85 DECLARE_SWAITQUEUE(wait); in do_wait_for_common()
88 if (signal_pending_state(state, current)) { in do_wait_for_common()
89 timeout = -ERESTARTSYS; in do_wait_for_common()
92 __prepare_to_swait(&x->wait, &wait); in do_wait_for_common()
93 __set_current_state(state); in do_wait_for_common()
94 raw_spin_unlock_irq(&x->wait.lock); in do_wait_for_common()
96 raw_spin_lock_irq(&x->wait.lock); in do_wait_for_common()
97 } while (!x->done && timeout); in do_wait_for_common()
98 __finish_swait(&x->wait, &wait); in do_wait_for_common()
99 if (!x->done) in do_wait_for_common()
102 if (x->done != UINT_MAX) in do_wait_for_common()
103 x->done--; in do_wait_for_common()
109 long (*action)(long), long timeout, int state) in __wait_for_common() argument
115 raw_spin_lock_irq(&x->wait.lock); in __wait_for_common()
116 timeout = do_wait_for_common(x, action, timeout, state); in __wait_for_common()
117 raw_spin_unlock_irq(&x->wait.lock); in __wait_for_common()
125 wait_for_common(struct completion *x, long timeout, int state) in wait_for_common() argument
127 return __wait_for_common(x, schedule_timeout, timeout, state); in wait_for_common()
131 wait_for_common_io(struct completion *x, long timeout, int state) in wait_for_common_io() argument
133 return __wait_for_common(x, io_schedule_timeout, timeout, state); in wait_for_common_io()
137 * wait_for_completion: - waits for completion of a task
138 * @x: holds the state of this particular completion
153 * wait_for_completion_timeout: - waits for completion of a task (w/timeout)
154 * @x: holds the state of this particular completion
172 * wait_for_completion_io: - waits for completion of a task
173 * @x: holds the state of this particular completion
186 * wait_for_completion_io_timeout: - waits for completion of a task (w/timeout)
187 * @x: holds the state of this particular completion
206 * wait_for_completion_interruptible: - waits for completion of a task (w/intr)
207 * @x: holds the state of this particular completion
212 * Return: -ERESTARTSYS if interrupted, 0 if completed.
218 if (t == -ERESTARTSYS) in wait_for_completion_interruptible()
225 * wait_for_completion_interruptible_timeout: - waits for completion (w/(to,intr))
226 * @x: holds the state of this particular completion
232 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
244 * wait_for_completion_killable: - waits for completion of a task (killable)
245 * @x: holds the state of this particular completion
250 * Return: -ERESTARTSYS if interrupted, 0 if completed.
256 if (t == -ERESTARTSYS) in wait_for_completion_killable()
262 int __sched wait_for_completion_state(struct completion *x, unsigned int state) in wait_for_completion_state() argument
264 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, state); in wait_for_completion_state()
266 if (t == -ERESTARTSYS) in wait_for_completion_state()
273 * wait_for_completion_killable_timeout: - waits for completion of a task (w/(to,killable))
274 * @x: holds the state of this particular completion
281 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
293 * try_wait_for_completion - try to decrement a completion without blocking
310 * Since x->done will need to be locked only in try_wait_for_completion()
311 * in the non-blocking case, we check x->done in try_wait_for_completion()
315 if (!READ_ONCE(x->done)) in try_wait_for_completion()
318 raw_spin_lock_irqsave(&x->wait.lock, flags); in try_wait_for_completion()
319 if (!x->done) in try_wait_for_completion()
321 else if (x->done != UINT_MAX) in try_wait_for_completion()
322 x->done--; in try_wait_for_completion()
323 raw_spin_unlock_irqrestore(&x->wait.lock, flags); in try_wait_for_completion()
329 * completion_done - Test to see if a completion has any waiters
341 if (!READ_ONCE(x->done)) in completion_done()
345 * If ->done, we need to wait for complete() to release ->wait.lock in completion_done()
349 raw_spin_lock_irqsave(&x->wait.lock, flags); in completion_done()
350 raw_spin_unlock_irqrestore(&x->wait.lock, flags); in completion_done()