Re: [PATCH v9 3/9] PCI: Avoid saving config space state in reset path
From: Farhan Ali
Date: Tue Feb 17 2026 - 14:56:17 EST
On 2/17/2026 11:11 AM, Keith Busch wrote:
On Tue, Feb 17, 2026 at 10:22:51AM -0800, Farhan Ali wrote:
The current reset process saves the device's config space state beforeThe vfio driver calls pci_try_reset_function after pci_enable_device,
reset and restores it afterward. However errors may occur unexpectedly and
it may then be impossible to save config space because the device may be
inaccessible (e.g. DPC) or config space may be corrupted. This results in
saving corrupted values that get written back to the device during state
restoration.
Since commit a2f1e22390ac ("PCI/ERR: Ensure error recoverability at all times"),
we now save the state of device at enumeration. On every restore we should
either use the enumeration saved state or driver's intentional saved state,
never a state saved at the unpredictable time of an error recovery reset.
but before calling pci_store_saved_state. Won't this change, then, mean
that the PCI Command register will get restored to the wrong state with
the resources disabled?
Yes I think you are right, with this change the PCI Command register gets restored to state at enumeration. So we will lose the updated state after pci_clear_master() and pci_enable_device(). I think we can update the vfio driver to call pci_save_state() after pci_enable_device()?
Thanks
Farhan