[PATCH v2 0/5] rust: sync: add WaitQueue infrastructure
From: Danilo Krummrich
Date: Wed Nov 04 2026 - 20:37:15 EST
Add a WaitQueue abstraction wrapping struct wait_queue_head, providing
wait_event()-style methods that take a condition closure directly.
This is needed for a (subsequent) DRM patch series to wait for in-flight file
close operations during driver unbind. The Tyr driver also needs it for "CSF
firmware responses and other GPU-driven events" [1].
Convert CondVar (and PollCondVar) to use WaitQueue internally, removing
duplicate code using WaitQueue as the base primitive and add
wait_interruptible_freezable_nonexclusive() for subsequent binder usage.
Changes in v2:
- Drop the already merged workqueue patch.
- Make as_raw() public.
- Split error types and use bindings constants for direct C calls.
- Avoid condition rechecks after success.
- Check the condition before preparing a waiter.
- Add non-exclusive wait support, including a CondVar method for subsequent
Binder conversion.
- Handle zero and expired timeouts before interruption; extend KUnit coverage.
[1] https://lore.kernel.org/dri-devel/20260721151423.444175-2-laura.nao@xxxxxxxxxxxxx/
Danilo Krummrich (5):
rust: task: add safe schedule_timeout() wrapper
rust: sync: add WaitQueue infrastructure
rust: sync: convert CondVar and PollCondVar to use WaitQueue
rust: sync: condvar: use task::schedule_timeout()
rust: sync: condvar: add non-exclusive freezable waiting
rust/kernel/sync.rs | 8 +
rust/kernel/sync/condvar.rs | 134 ++++-----
rust/kernel/sync/poll.rs | 19 +-
rust/kernel/sync/wait.rs | 524 ++++++++++++++++++++++++++++++++++++
rust/kernel/task.rs | 16 ++
5 files changed, 612 insertions(+), 89 deletions(-)
create mode 100644 rust/kernel/sync/wait.rs
base-commit: 41871f4ddf710339863f957bcfcab5094c234771
--
2.56.0