From: "Gary Guo" <gary@garyguo.net>
To: "Alice Ryhl" <aliceryhl@google.com>,
"Danilo Krummrich" <dakr@kernel.org>
Cc: <gregkh@linuxfoundation.org>, <rafael@kernel.org>,
<acourbot@nvidia.com>, <david.m.ertman@intel.com>,
<ira.weiny@intel.com>, <leon@kernel.org>, <ojeda@kernel.org>,
<boqun@kernel.org>, <gary@garyguo.net>,
<bjorn3_gh@protonmail.com>, <lossin@kernel.org>,
<a.hindborg@kernel.org>, <tmgross@umich.edu>,
<driver-core@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
<nova-gpu@lists.linux.dev>, <dri-devel@lists.freedesktop.org>,
<rust-for-linux@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] rust: auxiliary: add registration data to auxiliary devices
Date: Wed, 06 May 2026 14:41:06 +0100 [thread overview]
Message-ID: <DIBMXPC3ZKIA.1UQORYD223AY6@garyguo.net> (raw)
In-Reply-To: <afs3Mz8J9oOeqF34@google.com>
On Wed May 6, 2026 at 1:42 PM BST, Alice Ryhl wrote:
> On Tue, May 05, 2026 at 05:23:08PM +0200, Danilo Krummrich wrote:
>> Add a registration_data pointer to struct auxiliary_device, allowing the
>> registering (parent) driver to attach private data to the device at
>> registration time and retrieve it later when called back by the
>> auxiliary (child) driver.
>>
>> By tying the data to the device's registration, Rust drivers can bind
>> the lifetime of device resources to it, since the auxiliary bus
>> guarantees that the parent driver remains bound while the auxiliary
>> device is bound.
>>
>> On the Rust side, Registration<T> takes ownership of the data via
>> ForeignOwnable. A TypeId is stored alongside the data for runtime type
>> checking, making Device::registration_data<T>() a safe method.
>>
>> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
>
> The change itself LGTM.
>
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
>
> But I'm not entirely convinced that this is the most convenient
> user-interface. I'm wondering if the auxiliary driver trait could
> specify which type the parent driver data is using in an associated
> type, and whether you could eliminate the check and error path that way.
> But then again, AuxiliaryDriver does not appear as a generic parameter
> in auxiliary::Driver, so it might not work.
I think that's similar to what I'm suggesting in
https://lore.kernel.org/rust-for-linux/DI6L13A5LMOW.DU7ZTHXZYB0K@garyguo.net/.
This does still require the type ID to exist and that probe of auxiliary drivers
need to fail if type ID mismatches during probing.
Best,
Gary
next prev parent reply other threads:[~2026-05-06 13:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 15:23 [PATCH v2 0/3] rust: auxiliary: replace drvdata() with registration data Danilo Krummrich
2026-05-05 15:23 ` [PATCH v2 1/3] rust: alloc: add Box::zeroed() Danilo Krummrich
2026-05-05 15:48 ` Alice Ryhl
2026-05-05 20:04 ` Danilo Krummrich
2026-05-05 20:06 ` Gary Guo
2026-05-05 20:10 ` Danilo Krummrich
2026-05-05 15:23 ` [PATCH v2 2/3] rust: auxiliary: add registration data to auxiliary devices Danilo Krummrich
2026-05-06 12:42 ` Alice Ryhl
2026-05-06 13:41 ` Gary Guo [this message]
2026-05-05 15:23 ` [PATCH v2 3/3] rust: driver core: remove drvdata() and driver_type Danilo Krummrich
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=DIBMXPC3ZKIA.1UQORYD223AY6@garyguo.net \
--to=gary@garyguo.net \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=david.m.ertman@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=ira.weiny@intel.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox