* Re: [PATCH] usb: rust: mark Device and Interface methods as inline
2026-06-16 22:36 [PATCH] usb: rust: mark Device and Interface methods as inline Nicolás Antinori
@ 2026-06-17 3:18 ` Daniel Almeida
2026-06-17 7:35 ` Alice Ryhl
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Daniel Almeida @ 2026-06-17 3:18 UTC (permalink / raw)
To: Nicolás Antinori
Cc: Miguel Ojeda, Alexandre Courbot, Alice Ryhl, Andreas Hindborg,
Benno Lossin, Björn Roy Baron, Boqun Feng, Danilo Krummrich,
Gary Guo, Onur Özkan, Shuah Khan, Tamir Duberstein,
Trevor Gross, linux-kernel, rust-for-linux, linux-kernel-mentees
> On 16 Jun 2026, at 19:36, Nicolás Antinori <nico.antinori.7@gmail.com> wrote:
>
> When building the kernel using llvm-19.1.7-rust-1.85.1-x86_64, the
> following symbols are generated:
>
> $ nm vmlinux | grep ' _R'.*usb.*Device | rustfilt
> ...
> ffffffff823f2490 T <kernel::usb::Device as kernel::sync::aref::AlwaysRefCounted>::dec_ref
> ffffffff823f2470 T <kernel::usb::Device as kernel::sync::aref::AlwaysRefCounted>::inc_ref
> ...
>
> $ nm vmlinux | grep ' _R'.*usb.*Interface | rustfilt
> ffffffff823f2450 T <kernel::usb::Interface as kernel::sync::aref::AlwaysRefCounted>::dec_ref
> ffffffff823f2430 T <kernel::usb::Interface as kernel::sync::aref::AlwaysRefCounted>::inc_ref
> ...
>
> However, these Rust symbols are trivial wrappers around the
> `usb_get_dev`, `usb_put_dev`, `usb_get_intf` and `usb_put_intf`
> functions. It doesn't make sense to go through a trivial wrapper
> for these functions.
>
> Link: https://github.com/Rust-for-Linux/linux/issues/1145
> Suggested-by: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com>
> ---
> rust/kernel/usb.rs | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/rust/kernel/usb.rs b/rust/kernel/usb.rs
> index 7aff0c82d0af..efbbee319b1a 100644
> --- a/rust/kernel/usb.rs
> +++ b/rust/kernel/usb.rs
> @@ -393,6 +393,7 @@ fn as_ref(&self) -> &Device {
>
> // SAFETY: Instances of `Interface` are always reference-counted.
> unsafe impl AlwaysRefCounted for Interface {
> + #[inline]
> fn inc_ref(&self) {
> // SAFETY: The invariants of `Interface` guarantee that `self.as_raw()`
> // returns a valid `struct usb_interface` pointer, for which we will
> @@ -400,6 +401,7 @@ fn inc_ref(&self) {
> unsafe { bindings::usb_get_intf(self.as_raw()) };
> }
>
> + #[inline]
> unsafe fn dec_ref(obj: NonNull<Self>) {
> // SAFETY: The safety requirements guarantee that the refcount is non-zero.
> unsafe { bindings::usb_put_intf(obj.cast().as_ptr()) }
> @@ -444,6 +446,7 @@ fn as_raw(&self) -> *mut bindings::usb_device {
>
> // SAFETY: Instances of `Device` are always reference-counted.
> unsafe impl AlwaysRefCounted for Device {
> + #[inline]
> fn inc_ref(&self) {
> // SAFETY: The invariants of `Device` guarantee that `self.as_raw()`
> // returns a valid `struct usb_device` pointer, for which we will
> @@ -451,6 +454,7 @@ fn inc_ref(&self) {
> unsafe { bindings::usb_get_dev(self.as_raw()) };
> }
>
> + #[inline]
> unsafe fn dec_ref(obj: NonNull<Self>) {
> // SAFETY: The safety requirements guarantee that the refcount is non-zero.
> unsafe { bindings::usb_put_dev(obj.cast().as_ptr()) }
> --
> 2.47.3
>
>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] usb: rust: mark Device and Interface methods as inline
2026-06-16 22:36 [PATCH] usb: rust: mark Device and Interface methods as inline Nicolás Antinori
2026-06-17 3:18 ` Daniel Almeida
@ 2026-06-17 7:35 ` Alice Ryhl
2026-06-17 14:10 ` Gary Guo
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Alice Ryhl @ 2026-06-17 7:35 UTC (permalink / raw)
To: Nicolás Antinori
Cc: Miguel Ojeda, Alexandre Courbot, Andreas Hindborg, Benno Lossin,
Björn Roy Baron, Boqun Feng, Daniel Almeida,
Danilo Krummrich, Gary Guo, Onur Özkan, Shuah Khan,
Tamir Duberstein, Trevor Gross, linux-kernel, rust-for-linux,
linux-kernel-mentees
On Tue, Jun 16, 2026 at 07:36:06PM -0300, Nicolás Antinori wrote:
> When building the kernel using llvm-19.1.7-rust-1.85.1-x86_64, the
> following symbols are generated:
>
> $ nm vmlinux | grep ' _R'.*usb.*Device | rustfilt
> ...
> ffffffff823f2490 T <kernel::usb::Device as kernel::sync::aref::AlwaysRefCounted>::dec_ref
> ffffffff823f2470 T <kernel::usb::Device as kernel::sync::aref::AlwaysRefCounted>::inc_ref
> ...
>
> $ nm vmlinux | grep ' _R'.*usb.*Interface | rustfilt
> ffffffff823f2450 T <kernel::usb::Interface as kernel::sync::aref::AlwaysRefCounted>::dec_ref
> ffffffff823f2430 T <kernel::usb::Interface as kernel::sync::aref::AlwaysRefCounted>::inc_ref
> ...
>
> However, these Rust symbols are trivial wrappers around the
> `usb_get_dev`, `usb_put_dev`, `usb_get_intf` and `usb_put_intf`
> functions. It doesn't make sense to go through a trivial wrapper
> for these functions.
>
> Link: https://github.com/Rust-for-Linux/linux/issues/1145
> Suggested-by: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] usb: rust: mark Device and Interface methods as inline
2026-06-16 22:36 [PATCH] usb: rust: mark Device and Interface methods as inline Nicolás Antinori
2026-06-17 3:18 ` Daniel Almeida
2026-06-17 7:35 ` Alice Ryhl
@ 2026-06-17 14:10 ` Gary Guo
2026-06-17 14:39 ` Miguel Ojeda
2026-06-17 15:34 ` Danilo Krummrich
4 siblings, 0 replies; 7+ messages in thread
From: Gary Guo @ 2026-06-17 14:10 UTC (permalink / raw)
To: Nicolás Antinori, Miguel Ojeda
Cc: Alexandre Courbot, Alice Ryhl, Andreas Hindborg, Benno Lossin,
Björn Roy Baron, Boqun Feng, Daniel Almeida,
Danilo Krummrich, Gary Guo, Onur Özkan, Shuah Khan,
Tamir Duberstein, Trevor Gross, linux-kernel, rust-for-linux,
linux-kernel-mentees
On Tue Jun 16, 2026 at 11:36 PM BST, Nicolás Antinori wrote:
> When building the kernel using llvm-19.1.7-rust-1.85.1-x86_64, the
> following symbols are generated:
>
> $ nm vmlinux | grep ' _R'.*usb.*Device | rustfilt
> ...
> ffffffff823f2490 T <kernel::usb::Device as kernel::sync::aref::AlwaysRefCounted>::dec_ref
> ffffffff823f2470 T <kernel::usb::Device as kernel::sync::aref::AlwaysRefCounted>::inc_ref
> ...
>
> $ nm vmlinux | grep ' _R'.*usb.*Interface | rustfilt
> ffffffff823f2450 T <kernel::usb::Interface as kernel::sync::aref::AlwaysRefCounted>::dec_ref
> ffffffff823f2430 T <kernel::usb::Interface as kernel::sync::aref::AlwaysRefCounted>::inc_ref
> ...
>
> However, these Rust symbols are trivial wrappers around the
> `usb_get_dev`, `usb_put_dev`, `usb_get_intf` and `usb_put_intf`
> functions. It doesn't make sense to go through a trivial wrapper
> for these functions.
>
> Link: https://github.com/Rust-for-Linux/linux/issues/1145
> Suggested-by: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
> ---
> rust/kernel/usb.rs | 4 ++++
> 1 file changed, 4 insertions(+)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] usb: rust: mark Device and Interface methods as inline
2026-06-16 22:36 [PATCH] usb: rust: mark Device and Interface methods as inline Nicolás Antinori
` (2 preceding siblings ...)
2026-06-17 14:10 ` Gary Guo
@ 2026-06-17 14:39 ` Miguel Ojeda
2026-06-17 15:34 ` Danilo Krummrich
4 siblings, 0 replies; 7+ messages in thread
From: Miguel Ojeda @ 2026-06-17 14:39 UTC (permalink / raw)
To: Nicolás Antinori
Cc: Miguel Ojeda, Alexandre Courbot, Alice Ryhl, Andreas Hindborg,
Benno Lossin, Björn Roy Baron, Boqun Feng, Daniel Almeida,
Danilo Krummrich, Gary Guo, Onur Özkan, Shuah Khan,
Tamir Duberstein, Trevor Gross, linux-kernel, rust-for-linux,
linux-kernel-mentees
On Wed, Jun 17, 2026 at 12:36 AM Nicolás Antinori
<nico.antinori.7@gmail.com> wrote:
>
> When building the kernel using llvm-19.1.7-rust-1.85.1-x86_64, the
> following symbols are generated:
>
> $ nm vmlinux | grep ' _R'.*usb.*Device | rustfilt
> ...
> ffffffff823f2490 T <kernel::usb::Device as kernel::sync::aref::AlwaysRefCounted>::dec_ref
> ffffffff823f2470 T <kernel::usb::Device as kernel::sync::aref::AlwaysRefCounted>::inc_ref
> ...
>
> $ nm vmlinux | grep ' _R'.*usb.*Interface | rustfilt
> ffffffff823f2450 T <kernel::usb::Interface as kernel::sync::aref::AlwaysRefCounted>::dec_ref
> ffffffff823f2430 T <kernel::usb::Interface as kernel::sync::aref::AlwaysRefCounted>::inc_ref
> ...
>
> However, these Rust symbols are trivial wrappers around the
> `usb_get_dev`, `usb_put_dev`, `usb_get_intf` and `usb_put_intf`
> functions. It doesn't make sense to go through a trivial wrapper
> for these functions.
>
> Link: https://github.com/Rust-for-Linux/linux/issues/1145
> Suggested-by: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com>
Looks good, thanks -- I can pick this up, unless USB wants to route it
differently.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] usb: rust: mark Device and Interface methods as inline
2026-06-16 22:36 [PATCH] usb: rust: mark Device and Interface methods as inline Nicolás Antinori
` (3 preceding siblings ...)
2026-06-17 14:39 ` Miguel Ojeda
@ 2026-06-17 15:34 ` Danilo Krummrich
2026-06-17 15:39 ` Greg Kroah-Hartman
4 siblings, 1 reply; 7+ messages in thread
From: Danilo Krummrich @ 2026-06-17 15:34 UTC (permalink / raw)
To: Nicolás Antinori, Greg Kroah-Hartman
Cc: Miguel Ojeda, Alexandre Courbot, Alice Ryhl, Andreas Hindborg,
Benno Lossin, Björn Roy Baron, Boqun Feng, Daniel Almeida,
Gary Guo, Onur Özkan, Shuah Khan, Tamir Duberstein,
Trevor Gross, linux-kernel, rust-for-linux, linux-kernel-mentees,
linux-usb
(Cc: Greg, linux-usb)
Looks like the Rust USB code wasn't added to the USB MAINTAINERS entry.
On Wed Jun 17, 2026 at 12:36 AM CEST, Nicolás Antinori wrote:
> When building the kernel using llvm-19.1.7-rust-1.85.1-x86_64, the
> following symbols are generated:
>
> $ nm vmlinux | grep ' _R'.*usb.*Device | rustfilt
> ...
> ffffffff823f2490 T <kernel::usb::Device as kernel::sync::aref::AlwaysRefCounted>::dec_ref
> ffffffff823f2470 T <kernel::usb::Device as kernel::sync::aref::AlwaysRefCounted>::inc_ref
> ...
>
> $ nm vmlinux | grep ' _R'.*usb.*Interface | rustfilt
> ffffffff823f2450 T <kernel::usb::Interface as kernel::sync::aref::AlwaysRefCounted>::dec_ref
> ffffffff823f2430 T <kernel::usb::Interface as kernel::sync::aref::AlwaysRefCounted>::inc_ref
> ...
>
> However, these Rust symbols are trivial wrappers around the
> `usb_get_dev`, `usb_put_dev`, `usb_get_intf` and `usb_put_intf`
> functions. It doesn't make sense to go through a trivial wrapper
> for these functions.
>
> Link: https://github.com/Rust-for-Linux/linux/issues/1145
> Suggested-by: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] usb: rust: mark Device and Interface methods as inline
2026-06-17 15:34 ` Danilo Krummrich
@ 2026-06-17 15:39 ` Greg Kroah-Hartman
0 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2026-06-17 15:39 UTC (permalink / raw)
To: Danilo Krummrich
Cc: Nicolás Antinori, Miguel Ojeda, Alexandre Courbot,
Alice Ryhl, Andreas Hindborg, Benno Lossin, Björn Roy Baron,
Boqun Feng, Daniel Almeida, Gary Guo, Onur Özkan, Shuah Khan,
Tamir Duberstein, Trevor Gross, linux-kernel, rust-for-linux,
linux-kernel-mentees, linux-usb
On Wed, Jun 17, 2026 at 05:34:02PM +0200, Danilo Krummrich wrote:
> (Cc: Greg, linux-usb)
>
> Looks like the Rust USB code wasn't added to the USB MAINTAINERS entry.
Yeah, we should fix that. As it didn't actually work I wasn't too
worried about it yet :)
I'll knock up a patch later this week.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread