Re: [PATCH v2 01/17] PCI/DPC: Allocate the DPC save buffer during device setup
From: Lukas Wunner
Date: Fri Dec 04 2026 - 06:43:26 EST
On Fri, Nov 06, 2026 at 12:42:02AM +0000, David Matlack wrote:
> Allocate the DPC capability's save buffer in pci_dpc_init() rather than
> in dpc_probe(), and report an allocation failure, which dpc_probe()
> ignored.
Good catch, could you amend dpc_probe() to handle the allocation failure?
>
> dpc_probe() runs when the portdrv DPC service binds to a port, which is
> long after the device has been added, and does not happen at all if the
> service is not enabled. Until then pci_save_dpc_state() silently saves
> nothing, so a reset in that window loses the DPC Control register.
That shouldn't hurt. I think the expectation is that until the
DPC port service driver binds, the DPC Extended Capability is in
power-on reset state and it's not managed by the kernel. So the
kernel doesn't have to care about restoring it.
Moreover according to PCI Firmware Spec r3.3 table 4-6 bit 7,
the kernel is not supposed to modify the DPC Extended Capability
unless it has been granted control by platform firmware.
It seems this is violated by moving the allocation to pci_dpc_init().
Note that dpc_probe() is gated by the rules applied in
get_port_device_capability(), which checks whether DPC control
was granted by the platform. pci_dpc_init() doesn't perform those
checks.
> Allocating during device setup makes buffer existence depend only on the
> capability being present, which is what the save and restore paths
> already assume. It also puts every capability save buffer in one phase
> of a device's life, which a later patch relies on.
pci_save_dpc_state() and pci_restore_dpc_state() become no-ops if
no saved_state has been allocated, which never happens if platform
firmware hasn't granted control.
So my impression is that this patch isn't needed, but a fixup to
handle the allocation failure in dpc_probe() is.
Thanks,
Lukas