mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] PCI/PM: Do not save or restore the config space of an inaccessible device
@ 2026-09-24 12:42 Francisco Beltrán Millalén
  2026-09-24 12:42 ` [PATCH 1/4] usb: hcd-pci: Honour pci_save_state() failure Francisco Beltrán Millalén
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Francisco Beltrán Millalén @ 2026-09-24 12:42 UTC (permalink / raw)
  To: bhelgaas, linux-pci; +Cc: gregkh, linux-usb, linux-kernel

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-09-24 15:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-24 12:42 [PATCH 0/4] PCI/PM: Do not save or restore the config space of an inaccessible device Francisco Beltrán Millalén
2026-09-24 12:42 ` [PATCH 1/4] usb: hcd-pci: Honour pci_save_state() failure Francisco Beltrán Millalén
2026-09-24 15:30   ` Alan Stern
2026-09-24 12:42 ` [PATCH 2/4] PCI/PM: Do not save the config space of an inaccessible device Francisco Beltrán Millalén
2026-09-24 12:42 ` [PATCH 3/4] PCI/PM: Do not restore a config space snapshot that is all ones Francisco Beltrán Millalén
2026-09-24 12:42 ` [PATCH 4/4] PCI: Do not mistake an absent device for an active link Francisco Beltrán Millalén

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®