[PATCH 1/4] usb: hcd-pci: Honour pci_save_state() failure

From: Francisco Beltrán Millalén

Date: Thu Sep 24 2026 - 08:50:15 EST


hcd_pci_suspend_noirq() calls pci_save_state() and ignores its return
value, then goes on to call pci_prepare_to_sleep(). pci_save_state()
can fail -- it already propagates failures from pci_save_pcie_state()
and friends -- and when it does there is no saved state to restore
later, so putting the device into a low-power state only makes matters
worse: the subsequent transition fails too, and the PCI core then warns
that the callback returned without saving the state.

Check the return value. If the state could not be saved, leave the
device alone and return success, so the rest of the system can still
suspend. Leaving the power state untouched also means the PCI core has
nothing to complain about.

Signed-off-by: Francisco Beltrán Millalén <fbeltranmillalen@xxxxxxxxx>
---
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -541,7 +541,17 @@
if (retval)
return retval;

- pci_save_state(pci_dev);
+ /*
+ * If the controller is already inaccessible, there is no state to
+ * save and nothing to put into a low-power state. Leaving the power
+ * state alone also keeps the PCI core from warning that this callback
+ * returned without saving the state.
+ */
+ retval = pci_save_state(pci_dev);
+ if (retval) {
+ dev_dbg(dev, "--> not suspending, device inaccessible\n");
+ return 0;
+ }

/* If the root hub is dead rather than suspended, disallow remote
* wakeup. usb_hc_died() should ensure that both hosts are marked as