From: sashiko-bot@kernel.org
To: "Maurice Hieronymus" <mhi@mailbox.org>,
"Danilo Krummrich" <dakr@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Lyude Paul" <lyude@redhat.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>
Cc: "John Hubbard" <jhubbard@nvidia.com>,
linux-pci@vger.kernel.org, nova-gpu@lists.linux.dev,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v4 2/7] rust: pci: rework device enabling API
Date: Wed, 04 Nov 2026 23:14:25 +0000 [thread overview]
Message-ID: <sashiko-outbox-198281@kernel.org> (raw)
In-Reply-To: <20261105-b4-rust-pci-edu-driver-v4-2-20ef027bb707@mailbox.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] rust: pci: missing #[inline] on DeviceEnableGuard::drop()
--
commit 74e19693f9a2d2ce6a2ed986dc5fdc9a88535014
Author: Maurice Hieronymus <mhi@mailbox.org>
rust: pci: rework device enabling API
This commit replaces Device::enable_device_mem() with
Device::enable_device(), returning a DeviceEnableGuard<'a> that calls
pci_disable_device() on drop to keep the PCI device enable count balanced.
It also updates the nova-core driver to store the guard in NovaCore.
Link: https://lore.kernel.org/rust-for-linux/DJOEYVBS17MJ.1YD3TNGQBWHNK@kernel.org
> diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
> index 769d01d234296..75efd5c5ee97f 100644
> --- a/rust/kernel/pci.rs
> +++ b/rust/kernel/pci.rs
> @@ -469,6 +469,25 @@ pub fn pci_class(&self) -> Class {
> }
> }
>
> +/// A guard that keeps the device's I/O and memory resources enabled.
> +///
> +/// # Invariants
> +///
> +/// The device's enable count was incremented once for this guard; dropping the guard decrements
> +/// it again.
> +#[must_use = "if unused, the device will be immediately disabled"]
> +pub struct DeviceEnableGuard<'a> {
> + dev: &'a Device<device::Bound>,
> +}
> +
> +impl Drop for DeviceEnableGuard<'_> {
> + fn drop(&mut self) {
> + // SAFETY: `self.dev.as_raw()` is a valid pointer to a `struct pci_dev`, and by the type
> + // invariant this guard holds one increment of the device's enable count.
> + unsafe { bindings::pci_disable_device(self.dev.as_raw()) };
> + }
> +}
[Severity: Low]
This isn't a bug, but since DeviceEnableGuard::drop() in rust/kernel/pci.rs
is a small non-generic abstraction method in the kernel crate that forwards
directly to bindings::pci_disable_device() when a DeviceEnableGuard is
dropped on driver unbind or probe error unwind, should it be marked with
#[inline] to allow cross-crate inlining into drivers (matching
Device::enable_device() below and IrqVectorRegistration::drop() in
rust/kernel/pci/irq.rs)?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-b4-rust-pci-edu-driver-v4-0-20ef027bb707@mailbox.org?part=2
next prev parent reply other threads:[~2026-11-04 23:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 23:05 [PATCH v4 0/7] samples: rust: add an EDU PCI driver sample (MMIO + IRQ + DMA) Maurice Hieronymus
2026-11-04 23:05 ` [PATCH v4 1/7] samples: rust: remove the rust_driver_pci sample Maurice Hieronymus
2026-11-04 23:09 ` sashiko-bot
2026-11-04 23:05 ` [PATCH v4 2/7] rust: pci: rework device enabling API Maurice Hieronymus
2026-11-04 23:14 ` sashiko-bot [this message]
2026-11-04 23:05 ` [PATCH v4 3/7] rust: pci: require an enable guard for `set_master()` Maurice Hieronymus
2026-11-04 23:11 ` sashiko-bot
2026-11-04 23:05 ` [PATCH v4 4/7] PCI: Add QEMU vendor ID Maurice Hieronymus
2026-11-04 23:09 ` sashiko-bot
2026-11-04 23:05 ` [PATCH v4 5/7] rust: pci: add Vendor::QEMU Maurice Hieronymus
2026-11-04 23:09 ` sashiko-bot
2026-11-04 23:05 ` [PATCH v4 6/7] rust: completion: add complete() Maurice Hieronymus
2026-11-04 23:11 ` sashiko-bot
2026-11-04 23:05 ` [PATCH v4 7/7] samples: rust: add EDU PCI driver sample Maurice Hieronymus
2026-11-04 23:14 ` sashiko-bot
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=sashiko-outbox-198281@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=jhubbard@nvidia.com \
--cc=kwilczynski@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=mhi@mailbox.org \
--cc=nova-gpu@lists.linux.dev \
--cc=ojeda@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=simona@ffwll.ch \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/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