]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rust: drm: dispatch delayed work items to the private data
authorDaniel Almeida <daniel.almeida@collabora.com>
Mon, 23 Mar 2026 23:27:02 +0000 (20:27 -0300)
committerAlice Ryhl <aliceryhl@google.com>
Thu, 26 Mar 2026 13:08:49 +0000 (13:08 +0000)
Much like the patch that dispatched (regular) work items, we also need to
dispatch delayed work items in order not to trigger the orphan rule. This
allows a drm::Device<T> to dispatch the delayed work to T::Data.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
Link: https://lore.kernel.org/r/20260323-aref-workitem-v3-4-f59729b812aa@collabora.com
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
rust/kernel/drm/device.rs

index 5db5c7e3bb7aa6c365291c6cf26b2a8aa5fd4bd6..adbafe8db54d11f5c96d40ee0fafa272546c9159 100644 (file)
@@ -19,6 +19,7 @@ use crate::{
     },
     types::Opaque,
     workqueue::{
+        HasDelayedWork,
         HasWork,
         Work,
         WorkItem, //
@@ -291,3 +292,15 @@ where
         unsafe { crate::container_of!(data_ptr, Self, data) }
     }
 }
+
+// SAFETY: Our `HasWork<T, ID>` implementation returns a `work_struct` that is
+// stored in the `work` field of a `delayed_work` with the same access rules as
+// the `work_struct` owing to the bound on `T::Data: HasDelayedWork<Device<T>,
+// ID>`, which requires that `T::Data::raw_get_work` return a `work_struct` that
+// is inside a `delayed_work`.
+unsafe impl<T, const ID: u64> HasDelayedWork<Device<T>, ID> for Device<T>
+where
+    T: drm::Driver,
+    T::Data: HasDelayedWork<Device<T>, ID>,
+{
+}