[PATCH 5/9] rust: workqueue: make OwnedQueue thread-safe
Mike Lothian <[email protected]>
| Newsgroups | org.kernel.vger.rust-for-linux,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
OwnedQueue only owns a pointer to Queue, whose operations are already Send and Sync. Propagate those guarantees so drivers can keep an owned queue in shared device state. Assisted-by: Claude:claude-opus-5 Signed-off-by: Mike Lothian <[email protected]> --- rust/kernel/workqueue/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rust/kernel/workqueue/mod.rs b/rust/kernel/workqueue/mod.rs index e30c21214a81..000a29c9dc1a 100644 --- a/rust/kernel/workqueue/mod.rs +++ b/rust/kernel/workqueue/mod.rs @@ -380,6 +380,12 @@ pub struct OwnedQueue { queue: NonNull<Queue>, } +// SAFETY: `Queue` operations are thread-safe and ownership may be transferred +// between threads. +unsafe impl Send for OwnedQueue {} +// SAFETY: Shared access only exposes the thread-safe `Queue` API. +unsafe impl Sync for OwnedQueue {} + impl Deref for OwnedQueue { type Target = Queue; fn deref(&self) -> &Queue {