Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Zhi Wang" <zhiw@nvidia.com>
Cc: linux-pci@vger.kernel.org, ojeda@kernel.org, gary@garyguo.net
Subject: Re: [PATCH v4 1/9] rust: pci: add internal SR-IOV enable and disable helpers
Date: Sun, 04 Oct 2026 12:14:11 +0000	[thread overview]
Message-ID: <20261004121411.86DF31F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261004120732.1045629-2-zhiw@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] rust: pci: missing #[inline] on abstraction functions forwarding to C bindings
--

commit c316165d2a3f7f2b9498fa8f5fcc7616b0e3fb32
Author: Peter Colberg <peter@colberg.org>

rust: pci: add internal SR-IOV enable and disable helpers

This commit wraps pci_enable_sriov() and pci_disable_sriov() on
Device<CoreInternal> for use by SR-IOV callback tokens. These operations
are kept internal to ensure drivers can only modify VFs through the
callback-scoped API.

> diff --git a/rust/kernel/pci/iov.rs b/rust/kernel/pci/iov.rs
> new file mode 100644
> index 0000000000000..1af5bdc198302
> --- /dev/null
> +++ b/rust/kernel/pci/iov.rs
[ ... ]
> +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: u16) -> Result {

[Severity: Low]
This isn't a bug, but does this abstraction method miss an inline annotation?
The Rust subsystem guidelines specify that functions forwarding to a C binding
call in the kernel crate should be annotated with inline to allow for
compiler optimization.

> +        // SAFETY:
[ ... ]
> +        // - The [`CoreInternal`] device context inherits from the [`Bound`] device context,
> +        //   which guarantees that the PF device is bound to a driver.
> +        to_result(unsafe { bindings::pci_enable_sriov(self.as_raw(), nr_virtfn.into()) })
> +    }
> +
> +    /// Disable the Single Root I/O Virtualization (SR-IOV) capability for this device.
> +    #[expect(dead_code)]
> +    pub(crate) fn disable_sriov(&self) {

[Severity: Low]
Similarly, should this method also include an inline annotation since it
directly forwards to the pci_disable_sriov C binding?

> +        // SAFETY:
[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261004120732.1045629-1-zhiw@nvidia.com?part=1

  reply	other threads:[~2026-10-04 12:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-04 12:07 [PATCH v4 0/9] Add Rust PCI SR-IOV support Zhi Wang
2026-10-04 12:07 ` [PATCH v4 1/9] rust: pci: add internal SR-IOV enable and disable helpers Zhi Wang
2026-10-04 12:14   ` sashiko-bot [this message]
2026-10-04 12:07 ` [PATCH v4 2/9] rust: pci: add vtable attribute to pci::Driver trait Zhi Wang
2026-10-04 12:12   ` sashiko-bot
2026-10-04 12:07 ` [PATCH v4 3/9] rust: pci: add is_virtfn(), to check for VFs Zhi Wang
2026-10-04 12:17   ` sashiko-bot
2026-10-04 12:07 ` [PATCH v4 4/9] rust: pci: add num_vf(), to return number of VFs Zhi Wang
2026-10-04 12:15   ` sashiko-bot
2026-10-04 12:07 ` [PATCH v4 5/9] rust: pci: drop driver data before remove returns Zhi Wang
2026-10-04 12:15   ` sashiko-bot
2026-10-04 12:07 ` [PATCH v4 6/9] rust: pci: add typed SR-IOV PF registration data Zhi Wang
2026-10-04 12:20   ` sashiko-bot
2026-10-04 12:07 ` [PATCH v4 7/9] rust: pci: add SR-IOV enable and disable tokens Zhi Wang
2026-10-04 12:17   ` sashiko-bot
2026-10-04 12:07 ` [PATCH v4 8/9] rust: pci: add SR-IOV enable and disable callbacks Zhi Wang
2026-10-04 12:22   ` sashiko-bot
2026-10-04 12:07 ` [PATCH v4 9/9] samples: rust: add Rust SR-IOV PF and VF driver samples Zhi Wang
2026-10-04 12:17   ` 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=20261004121411.86DF31F000FF@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox