* [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
* Re: [PATCH] usb: xhci: prevent spurious root hub resume during suspend
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
0 siblings, 1 reply; 5+ messages in thread
From: Mathias Nyman @ 2026-06-30 8:10 UTC (permalink / raw)
To: Pei Xiao, mathias.nyman, gregkh, linux-usb, linux-kernel, stern; +Cc: dengjie03
On 6/30/26 10:36, Pei Xiao wrote:
> 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.
Doesn't this change prevent handling device disconnects on suspended hosts?
Thanks
Mathias
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] usb: xhci: prevent spurious root hub resume during suspend
2026-06-30 8:10 ` Mathias Nyman
@ 2026-06-30 8:43 ` Pei Xiao
2026-06-30 10:30 ` Mathias Nyman
0 siblings, 1 reply; 5+ messages in thread
From: Pei Xiao @ 2026-06-30 8:43 UTC (permalink / raw)
To: Mathias Nyman, mathias.nyman, gregkh, linux-usb, linux-kernel,
stern
Cc: dengjie03
在 2026/6/30 16:10, Mathias Nyman 写道:
> On 6/30/26 10:36, Pei Xiao wrote:
>> 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.
>
> Doesn't this change prevent handling device disconnects on suspended
> hosts?
>
*Thank you for your reply. I’m not familiar with xHCI or these registers.
Can’t we tell the difference between a real unplug and a situation where
the device is physically still attached but portsc reports a disconnect?
Thanks!
Pei*
> Thanks
> Mathias
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] usb: xhci: prevent spurious root hub resume during suspend
2026-06-30 8:43 ` Pei Xiao
@ 2026-06-30 10:30 ` Mathias Nyman
2026-07-01 1:10 ` Pei Xiao
0 siblings, 1 reply; 5+ messages in thread
From: Mathias Nyman @ 2026-06-30 10:30 UTC (permalink / raw)
To: Pei Xiao, mathias.nyman, gregkh, linux-usb, linux-kernel, stern; +Cc: dengjie03
On 6/30/26 11:43, Pei Xiao wrote:
>
>
> 在 2026/6/30 16:10, Mathias Nyman 写道:
>> On 6/30/26 10:36, Pei Xiao wrote:
>>> 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.
>>
>> Doesn't this change prevent handling device disconnects on suspended
>> hosts?
>>
> *Thank you for your reply. I’m not familiar with xHCI or these registers.
> Can’t we tell the difference between a real unplug and a situation where
> the device is physically still attached but portsc reports a disconnect?
Not really. In your case it really looks like a disconnect.
Port Status: 0x202a0
Disconnected
Disabled
Link: Rx Detect
Powered
Unknown port speed
Connect Status Change
Is it only this specific device that disconnects on suspend, or can this be
reproduced with any usb device?
Thanks
Mathias
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] usb: xhci: prevent spurious root hub resume during suspend
2026-06-30 10:30 ` Mathias Nyman
@ 2026-07-01 1:10 ` Pei Xiao
0 siblings, 0 replies; 5+ messages in thread
From: Pei Xiao @ 2026-07-01 1:10 UTC (permalink / raw)
To: Mathias Nyman, mathias.nyman, gregkh, linux-usb, linux-kernel,
stern
Cc: dengjie03
在 2026/6/30 18:30, Mathias Nyman 写道:
> On 6/30/26 11:43, Pei Xiao wrote:
>>
>>
>> 在 2026/6/30 16:10, Mathias Nyman 写道:
>>> On 6/30/26 10:36, Pei Xiao wrote:
>>>> 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.
>>>
>>> Doesn't this change prevent handling device disconnects on suspended
>>> hosts?
>>>
>> *Thank you for your reply. I’m not familiar with xHCI or these
>> registers.
>> Can’t we tell the difference between a real unplug and a situation
>> where
>> the device is physically still attached but portsc reports a
>> disconnect?
>
> Not really. In your case it really looks like a disconnect.
>
> Port Status: 0x202a0
> Disconnected
> Disabled
> Link: Rx Detect
> Powered
> Unknown port speed
> Connect Status Change
>
> Is it only this specific device that disconnects on suspend, or can
> this be
> reproduced with any usb device?
>
It's specific devices—like USB flash drives and external hard drives.
A USB keyboard doesn't have the problem. And for the device that does
have the issue, if I plug it into a USB hub and then connect that hub to
the host,
the issue doesn't happen either.
Thanks
Pei.
> Thanks
> Mathias
^ permalink raw reply [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.