From 206bada308d0d715d62ac841784af34a2ca22ff6 Mon Sep 17 00:00:00 2001 From: Daniel Almeida Date: Mon, 23 Mar 2026 20:27:02 -0300 Subject: [PATCH] rust: drm: dispatch delayed work items to the private data 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 to dispatch the delayed work to T::Data. Reviewed-by: Alice Ryhl Acked-by: Danilo Krummrich Signed-off-by: Daniel Almeida Link: https://lore.kernel.org/r/20260323-aref-workitem-v3-4-f59729b812aa@collabora.com Signed-off-by: Alice Ryhl --- rust/kernel/drm/device.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/rust/kernel/drm/device.rs b/rust/kernel/drm/device.rs index 5db5c7e3bb7a..adbafe8db54d 100644 --- a/rust/kernel/drm/device.rs +++ b/rust/kernel/drm/device.rs @@ -19,6 +19,7 @@ }, types::Opaque, workqueue::{ + HasDelayedWork, HasWork, Work, WorkItem, // @@ -291,3 +292,15 @@ unsafe fn work_container_of(ptr: *mut Work, ID>) -> *mut Self { unsafe { crate::container_of!(data_ptr, Self, data) } } } + +// SAFETY: Our `HasWork` 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, +// ID>`, which requires that `T::Data::raw_get_work` return a `work_struct` that +// is inside a `delayed_work`. +unsafe impl HasDelayedWork, ID> for Device +where + T: drm::Driver, + T::Data: HasDelayedWork, ID>, +{ +}