答复: [外部邮件] Re: [PATCH] PCI: Only restore state that was successfully saved around a reset
From: Li,Rongqing
Date: Wed Nov 11 2026 - 21:37:41 EST
> > pci_dev_save_and_disable() returns early when config space is
> > inaccessible, without saving anything, but pci_dev_restore() calls
> > pci_restore_state() unconditionally and pci_restore_state() does not
> > look at state_saved. After the reset makes config space accessible
> > again, the all-zero or stale saved_config_space[] array is written
> > back to the device, clearing Command, BARs and, for bridges, the bus number
> registers.
> >
> > Clear state_saved when the save is skipped and only restore when a
> > state was saved.
>
> We should always have a valid state of the device saved at enumeration due to
> commit a2f1e22390ac ("PCI/ERR: Ensure error recoverability at all times"). In
> pci_dev_save_disable(), if the device is inaccessible then we want to avoid
> storing a state that can corrupt the device on restore.
> Since we always have a valid state, we would restore to the last good state.
>
You're right, please disregard this patch.
I missed that a2f1e22390ac ("PCI/ERR: Ensure error recoverability at
all times") already saves a valid state at enumeration and deliberately
drops the state_saved check in pci_restore_state(). Skipping the save
when config space is inaccessible keeps that last good state, and the
unconditional restore writes it back after the reset. Gating
pci_dev_restore() on state_saved would instead leave the device at its
power-on defaults. This came from code inspection of the reset path, not
from a failure on a specific device or driver.
Sorry for the noise.
[Li,Rongqing]