Re: [PATCH v2 02/17] PCI: Add an offset-indexed store for saved capability registers
From: Lukas Wunner
Date: Fri Dec 04 2026 - 12:55:16 EST
On Fri, Nov 06, 2026 at 12:42:03AM +0000, David Matlack wrote:
> The store holds capability registers only. The configuration space header
> continues to be saved in pci_dev.saved_config_space, which is embedded in
> struct pci_dev so that saving it cannot fail.
I'd prefer moving saved_config_space to the new store as well
for consistency and simplicity. As an optional optimization,
the saved-caps library could skip the hweight and test_bit
operations for the lowest 16 dwords.
> +/*
> + * Return the slot holding the value saved for the DWORD containing @off, or
> + * NULL if there is nowhere to save it. Reservations that do not fit in the
> + * device's configuration space and a failure to allocate the values were
> + * reported during setup, so return NULL quietly for those. Reaching any other
> + * register that was not reserved is a kernel bug.
> + */
> +static u32 *pci_saved_cap_slot(struct pci_dev *dev, unsigned int off)
Documentation should be kerneldoc-formatted so that it's recognized
by cross referencers such as elixir.
The "slot" terminology is a little unfortunate as it sounds as if
there's a connection with struct pci_slot.
> +/**
> + * pci_write_saved_cap_word - change the saved value of a 16-bit register
> + * @dev: the PCI device
> + * @off: offset of the register in configuration space
> + * @val: value to save
> + */
> +void pci_write_saved_cap_word(struct pci_dev *dev, unsigned int off, u16 val)
Another naming issue: "write" sounds like something is written to
config space. You're actually updating the saved config store.
Same for pci_read_saved_cap_word(). Maybe "store" / "retrieve"?
Aside from the issues mentioned, this looks pretty good!
Thanks,
Lukas