Commit 33266648 authored by Daniel Almeida's avatar Daniel Almeida Committed by Alice Ryhl
Browse files

rust: workqueue: add delayed work support for ARef<T>



The preceding patches added support for ARef<T> work items. By the same
token, add support for delayed work items too.

The rationale is the same: it may be convenient or even necessary at times
to implement HasDelayedWork directly on ARef<T>. A follow up patch will
also implement support for drm::Device as the first user.

Reviewed-by: default avatarAlice Ryhl <aliceryhl@google.com>
Acked-by: default avatarDanilo Krummrich <dakr@kernel.org>
Signed-off-by: default avatarDaniel Almeida <daniel.almeida@collabora.com>
Link: https://lore.kernel.org/r/20260323-aref-workitem-v3-3-f59729b812aa@collabora.com


Signed-off-by: default avatarAlice Ryhl <aliceryhl@google.com>
parent 72a723df
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -1007,6 +1007,17 @@ unsafe fn __enqueue<F>(self, queue_work_on: F) -> Self::EnqueueOutput
    }
}

// SAFETY: By the safety requirements of `HasDelayedWork`, the `work_struct` returned by methods in
// `HasWork` provides a `work_struct` that is the `work` field of a `delayed_work`, and the rest of
// the `delayed_work` has the same access rules as its `work` field.
unsafe impl<T, const ID: u64> RawDelayedWorkItem<ID> for ARef<T>
where
    T: WorkItem<ID, Pointer = Self>,
    T: HasDelayedWork<T, ID>,
    T: AlwaysRefCounted,
{
}

/// Returns the system work queue (`system_wq`).
///
/// It is the one used by `schedule[_delayed]_work[_on]()`. Multi-CPU multi-threaded. There are