* [PATCH] rust: pci: Mark Device refcount methods inline
@ 2026-08-04 23:24 Ethan Plant via B4 Relay
2026-08-05 7:52 ` Alice Ryhl
2026-08-06 21:31 ` Danilo Krummrich
0 siblings, 2 replies; 3+ messages in thread
From: Ethan Plant via B4 Relay @ 2026-08-04 23:24 UTC (permalink / raw)
To: Danilo Krummrich, Bjorn Helgaas, Krzysztof Wilczyński,
Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
Onur Özkan
Cc: linux-pci, rust-for-linux, linux-kernel, Ethan Plant
From: Ethan Plant <plant.ethan@gmail.com>
When building the kernel, the following Rust symbols are generated:
$ nm vmlinux | grep ' _R' | rustfilt | grep -E 'pci::Device.*(inc_ref|dec_ref)'
... T <kernel::pci::Device as kernel::sync::aref::AlwaysRefCounted>::dec_ref
... T <kernel::pci::Device as kernel::sync::aref::AlwaysRefCounted>::inc_ref
These Rust symbols are trivial wrappers around pci_dev_put() and
pci_dev_get(), respectively. It doesn't make sense to go through a
trivial wrapper for these functions, so mark them inline.
Suggested-by: Alice Ryhl <aliceryhl@google.com>
Link: https://github.com/Rust-for-Linux/linux/issues/1145
Signed-off-by: Ethan Plant <plant.ethan@gmail.com>
---
rust/kernel/pci.rs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
index 5071cae6543f..3e80ec1160b3 100644
--- a/rust/kernel/pci.rs
+++ b/rust/kernel/pci.rs
@@ -482,11 +482,13 @@ impl<'a> crate::dma::Device<'a> for Device<device::Core<'a>> {}
// SAFETY: Instances of `Device` are always reference-counted.
unsafe impl crate::sync::aref::AlwaysRefCounted for Device {
+ #[inline]
fn inc_ref(&self) {
// SAFETY: The existence of a shared reference guarantees that the refcount is non-zero.
unsafe { bindings::pci_dev_get(self.as_raw()) };
}
+ #[inline]
unsafe fn dec_ref(obj: NonNull<Self>) {
// SAFETY: The safety requirements guarantee that the refcount is non-zero.
unsafe { bindings::pci_dev_put(obj.cast().as_ptr()) }
---
base-commit: dc01dfb37b34beeefcfe1c3055364d41a4070c7e
change-id: 20260804-inline-wrappers-f869b6e4601e
Best regards,
--
Ethan Plant <plant.ethan@gmail.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] rust: pci: Mark Device refcount methods inline
2026-08-04 23:24 [PATCH] rust: pci: Mark Device refcount methods inline Ethan Plant via B4 Relay
@ 2026-08-05 7:52 ` Alice Ryhl
2026-08-06 21:31 ` Danilo Krummrich
1 sibling, 0 replies; 3+ messages in thread
From: Alice Ryhl @ 2026-08-05 7:52 UTC (permalink / raw)
To: plant.ethan
Cc: Danilo Krummrich, Bjorn Helgaas, Krzysztof Wilczyński,
Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Daniel Almeida,
Tamir Duberstein, Alexandre Courbot, Onur Özkan, linux-pci,
rust-for-linux, linux-kernel
On Wed, Aug 5, 2026 at 1:24 AM Ethan Plant via B4 Relay
<devnull+plant.ethan.gmail.com@kernel.org> wrote:
>
> From: Ethan Plant <plant.ethan@gmail.com>
>
> When building the kernel, the following Rust symbols are generated:
> $ nm vmlinux | grep ' _R' | rustfilt | grep -E 'pci::Device.*(inc_ref|dec_ref)'
> ... T <kernel::pci::Device as kernel::sync::aref::AlwaysRefCounted>::dec_ref
> ... T <kernel::pci::Device as kernel::sync::aref::AlwaysRefCounted>::inc_ref
>
> These Rust symbols are trivial wrappers around pci_dev_put() and
> pci_dev_get(), respectively. It doesn't make sense to go through a
> trivial wrapper for these functions, so mark them inline.
>
> Suggested-by: Alice Ryhl <aliceryhl@google.com>
> Link: https://github.com/Rust-for-Linux/linux/issues/1145
> Signed-off-by: Ethan Plant <plant.ethan@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rust: pci: Mark Device refcount methods inline
2026-08-04 23:24 [PATCH] rust: pci: Mark Device refcount methods inline Ethan Plant via B4 Relay
2026-08-05 7:52 ` Alice Ryhl
@ 2026-08-06 21:31 ` Danilo Krummrich
1 sibling, 0 replies; 3+ messages in thread
From: Danilo Krummrich @ 2026-08-06 21:31 UTC (permalink / raw)
To: Ethan Plant
Cc: Danilo Krummrich, Bjorn Helgaas, Krzysztof Wilczyński,
Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
Onur Özkan, linux-pci, rust-for-linux, linux-kernel
On Tue, 04 Aug 2026 16:24:25 -0700, Ethan Plant wrote:
> [PATCH] rust: pci: Mark Device refcount methods inline
Applied, thanks!
Branch: driver-core-testing
Tree: git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git
[1/1] rust: pci: Mark Device refcount methods inline
commit: 56c193a5cb37
The patch will appear in the next linux-next integration (typically within 24
hours on weekdays).
The patch is in the driver-core-testing branch and will be promoted to
driver-core-next after validation.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-06 21:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-04 23:24 [PATCH] rust: pci: Mark Device refcount methods inline Ethan Plant via B4 Relay
2026-08-05 7:52 ` Alice Ryhl
2026-08-06 21:31 ` Danilo Krummrich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox