All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: xhci: prevent spurious root hub resume during suspend
@ 2026-06-30  7:36 Pei Xiao
  2026-06-30  8:10 ` Mathias Nyman
  0 siblings, 1 reply; 5+ messages in thread
From: Pei Xiao @ 2026-06-30  7:36 UTC (permalink / raw)
  To: mathias.nyman, gregkh, linux-usb, linux-kernel, stern; +Cc: dengjie03, Pei Xiao

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@kylinos.cn>
---
 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


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

end of thread, other threads:[~2026-07-01  1:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30  7:36 [PATCH] usb: xhci: prevent spurious root hub resume during suspend Pei Xiao
2026-06-30  8:10 ` Mathias Nyman
2026-06-30  8:43   ` Pei Xiao
2026-06-30 10:30     ` Mathias Nyman
2026-07-01  1:10       ` Pei Xiao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.