Re: [PATCH v3 3/5] rust: pci: add a helper to query configuration space size

From: Bjorn Helgaas

Date: Thu Oct 30 2025 - 12:51:17 EST


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?

Apart from pci-sysfs and vfio, I don't really see any drivers that use
pdev->cfg_size today.