Re: [PATCH v2 02/17] PCI: Add an offset-indexed store for saved capability registers
From: David Matlack
Date: Fri Dec 04 2026 - 18:22:59 EST
On Fri Dec 4, 2026 at 9:55 AM PST, Lukas Wunner wrote:
> 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.
Agreed, I'll do both in v3 (more details in my reply to your other email
on this patch).
>
>> +/*
>> + * 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.
Will do.
> The "slot" terminology is a little unfortunate as it sounds as if
> there's a connection with struct pci_slot.
Yes, good point. I'll swap "slot" with "ptr" in the next version.
>> +/**
>> + * 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"?
How about get/set?
I'd like to avoid "retrieve" since patch 17 already uses it for Live
Update, where it means something else
(pci_liveupdate_retrieve_saved_state()).
> Aside from the issues mentioned, this looks pretty good!
Thanks for the review!