[PATCH 0/4] PCI/PM: Do not save or restore the config space of an inaccessible device

From: Francisco Beltrán Millalén

Date: Thu Sep 24 2026 - 08:44:38 EST


When a PCI device becomes inaccessible while the system is suspending,
pci_save_state() happily stores 0xFFFFFFFF into all 16 dwords of the
saved config space, and pci_restore_state() writes that back on resume --
to a device that by then *is* responding again.

On a MacBookPro14,3 (Intel Alpine Ridge Thunderbolt 3) this is not
theoretical. The upstream bridge of the Thunderbolt switch stops
responding during suspend, and on resume the restore leaves it with:

- the Secondary Bus Reset bit asserted (0xFF contains
PCI_BRIDGE_CTL_BUS_RESET),
- primary/secondary/subordinate bus numbers set to ff/ff/ff,
- the link retrained down from 8 GT/s to 2.5 GT/s.

The visible effect is a 65-second resume while the kernel waits for
devices that can no longer be reached, followed by the removal of both
xHCI controllers: every USB-C port on the machine is gone until reboot.

The series makes the save path refuse to snapshot a device that is not
there, the restore path refuse to write back a snapshot that is all
ones, and teaches one more caller not to mistake an absent device for a
working link.

Patch 1 makes the USB PCI HCD honour the pci_save_state() return value,
which it currently ignores. It is a fix in its own right --
pci_save_state() can already fail today -- and it is placed first so
that no patch in the series introduces an error condition before its
caller knows how to handle it.

Measured on the affected machine, comparing the same suspend/resume
cycle with and without the series:

- resume time for the affected bridge: 65 s -> 1 s;
- the bridge keeps its bus numbers (04/05/79) and its 8 GT/s link,
with no Secondary Bus Reset asserted;
- the xHCI behind it survives the cycle: 1 of 2 controllers instead of
0 of 2, and 4 USB buses instead of 2.

v2 of this work fixes two defects found in review of v1: a
pci_WARN_ONCE() that the first version could trigger in
pci_pm_suspend_noirq(), and a partially written snapshot -- v1 could
leave dev->saved_config_space half updated if the device disappeared
while it was being read. v2 reads into a temporary buffer and only
commits it after re-checking that the device is still there. Both were
verified on hardware: the warning count went from 1 and 1 to 0 and 0,
and the per-device resume timings are unchanged to within 0.01%.

Tested on 6.18.49 on the machine described above. I do not have other
affected hardware, so wider testing of the PCI core changes would be
welcome.