From: "Danilo Krummrich" <dakr@kernel.org>
To: "Gary Guo" <gary@garyguo.net>
Cc: "Alice Ryhl" <aliceryhl@google.com>, <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>,
<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: Sun, 10 May 2026 23:39:48 +0200 [thread overview]
Message-ID: <DIFBME3GXDC0.14UHJTPD6TTAE@kernel.org> (raw)
In-Reply-To: <DIBMXPC3ZKIA.1UQORYD223AY6@garyguo.net>
On Wed May 6, 2026 at 3:41 PM CEST, Gary Guo wrote:
> 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>
Thanks!
>> 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.
Technically, this would be an additional driver match criteria, i.e. the name
string in struct auxiliary_device_id *and* the asserted type of the parent's
registration data must match.
Given that drivers can match against multiple entries in the auxiliary_device_id
table, we must consider that they can have different registration data types
(depending on the specific parent driver that exposed the auxiliary device).
Thus, I don't think we can solve this without a runtime dispatch (over all types
that would need to be listed in the ID table) anyway; and having this dispatch
in the child driver - essentially leaking an implementation detail of each of
the parents into the child - does not seem to add any value; quite the opposite
unfortunately.
(OOC, I hacked up the statically typed version -- I think it turns out OK,
despite the fact that it still leaks the parent's registration private data type
to the child, which I dislike, plus a few hiccups with the generic device
context infrastructure. But as mentioned, I don't think that's an option in the
first place.)
next prev parent reply other threads:[~2026-05-10 21:39 UTC|newest]
Thread overview: 11+ 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
2026-05-10 21:39 ` Danilo Krummrich [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=DIFBME3GXDC0.14UHJTPD6TTAE@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=david.m.ertman@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--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