[PATCH] usb: xhci: prevent spurious root hub resume during suspend

From: Pei Xiao

Date: Tue Jun 30 2026 - 03:40:11 EST


handle_port_status() unconditionally resumes the root hub when
hcd->state is HC_STATE_SUSPENDED, regardless of whether a device is
actually attached to the port. This can cause system suspend to fail
with -EBUSY if a spurious port change event arrives on an empty port
after its bus has entered suspend.

Fix this by checking PORT_CONNECT in handle_port_status() before
resuming the root hub. If no device is actually present on the port,
the event is spurious and should be silently ignored rather than
aborting suspend.

Logs:
handle_port_status:1700: xhci_hcd 0000:04:00.0: Port change event, 3-2, id 6, portsc: 0x202a0
handle_port_status:1706: xhci_hcd 0000:04:00.0: resume root hub
handle_port_status:1821: xhci_hcd 0000:04:00.0: handle_port_status: starting port polling.
PM: pci_pm_suspend(): hcd_pci_suspend+0x0/0x38 returns -16
xhci_suspend:1017: xhci_hcd 0000:03:00.0: xhci_suspend: stopping port polling.
PM: dpm_run_callback(): pci_pm_suspend+0x0/0x190 returns -16

Signed-off-by: Pei Xiao <xiaopei01@xxxxxxxxxx>
---
drivers/usb/host/xhci-ring.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 4f98d8269625..3bfe49e788ed 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2042,8 +2042,13 @@ static void handle_port_status(struct xhci_hcd *xhci, union xhci_trb *event)
trace_xhci_handle_port_status(port, portsc);

if (hcd->state == HC_STATE_SUSPENDED) {
- xhci_dbg(xhci, "resume root hub\n");
- usb_hcd_resume_root_hub(hcd);
+ if (portsc & PORT_CONNECT) {
+ xhci_dbg(xhci, "resume root hub\n");
+ usb_hcd_resume_root_hub(hcd);
+ } else {
+ xhci_dbg(xhci, "spurious port change on empty port %d-%d, ignored\n",
+ hcd->self.busnum, hcd_portnum + 1);
+ }
}

if (vdev && (portsc & PORT_PLS_MASK) == XDEV_INACTIVE) {
--
2.25.1