[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2025092529-schilling-impeach-c71a@gregkh>
Date: Thu, 25 Sep 2025 19:38:22 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Danilo Krummrich <dakr@...nel.org>
Cc: Daniel Almeida <daniel.almeida@...labora.com>,
Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org,
linux-usb@...r.kernel.org
Subject: Re: [PATCH 0/2] rust: usb: add initial USB abstractions
On Thu, Sep 25, 2025 at 03:29:25PM +0200, Danilo Krummrich wrote:
> On Thu Sep 25, 2025 at 2:52 PM CEST, Greg Kroah-Hartman wrote:
> > Yes, this is not a normal way that bindings will probably be merged into
> > the tree, but as I consulted deeply with the USB maintainer about this
> > topic while eating some good Paris pizza and French wine this week while
> > at the Kernel Recipes conference, I think that this deserves an
> > exception as they agree this can be merged now and they will be
> > responsible for any fallout.[1]
>
> If you rather have it "staging" in-tree that's of course up to you. :)
>
> But, I'd prefer not to expose the incorrect conversion between a
> &usb::Interface<Ctx> and a &usb::Device<Ctx> for a full release in Linus' tree.
>
> Besides other implications, this conversation also implies that
> &usb::Device<Core> can be derived from &usb::Interface<Core>, which semantically
> means that if the USB interface's device lock is held we infer that the device
> lock of the USB device is held as well.
>
> I know the code isn't even built, but I don't want people reading the code to
> take wrong conclusions from that.
>
> Also, it's dead code anyways, so maybe just apply the following hunk?
>
> Thanks,
> Danilo
>
> diff --git a/rust/kernel/usb.rs b/rust/kernel/usb.rs
> index 8899e7520b58..9bc3478cf561 100644
> --- a/rust/kernel/usb.rs
> +++ b/rust/kernel/usb.rs
> @@ -340,18 +340,6 @@ fn as_ref(&self) -> &device::Device<Ctx> {
> }
> }
>
> -impl<Ctx: device::DeviceContext> AsRef<Device<Ctx>> for Interface<Ctx> {
> - fn as_ref(&self) -> &Device<Ctx> {
> - // SAFETY: `self.as_raw()` is valid by the type invariants. For a valid interface,
> - // the helper should always return a valid USB device pointer.
> - let usb_dev = unsafe { bindings::interface_to_usbdev(self.as_raw()) };
> -
> - // SAFETY: The helper returns a valid interface pointer that shares the
> - // same `DeviceContext`.
> - unsafe { &*(usb_dev.cast()) }
> - }
> -}
> -
> // SAFETY: Instances of `Interface` are always reference-counted.
> unsafe impl AlwaysRefCounted for Interface {
> fn inc_ref(&self) {
Cool, I'll be glad to apply this, can you resend it with a real
signed-off-by line?
And we can always submit fixes during the -rc cycle for 6.18, for stuff
like this, so there's no immediate rush at the moment to get this
"perfect".
thanks,
greg k-h
Powered by blists - more mailing lists