From: sashiko-bot@kernel.org
To: "Zhi Wang" <zhiw@nvidia.com>
Cc: ojeda@kernel.org, linux-pci@vger.kernel.org, gary@garyguo.net
Subject: Re: [PATCH v3 01/10] rust: pci: add internal SR-IOV enable and disable helpers
Date: Wed, 30 Sep 2026 10:34:53 +0000 [thread overview]
Message-ID: <20260930103500.C5C401F000FF@smtp.kernel.org> (raw)
In-Reply-To: <af34ce6151b5be98668d712fbe62b5d6af291770.1790759932.git.zhiw@nvidia.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] rust: conditional compilation gap for SR-IOV API forcing downstream #cfg usage
- [Low] rust: missing #[inline] on abstraction functions forwarding to C bindings
--
commit 3f2a7b7fc60a2b23673b53641eba3ae3ba445ce8
Author: Peter Colberg <peter@colberg.org>
rust: pci: add internal SR-IOV enable and disable helpers
Wrap pci_enable_sriov() and pci_disable_sriov() on Device<CoreInternal>
for use by the SR-IOV callback tokens and their rollback guard.
Keep these operations internal so drivers can only enable or disable
VFs through the callback-scoped API introduced later in this series.
> diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
> index 3ec897709e890..b11a1d32c5db5 100644
> --- a/rust/kernel/pci.rs
> +++ b/rust/kernel/pci.rs
> @@ -34,6 +34,8 @@
>
> mod id;
> mod io;
> +#[cfg(CONFIG_PCI_IOV)]
> +mod iov;
[Severity: Medium]
Does hiding the `iov` module unconditionally when `CONFIG_PCI_IOV` is disabled
break downstream driver compilation?
By gating the `iov` module behind `#[cfg(CONFIG_PCI_IOV)]`, this cascades into
missing types (`SriovEnable`) and trait methods (`Driver::sriov_enable`). This
forces Rust driver developers to either pollute their code with
`#[cfg(CONFIG_PCI_IOV)]` on trait methods or add `depends on PCI_IOV` to their
Kconfig to avoid compilation failures.
In the C PCI subsystem, `.sriov_configure` and `pci_enable_sriov()` are
unconditionally available and fall back to static inlines returning `-ENODEV`
when disabled, allowing drivers to compile seamlessly without `#ifdef`s.
Could we provide `!CONFIG_PCI_IOV` helpers in `rust/helpers/pci.c` to maintain
C parity and avoid breaking valid Kconfig combinations?
> mod irq;
>
> pub use self::id::{
> diff --git a/rust/kernel/pci/iov.rs b/rust/kernel/pci/iov.rs
> new file mode 100644
> index 0000000000000..c37ce51346731
> --- /dev/null
> +++ b/rust/kernel/pci/iov.rs
> @@ -0,0 +1,46 @@
[ ... ]
> +impl Device<device::CoreInternal<'_>> {
> + /// Enable the Single Root I/O Virtualization (SR-IOV) capability for this device,
> + /// where `nr_virtfn` is number of Virtual Functions (VF) to enable.
> + #[expect(dead_code)]
> + pub(crate) fn enable_sriov(&self, nr_virtfn: c_int) -> Result {
[Severity: Low]
This isn't a bug, but should this function have an `#[inline]` annotation?
The rust.md guidelines recommend that small functions or functions forwarding
to a C binding call in abstractions (like the `kernel` crate) be annotated
with `#[inline]`. `enable_sriov()` directly forwards to
`bindings::pci_enable_sriov`.
> + // SAFETY:
[ ... ]
> + to_result(unsafe { bindings::pci_enable_sriov(self.as_raw(), nr_virtfn) })
> + }
> +
> + /// Disable the Single Root I/O Virtualization (SR-IOV) capability for this device.
> + #[expect(dead_code)]
> + pub(crate) fn disable_sriov(&self) {
[Severity: Low]
This isn't a bug, but should this function also have an `#[inline]`
annotation?
Similar to `enable_sriov()`, `disable_sriov()` directly forwards to
`bindings::pci_disable_sriov` and lacks the `#[inline]` annotation
recommended for abstraction methods.
> + // SAFETY:
[ ... ]
> + unsafe { bindings::pci_disable_sriov(self.as_raw()) };
> + }
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1790705494.git.zhiw@nvidia.com?part=1
next prev parent reply other threads:[~2026-09-30 10:35 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 10:18 [PATCH v3 00/10] Add Rust PCI SR-IOV support Zhi Wang
2026-09-30 10:18 ` [PATCH v3 01/10] rust: pci: add internal SR-IOV enable and disable helpers Zhi Wang
2026-09-30 10:34 ` sashiko-bot [this message]
2026-09-30 10:58 ` Danilo Krummrich
2026-09-30 10:18 ` [PATCH v3 02/10] rust: pci: add vtable attribute to pci::Driver trait Zhi Wang
2026-09-30 10:36 ` sashiko-bot
2026-09-30 10:18 ` [PATCH v3 03/10] rust: pci: add is_virtfn(), to check for VFs Zhi Wang
2026-09-30 10:34 ` sashiko-bot
2026-09-30 10:18 ` [PATCH v3 04/10] rust: pci: add is_physfn(), to check for PFs Zhi Wang
2026-09-30 10:30 ` sashiko-bot
2026-09-30 10:18 ` [PATCH v3 05/10] rust: pci: add num_vf(), to return number of VFs Zhi Wang
2026-09-30 10:32 ` sashiko-bot
2026-09-30 11:13 ` Danilo Krummrich
2026-10-03 17:12 ` Zhi Wang
2026-09-30 10:18 ` [PATCH v3 06/10] rust: pci: drop driver data before remove returns Zhi Wang
2026-09-30 10:35 ` sashiko-bot
2026-09-30 10:18 ` [PATCH v3 07/10] rust: pci: add typed SR-IOV PF registration data Zhi Wang
2026-09-30 10:36 ` sashiko-bot
2026-09-30 13:59 ` Danilo Krummrich
2026-10-04 6:07 ` Zhi Wang
2026-09-30 10:18 ` [PATCH v3 08/10] rust: pci: add SR-IOV enable and disable tokens Zhi Wang
2026-09-30 10:37 ` sashiko-bot
2026-09-30 14:25 ` Danilo Krummrich
2026-10-04 6:16 ` Zhi Wang
2026-09-30 10:18 ` [PATCH v3 09/10] rust: pci: add SR-IOV enable and disable callbacks Zhi Wang
2026-09-30 10:37 ` sashiko-bot
2026-09-30 14:46 ` Danilo Krummrich
2026-09-30 10:18 ` [PATCH v3 10/10] samples: rust: add Rust SR-IOV VF driver sample Zhi Wang
2026-09-30 10:46 ` sashiko-bot
2026-09-30 15:15 ` Danilo Krummrich
2026-10-04 6:21 ` Zhi Wang
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=20260930103500.C5C401F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=gary@garyguo.net \
--cc=linux-pci@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zhiw@nvidia.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.