Lines Matching +full:blocking +full:- +full:io

1 // SPDX-License-Identifier: GPL-2.0
3 * Generic wait-for-completion handler;
6 * wait_for_completion default blocks whereas semaphore default non-block. The
17 * complete: - signals a single thread waiting on this completion
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
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()
74 if (!x->done) { 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()
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()
105 raw_spin_lock_irq(&x->wait.lock); in __wait_for_common()
107 raw_spin_unlock_irq(&x->wait.lock); in __wait_for_common()
127 * wait_for_completion: - waits for completion of a task
143 * wait_for_completion_timeout: - waits for completion of a task (w/timeout)
162 * wait_for_completion_io: - waits for completion of a task
167 * for IO (which traditionally means blkio only).
176 * wait_for_completion_io_timeout: - waits for completion of a task (w/timeout)
182 * interruptible. The caller is accounted as waiting for IO (which traditionally
196 * wait_for_completion_interruptible: - waits for completion of a task (w/intr)
202 * Return: -ERESTARTSYS if interrupted, 0 if completed.
207 if (t == -ERESTARTSYS) in wait_for_completion_interruptible()
214 * wait_for_completion_interruptible_timeout: - waits for completion (w/(to,intr))
221 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
233 * wait_for_completion_killable: - waits for completion of a task (killable)
239 * Return: -ERESTARTSYS if interrupted, 0 if completed.
244 if (t == -ERESTARTSYS) in wait_for_completion_killable()
251 * wait_for_completion_killable_timeout: - waits for completion of a task (w/(to,killable))
259 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
271 * try_wait_for_completion - try to decrement a completion without blocking
274 * Return: 0 if a decrement cannot be done without blocking
278 * attempt to decrement the counter without blocking. This
288 * Since x->done will need to be locked only in try_wait_for_completion()
289 * in the non-blocking case, we check x->done in try_wait_for_completion()
291 * return early in the blocking case. in try_wait_for_completion()
293 if (!READ_ONCE(x->done)) in try_wait_for_completion()
296 raw_spin_lock_irqsave(&x->wait.lock, flags); in try_wait_for_completion()
297 if (!x->done) in try_wait_for_completion()
299 else if (x->done != UINT_MAX) in try_wait_for_completion()
300 x->done--; in try_wait_for_completion()
301 raw_spin_unlock_irqrestore(&x->wait.lock, flags); in try_wait_for_completion()
307 * completion_done - Test to see if a completion has any waiters
319 if (!READ_ONCE(x->done)) in completion_done()
323 * If ->done, we need to wait for complete() to release ->wait.lock in completion_done()
327 raw_spin_lock_irqsave(&x->wait.lock, flags); in completion_done()
328 raw_spin_unlock_irqrestore(&x->wait.lock, flags); in completion_done()