From: "Gary Guo" <gary@garyguo.net>
To: "Alice Ryhl" <aliceryhl@google.com>,
"Danilo Krummrich" <dakr@kernel.org>
Cc: <airlied@gmail.com>, <simona@ffwll.ch>,
<daniel.almeida@collabora.com>, <ojeda@kernel.org>,
<boqun@kernel.org>, <gary@garyguo.net>,
<bjorn3_gh@protonmail.com>, <lossin@kernel.org>,
<a.hindborg@kernel.org>, <tmgross@umich.edu>, <tamird@kernel.org>,
<acourbot@nvidia.com>, <work@onurozkan.dev>,
<nova-gpu@lists.linux.dev>, <dri-devel@lists.freedesktop.org>,
<linux-kernel@vger.kernel.org>, <rust-for-linux@vger.kernel.org>
Subject: Re: [PATCH] rust: drm: remove DRM device private data
Date: Thu, 19 Nov 2026 11:24:55 +0000 [thread overview]
Message-ID: <DMZ5ER6XTNLG.2ZJOF7F4100XW@garyguo.net> (raw)
In-Reply-To: <20261119111746.3049044-1-aliceryhl@google.com>
On Thu Nov 19, 2026 at 11:17 AM GMT, Alice Ryhl wrote:
> 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@kernel.org>
>
> 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@google.com>
>
> 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.)
Instead of a comment, a const assertion of !needs_drop would be better.
Best,
Gary
next prev parent reply other threads:[~2026-11-19 11:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 18:07 [PATCH] rust: drm: remove DRM device private data Danilo Krummrich
2026-11-19 11:17 ` Alice Ryhl
2026-11-19 11:24 ` Gary Guo [this message]
2026-11-19 11:49 ` Alice Ryhl
2026-11-19 17:28 ` Danilo Krummrich
2026-11-20 9:53 ` Alice Ryhl
2026-11-20 11:23 ` Gary Guo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DMZ5ER6XTNLG.2ZJOF7F4100XW@garyguo.net \
--to=gary@garyguo.net \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.