Re: [PATCH] rust: drm: remove DRM device private data
From: Alice Ryhl
Date: Thu Nov 19 2026 - 06:17:56 EST
On Wed, Nov 18, 2026 at 07:07:35PM +0100, Danilo Krummrich wrote:
> Driver::Data is owned by the reference-counted drm::Device and can
> outlive device unregistration and driver unbind. Driver state belongs in
> RegistrationData, whose lifetime ends with registration teardown.
>
> The intended model is that, after drm_dev_unplug(), surviving DRM
> objects (e.g. through remaining userspace handles) no longer require
> access to the driver state. Thus Driver::RegistrationData is available
> (and sufficient) for all DRM callbacks into the driver.
>
> Remove Driver::Data, its storage and Deref implementation, and the
> unused workqueue implementations that depend on it. Drop the data
> initializer argument from UnregisteredDevice::new() and update its
> callers.
>
> Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>
Makes sense to me. Both in-tree users had `type Data = ()` anyway, and
nothing uses the `WorkItem`/`HasWork` impls on `drm::Device`, so this is
a pure simplification.
Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
One small suggestion below.
> - release: Some(Device::<T>::release),
> + release: None,
[...]
> #[repr(C)]
> pub struct Device<T: drm::Driver, C: DeviceContext = Normal> {
> dev: Opaque<bindings::drm_device>,
> - data: T::Data,
> pub(super) registration_data: UnsafeCell<NonNull<T::RegistrationData<'static>>>,
> _ctx: PhantomData<C>,
> }
With `release` gone, nothing ever runs `drop_in_place()` on the Rust
side of `Device` anymore. That's fine today since all remaining fields
are trivially droppable, but it is now an implicit requirement on the
struct: anyone adding a field with a `Drop` impl (or a pinned field
that needs a destructor) would silently leak it.
Could you add a short comment on the struct along the lines of "no
`release` callback is installed, so no field of this struct may require
dropping"? That way the next person adding a field knows they have to
bring back the `release` callback.
(For what it's worth, I checked the lifetime-parameterized `File`
series [1] against this: `open_count`/`open_count_wq` are both
droppable without a destructor, and the two merge cleanly, so no
ordering constraint there as far as I can tell.)
[1] https://lore.kernel.org/r/20261118163203.2483856-1-dakr@xxxxxxxxxx
Alice