[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251031141611.669c5380.zhiw@nvidia.com>
Date: Fri, 31 Oct 2025 14:16:11 +0200
From: Zhi Wang <zhiw@...dia.com>
To: Bjorn Helgaas <helgaas@...nel.org>
CC: <rust-for-linux@...r.kernel.org>, <dakr@...nel.org>,
<bhelgaas@...gle.com>, <kwilczynski@...nel.org>, <ojeda@...nel.org>,
<alex.gaynor@...il.com>, <boqun.feng@...il.com>, <gary@...yguo.net>,
<bjorn3_gh@...tonmail.com>, <lossin@...nel.org>, <a.hindborg@...nel.org>,
<aliceryhl@...gle.com>, <tmgross@...ch.edu>, <linux-pci@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <cjia@...dia.com>, <smitra@...dia.com>,
<ankita@...dia.com>, <aniketa@...dia.com>, <kwankhede@...dia.com>,
<targupta@...dia.com>, <zhiwang@...nel.org>, <acourbot@...dia.com>,
<joelagnelf@...dia.com>, <jhubbard@...dia.com>, <markus.probst@...teo.de>
Subject: Re: [PATCH v3 3/5] rust: pci: add a helper to query configuration
space size
On Thu, 30 Oct 2025 11:51:15 -0500
Bjorn Helgaas <helgaas@...nel.org> wrote:
> On Thu, Oct 30, 2025 at 03:48:40PM +0000, Zhi Wang wrote:
> > Expose a safe Rust wrapper for the `cfg_size` field of `struct
> > pci_dev`, allowing drivers to query the size of a device's
> > configuration space.
> >
> > This is useful for code that needs to know whether the device
> > supports extended configuration space (e.g. 256 vs 4096 bytes) when
> > accessing PCI configuration registers and apply runtime checks.
>
> What is the value of knowing the config space size, as opposed to just
> having config space accessors return PCIBIOS_BAD_REGISTER_NUMBER or
> similar when trying to read past the implemented size?
>
Per my understading, the Io trait aims to provide a generic I/O
validation that can be reused across different transports -
MMIO, PCI, SPI, and others - with each backend implementing its own
region boundaries while sharing the same pre-access validation logic.
By design, the framework needs to know the valid address range
before performing the actual access. Without exposing
cfg_size(), we would have to add PCI configuration-specific
handling inside the framework.
> Apart from pci-sysfs and vfio, I don't really see any drivers that use
> pdev->cfg_size today.
It is for the framework so far. If we believe that driver doesn't need
this in the near term, I can make it private in the next re-spin.
Z.
Powered by blists - more mailing lists