From: "Danilo Krummrich" <dakr@kernel.org>
To: "Zhi Wang" <zhiw@nvidia.com>
Cc: rust-for-linux@vger.kernel.org, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org, aliceryhl@google.com,
bhelgaas@google.com, kwilczynski@kernel.org, ojeda@kernel.org,
boqun@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com,
lossin@kernel.org, a.hindborg@kernel.org, tmgross@umich.edu,
markus.probst@posteo.de, cjia@nvidia.com, smitra@nvidia.com,
ankita@nvidia.com, aniketa@nvidia.com, kwankhede@nvidia.com,
targupta@nvidia.com, kjaju@nvidia.com, alkumar@nvidia.com,
acourbot@nvidia.com, jhubbard@nvidia.com, zhiwang@kernel.org,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Subject: Re: [PATCH v10 1/1] rust: pci: add extended capability and SR-IOV support
Date: Wed, 30 Sep 2026 22:34:27 +0200 [thread overview]
Message-ID: <DLSXS9MO4YW5.2YLITM1OJ7P0P@kernel.org> (raw)
In-Reply-To: <20260906060404.3336193-2-zhiw@nvidia.com>
On Sun Sep 6, 2026 at 8:04 AM CEST, Zhi Wang wrote:
> + pub fn vf_bars(&self) -> Result<impl Iterator<Item = ExtSriovVfBar>> {
> + let slots: [u32; NUM_VF_BARS] =
> + core::array::from_fn(|slot| crate::io_read!(*self, .vf_bar[panic: slot]));
> + let mut slots = slots.into_iter();
> + let mut bars = [None; NUM_VF_BARS];
> + let mut count = 0;
> +
> + let mut decode = || {
> + while let Some(low) = slots.next().map(BarLow::from) {
> + // SR-IOV VF BARs describe memory-space apertures; an I/O-space encoding is not
> + // valid for these registers.
> + if low.io_space() {
> + return Err(EINVAL);
> + }
> +
> + let low_address = u64::from(low.address()) << BarLow::ADDRESS_SHIFT;
> + let bar = match low.memory_type()? {
> + BarMemoryType::Bits64 => ExtSriovVfBar {
> + address: (u64::from(slots.next().ok_or(EINVAL)?) << 32) | low_address,
> + is_64bit: true,
> + },
> + BarMemoryType::Bits32 => ExtSriovVfBar {
> + address: low_address,
> + is_64bit: false,
> + },
> + };
> +
> + bars[count] = Some(bar);
> + count += 1;
> + }
> +
> + Ok(())
> + };
> +
> + decode().inspect_err(|_| {
> + dev_err!(self.pdev, "invalid VF BAR encoding in SR-IOV capability\n");
> + })?;
> + Ok(bars.into_iter().flatten())
> + }
I don't mind too much, but can you please remind me why we decode the VF BAR
registers and can't use the PCI core's VF resource information instead?
(I gave it a very quick try and using pci_bus_address() and pci_resource_flags()
actually turned out worse, but that could be me spending less than 5 minutes on
it. :)
prev parent reply other threads:[~2026-09-30 20:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 6:04 [PATCH v10 0/1] Rust PCI capability infrastructure and SR-IOV support Zhi Wang
2026-09-06 6:04 ` [PATCH v10 1/1] rust: pci: add extended capability " Zhi Wang
2026-09-06 6:13 ` sashiko-bot
2026-09-30 20:34 ` Danilo Krummrich [this message]
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=DLSXS9MO4YW5.2YLITM1OJ7P0P@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=alkumar@nvidia.com \
--cc=aniketa@nvidia.com \
--cc=ankita@nvidia.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=cjia@nvidia.com \
--cc=gary@garyguo.net \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jhubbard@nvidia.com \
--cc=kjaju@nvidia.com \
--cc=kwankhede@nvidia.com \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=markus.probst@posteo.de \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=smitra@nvidia.com \
--cc=targupta@nvidia.com \
--cc=tmgross@umich.edu \
--cc=zhiw@nvidia.com \
--cc=zhiwang@kernel.org \
/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.