xhci: Handle missing USB2 resume events on Etron hosts
Subsystems (2)
PATCH RESEND 1/1 xhci: Handle missing USB2 resume events on Etron hosts
On Etron xHCs, a USB2 remote wakeup may also move other suspended USB2 ports into the resume state without generating individual Port Status Change Events.
The issue can be reproduced as follows:
1. Connect a USB2 hub to each downstream port of the Etron xHC.
2. Wait for all hubs, including the root hub, to autosuspend.
3. Connect a USB device, such as a mouse, to each USB2 hub in turn.
4. The last connected mouse does not work.
The affected USB2 ports may remain in the resume state, preventing newly connected devices from enumerating. Reconnecting an affected hub or mouse does not help. Reloading the xHCI driver restores normal operation.
When handling a USB2 resume event on an Etron xHC, check the other USB2 ports for the resume state and track them so the normal resume handling can complete.
Before the patch, the root hub status bitmap reported only port 2 (evt 0004), leaving port 3 in the resume state.
[ 4621.396100] xhci_hcd 0000:01:00.0: Port change event, 3-2, id 2, portsc: 0x400fe3 [ 4621.396158] xhci_hcd 0000:01:00.0: port resume event for port 2 [ 4621.396164] xhci_hcd 0000:01:00.0: resume HS port 2 [ 4621.437164] hub 3-0:1.0: state 7 ports 4 chg 0000 evt 0004 [ 4621.569169] usb usb3-port2: resume, status 0
After the patch, the bitmap includes both ports (evt 000c), allowing port 3 to complete resume through the normal resume handling.
[ 4824.829350] xhci_hcd 0000:01:00.0: Port change event, 3-2, id 2, portsc: 0x400fe3 [ 4824.829425] xhci_hcd 0000:01:00.0: port resume event for port 2 [ 4824.829431] xhci_hcd 0000:01:00.0: resume HS port 2 [ 4824.829439] xhci_hcd 0000:01:00.0: HS port 3 in resume without event, portsc: 0xfe3 [ 4824.870180] hub 3-0:1.0: state 7 ports 4 chg 0000 evt 000c [ 4825.001183] usb usb3-port2: resume, status 0 [ 4825.027484] usb usb3-port3: resume, status 0
Tested on Etron EJ168 (1b6f:7023) and EJ188 (1b6f:7052).
--- drivers/usb/host/xhci-ring.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
drivers/usb/host/xhci-ring.c +35 -0
@@ -1997,6 +1997,39 @@ static void xhci_cavium_reset_phy_quirk(struct xhci_hcd *xhci) }while (!(pll_lock_check &0x1 ) && --retry_count); } +/* +* Etron xHCs may resume other suspended USB2 ports without generating +* individual Port Status Change Events. Track those ports so the normal +* USB2 resume handling can finish. +*/ +static void xhci_handle_etron_usb2_resume (struct xhci_hcd *xhci) +{ +struct xhci_hub *rhub = &xhci->usb2_rhub; +struct xhci_bus_state *bus_state = &rhub->bus_state; +struct xhci_port *port; +unsigned int i; +u32 portsc; + +for (i =0 ; i < rhub->num_ports; i++) { +if (test_bit (i, &bus_state->resuming_ports)) +continue ; + + port = rhub->ports[i]; + portsc =xhci_portsc_readl (port); +if ((portsc &PORT_RESET ) || !(portsc &PORT_PE )) +continue ; + +if ((portsc &PORT_PLS_MASK ) ==XDEV_RESUME ) { +xhci_dbg (xhci,"HS port %d in resume without event, portsc: 0x%x\n" , + port->hw_portnum +1 , portsc); + port->resume_timestamp = jiffies + +msecs_to_jiffies (USB_RESUME_TIMEOUT ); +set_bit (i, &bus_state->resuming_ports); +usb_hcd_start_port_resume (&rhub->hcd->self, i); + } + } +} +static void handle_port_status (struct xhci_hcd *xhci,union xhci_trb *event) {struct xhci_virt_device *vdev =NULL ;
@@ -2103,6 +2136,8 @@ static void handle_port_status(struct xhci_hcd *xhci, union xhci_trb *event)mod_timer (&hcd->rh_timer, port->resume_timestamp);usb_hcd_start_port_resume (&hcd->self, hcd_portnum); +if (xhci->quirks &XHCI_ETRON_HOST ) +xhci_handle_etron_usb2_resume (xhci); bogus_port_status = true; } }
Signature · 1 line
2.25.1
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 16 lines
On Etron xHCs, a USB2 remote wakeup may also move other suspended USB2 ports into the resume state without generating individual Port Status Change Events.
The issue can be reproduced as follows:
1. Connect a USB2 hub to each downstream port of the Etron xHC.
2. Wait for all hubs, including the root hub, to autosuspend.
3. Connect a USB device, such as a mouse, to each USB2 hub in turn.
4. The last connected mouse does not work.The affected USB2 ports may remain in the resume state, preventing newly connected devices from enumerating. Reconnecting an affected hub or mouse does not help. Reloading the xHCI driver restores normal operation.
[ ... ]
Quoted 5 lines
[ 4825.027484] usb usb3-port3: resume, status 0Tested on Etron EJ168 (1b6f:7023) and EJ188 (1b6f:7052).
Signed-off-by Kuangyi Chiang <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 40 lines · Kuangyi Chiang
On Etron xHCs, a USB2 remote wakeup may also move other suspended USB2 ports into the resume state without generating individual Port Status Change Events.
The issue can be reproduced as follows:
1. Connect a USB2 hub to each downstream port of the Etron xHC.
2. Wait for all hubs, including the root hub, to autosuspend.
3. Connect a USB device, such as a mouse, to each USB2 hub in turn.
4. The last connected mouse does not work.The affected USB2 ports may remain in the resume state, preventing newly connected devices from enumerating. Reconnecting an affected hub or mouse does not help. Reloading the xHCI driver restores normal operation.
When handling a USB2 resume event on an Etron xHC, check the other USB2 ports for the resume state and track them so the normal resume handling can complete.
Before the patch, the root hub status bitmap reported only port 2 (evt 0004), leaving port 3 in the resume state.
[ 4621.396100] xhci_hcd 0000:01:00.0: Port change event, 3-2, id 2, portsc: 0x400fe3 [ 4621.396158] xhci_hcd 0000:01:00.0: port resume event for port 2 [ 4621.396164] xhci_hcd 0000:01:00.0: resume HS port 2 [ 4621.437164] hub 3-0:1.0: state 7 ports 4 chg 0000 evt 0004 [ 4621.569169] usb usb3-port2: resume, status 0After the patch, the bitmap includes both ports (evt 000c), allowing port 3 to complete resume through the normal resume handling.
[ 4824.829350] xhci_hcd 0000:01:00.0: Port change event, 3-2, id 2, portsc: 0x400fe3 [ 4824.829425] xhci_hcd 0000:01:00.0: port resume event for port 2 [ 4824.829431] xhci_hcd 0000:01:00.0: resume HS port 2 [ 4824.829439] xhci_hcd 0000:01:00.0: HS port 3 in resume without event, portsc: 0xfe3 [ 4824.870180] hub 3-0:1.0: state 7 ports 4 chg 0000 evt 000c [ 4825.001183] usb usb3-port2: resume, status 0 [ 4825.027484] usb usb3-port3: resume, status 0
Quoted 3 lines
Tested on Etron EJ168 (1b6f:7023) and EJ188 (1b6f:7052).
Signed-off-by Kuangyi Chiang <[email protected]>
Hi,
This repro doesn't seem to work for me.
Etron Technology, Inc. EJ168 USB 3.0 Host Controller [1b6f:7023] (rev 01)
/: Bus 008.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd/2p, 480M
|__ Port 001: Dev 040, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 002: Dev 034, If 0, Class=Hub, Driver=hub/4p, 480M# connecting a mouse to hub 2 resumes the bus: [ 8316.191894] xhci_hcd 0000:07:00.0: Port change event, 8-2, id 2, portsc: 0xc400fe3 [ 8316.191911] xhci_hcd 0000:07:00.0: resume root hub [ 8316.191930] xhci_hcd 0000:07:00.0: port resume event for port 2 [ 8316.191936] xhci_hcd 0000:07:00.0: resume HS port 2 [ 8316.191992] usb usb8: usb wakeup-resume [ 8316.192001] usb usb8: usb auto-resume [ 8316.192015] hub 8-0:1.0: hub_resume
# core polls both RH ports for status, both are resuming: [ 8316.192030] xhci_hcd 0000:07:00.0: Get port status 8-1 read: 0xfe3, return 0x507 [ 8316.192059] usb usb8-port1: status 0507 change 0000 [ 8316.192069] xhci_hcd 0000:07:00.0: Get port status 8-2 read: 0xfe3, return 0x507 [ 8316.192079] usb usb8-port2: status 0507 change 0000 [ 8316.192094] hub 8-0:1.0: state 7 ports 2 chg 0000 evt 0000 [ 8316.232936] hub 8-0:1.0: state 7 ports 2 chg 0000 evt 0006
# hub 1 is resumend, inspected and suspended again [ 8316.232961] xhci_hcd 0000:07:00.0: resume USB2 port 8-1 [ 8316.232970] xhci_hcd 0000:07:00.0: Set port 8-1 link state, portsc: 0xfe3, write 0x10e01 [ 8316.233017] xhci_hcd 0000:07:00.0: Port change event, 8-1, id 1, portsc: 0x400e03 [ 8316.233041] xhci_hcd 0000:07:00.0: Get port status 8-1 read: 0xfe3, return 0x40503 [ 8316.233061] xhci_hcd 0000:07:00.0: clear port1 suspend/resume change, portsc: 0xe03 [ 8316.244881] usb 8-1: usb wakeup-resume [ 8316.244921] xhci_hcd 0000:07:00.0: Get port status 8-1 read: 0xe03, return 0x503 [ 8316.256001] usb 8-1: Waited 0ms for CONNECT [ 8316.256014] usb 8-1: finish resume [ 8316.256917] hub 8-1:1.0: hub_resume [ 8316.259088] usb usb8-port1: resume, status 0 [ 8316.259122] xhci_hcd 0000:07:00.0: resume USB2 port 8-2 [ 8316.259131] xhci_hcd 0000:07:00.0: Set port 8-2 link state, portsc: 0xfe3, write 0x10e01 [ 8316.259158] hub 8-1:1.0: state 7 ports 4 chg 0000 evt 0000 [ 8316.259345] xhci_hcd 0000:07:00.0: Port change event, 8-2, id 2, portsc: 0x400e03 [ 8316.259410] xhci_hcd 0000:07:00.0: Get port status 8-2 read: 0xfe3, return 0x40503 [ 8316.259552] xhci_hcd 0000:07:00.0: clear port2 suspend/resume change, portsc: 0xe03 [ 8316.261302] hub 8-1:1.0: hub_suspend [ 8316.262137] xhci_hcd 0000:07:00.0: Set port 8-1 link state, portsc: 0xe03, write 0x10e61
# hub 2 is resumend, inspected and the device enabled [ 8316.270925] usb 8-2: usb wakeup-resume [ 8316.270950] xhci_hcd 0000:07:00.0: Get port status 8-2 read: 0xe03, return 0x503 [ 8316.272785] usb 8-1: usb auto-suspend, wakeup 1 [ 8316.282855] usb 8-2: Waited 0ms for CONNECT [ 8316.282867] usb 8-2: finish resume [ 8316.283835] hub 8-2:1.0: hub_resume [ 8316.284504] usb 8-2-port1: status 0301 change 0001 [ 8316.391951] usb usb8-port2: resume, status 0 [ 8316.391985] hub 8-2:1.0: state 7 ports 4 chg 0002 evt 0000 [ 8316.392650] usb 8-2-port1: status 0301, change 0000, 1.5 Mb/s [ 8316.393099] usb 8-2-port1: indicator auto status 0 [ 8316.447829] xhci_hcd 0000:07:00.0: xhci_hub_status_data: stopping usb8 port polling [ 8316.457913] usb 8-2.1: new low-speed USB device number 46 using xhci_hcd
# (not shown): hub 1 works normally, including wake on connection
Regards,
Michal
Hi,
Thanks for testing and sharing the detailed logs.
Michal Pecio <[email protected]> 於 2026年11月23日週一 下午7:23寫道:
Quoted 3 lines
This repro doesn't seem to work for me.
[...]
I tested again on an EJ188 with three USB2 hubs connected, without the proposed fix but with extra local debug messages to detect ports that are in the resume state without a Port Status Change Event.
When I connected the first mouse to hub 3, I saw the same behavior as in your test: the USB core checked all root hub ports, and all three hubs completed resume (evt 000e).
However, when I connected a second mouse to hub 2, the root hub was already active. Port 1 also entered the resume state without an event, but only port 2 was reported in the status bitmap (evt 0004).
Both mice worked, but a third mouse connected to hub 1 had no effect.
So the issue seems to occur when another suspended port enters the resume state while the root hub is already active.
Here are the test logs:
02:00.0 USB controller: Etron Technology, Inc. EJ188/EJ198 USB 3.0 Host Controller
/: Bus 005.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd/4p, 480M
|__ Port 001: Dev 004, If 0, Class=Hub, Driver=hub/7p, 480M
|__ Port 002: Dev 005, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 003: Dev 006, If 0, Class=Hub, Driver=hub/4p, 480M# connecting a mouse to hub 3 resumes the bus: [ 3613.057015] xhci_hcd 0000:02:00.0: Port change event, 5-3, id 3, portsc: 0xc400fe3 [ 3613.057091] xhci_hcd 0000:02:00.0: resume root hub [ 3613.057106] xhci_hcd 0000:02:00.0: port resume event for port 3 [ 3613.057114] xhci_hcd 0000:02:00.0: resume HS port 3 [ 3613.057122] xhci_hcd 0000:02:00.0: USB2 port 1 resumed without event, portsc: 0xc000fe3 [ 3613.057129] xhci_hcd 0000:02:00.0: USB2 port 2 resumed without event, portsc: 0xc000fe3 [ 3613.057170] usb usb5: usb wakeup-resume [ 3613.057184] usb usb5: usb auto-resume [ 3613.057206] hub 5-0:1.0: hub_resume
# core checks all RH ports; ports 1, 2 and 3 are resuming: [ 3613.057221] xhci_hcd 0000:02:00.0: Get port status 5-1 read: 0xfe3, return 0x507 [ 3613.057269] usb usb5-port1: status 0507 change 0000 [ 3613.057284] xhci_hcd 0000:02:00.0: Get port status 5-2 read: 0xfe3, return 0x507 [ 3613.057317] usb usb5-port2: status 0507 change 0000 [ 3613.057331] xhci_hcd 0000:02:00.0: Get port status 5-3 read: 0xfe3, return 0x507 [ 3613.057361] usb usb5-port3: status 0507 change 0000 [ 3613.057376] xhci_hcd 0000:02:00.0: Get port status 5-4 read: 0x2a0, return 0x100 [ 3613.057416] hub 5-0:1.0: state 7 ports 4 chg 0000 evt 0000 [ 3613.057728] hub 5-0:1.0: state 7 ports 4 chg 0000 evt 0000 [ 3613.295602] hub 5-0:1.0: state 7 ports 4 chg 0000 evt 000e
# hub 1 is resumed, inspected and suspended again [ 3613.295628] xhci_hcd 0000:02:00.0: resume USB2 port 5-1 [ 3613.295639] xhci_hcd 0000:02:00.0: Set port 5-1 link state, portsc: 0xfe3, write 0x10e01 [ 3613.295743] xhci_hcd 0000:02:00.0: Port change event, 5-1, id 1, portsc: 0x400e03 [ 3613.295774] xhci_hcd 0000:02:00.0: Get port status 5-1 read: 0xfe3, return 0x40503 [ 3613.295819] xhci_hcd 0000:02:00.0: clear port1 suspend/resume change, portsc: 0xe03 [ 3613.306530] usb 5-1: usb wakeup-resume [ 3613.306558] xhci_hcd 0000:02:00.0: Get port status 5-1 read: 0xe03, return 0x503 [ 3613.317615] usb 5-1: Waited 0ms for CONNECT [ 3613.317626] usb 5-1: finish resume [ 3613.318018] hub 5-1:1.0: hub_resume [ 3613.320288] usb usb5-port1: resume, status 0 [ 3613.320306] xhci_hcd 0000:02:00.0: resume USB2 port 5-2 [ 3613.320316] xhci_hcd 0000:02:00.0: Set port 5-2 link state, portsc: 0xfe3, write 0x10e01 [ 3613.320340] hub 5-1:1.0: state 7 ports 7 chg 0000 evt 0000 [ 3613.320381] hub 5-1:1.0: hub_suspend [ 3613.321518] xhci_hcd 0000:02:00.0: Set port 5-1 link state, portsc: 0xe03, write 0x10e61
# hub 2 is resumed, inspected and suspended again [ 3613.331561] usb 5-2: usb wakeup-resume [ 3613.331592] xhci_hcd 0000:02:00.0: Get port status 5-2 read: 0xe03, return 0x503 [ 3613.332562] usb 5-1: usb auto-suspend, wakeup 1 [ 3613.342518] usb 5-2: Waited 0ms for CONNECT [ 3613.342532] usb 5-2: finish resume [ 3613.343274] hub 5-2:1.0: hub_resume [ 3613.345374] usb usb5-port2: resume, status 0 [ 3613.345393] xhci_hcd 0000:02:00.0: resume USB2 port 5-3 [ 3613.345403] xhci_hcd 0000:02:00.0: Set port 5-3 link state, portsc: 0xfe3, write 0x10e01 [ 3613.345427] hub 5-2:1.0: state 7 ports 4 chg 0000 evt 0000 [ 3613.345439] xhci_hcd 0000:02:00.0: Port change event, 5-3, id 3, portsc: 0x400e03 [ 3613.345497] xhci_hcd 0000:02:00.0: Get port status 5-3 read: 0xfe3, return 0x40503 [ 3613.345548] xhci_hcd 0000:02:00.0: clear port3 suspend/resume change, portsc: 0xe03 [ 3613.347649] hub 5-2:1.0: hub_suspend [ 3613.348842] xhci_hcd 0000:02:00.0: Set port 5-2 link state, portsc: 0xe03, write 0x10e61
# hub 3 is resumed, inspected and the device enabled [ 3613.356604] usb 5-3: usb wakeup-resume [ 3613.356628] xhci_hcd 0000:02:00.0: Get port status 5-3 read: 0xe03, return 0x503 [ 3613.359576] usb 5-2: usb auto-suspend, wakeup 1 [ 3613.368504] usb 5-3: Waited 0ms for CONNECT [ 3613.368515] usb 5-3: finish resume [ 3613.368981] hub 5-3:1.0: hub_resume [ 3613.370094] usb 5-3-port4: status 0101 change 0001 [ 3613.471650] usb usb5-port3: resume, status 0 [ 3613.471671] hub 5-3:1.0: state 7 ports 4 chg 0010 evt 0000 [ 3613.472020] usb 5-3-port4: status 0101, change 0000, 12 Mb/s [ 3613.543564] xhci_hcd 0000:02:00.0: xhci_hub_status_data: stopping usb5 port polling [ 3613.544505] usb 5-3.4: new full-speed USB device number 7 using xhci_hcd
# connecting a second mouse to hub 2 resumes port 2: [ 3622.523436] xhci_hcd 0000:02:00.0: Port change event, 5-2, id 2, portsc: 0x400fe3 [ 3622.523492] xhci_hcd 0000:02:00.0: port resume event for port 2 [ 3622.523499] xhci_hcd 0000:02:00.0: resume HS port 2 [ 3622.523507] xhci_hcd 0000:02:00.0: USB2 port 1 resumed without event, portsc: 0xfe3 [ 3622.564503] hub 5-0:1.0: state 7 ports 4 chg 0000 evt 0004 [ 3622.564530] xhci_hcd 0000:02:00.0: resume USB2 port 5-2 [ 3622.564541] xhci_hcd 0000:02:00.0: Set port 5-2 link state, portsc: 0xfe3, write 0x10e01 [ 3622.564651] xhci_hcd 0000:02:00.0: Port change event, 5-2, id 2, portsc: 0x400e03 [ 3622.564684] xhci_hcd 0000:02:00.0: Get port status 5-2 read: 0xfe3, return 0x40503 [ 3622.564744] xhci_hcd 0000:02:00.0: clear port2 suspend/resume change, portsc: 0xe03
# hub 2 is resumed, inspected and the device enabled [ 3622.575423] usb 5-2: usb wakeup-resume [ 3622.575451] xhci_hcd 0000:02:00.0: Get port status 5-2 read: 0xe03, return 0x503 [ 3622.586477] usb 5-2: Waited 0ms for CONNECT [ 3622.586487] usb 5-2: finish resume [ 3622.587310] hub 5-2:1.0: hub_resume [ 3622.588566] usb 5-2-port2: status 0301 change 0001 [ 3622.695551] usb usb5-port2: resume, status 0 [ 3622.695573] hub 5-2:1.0: state 7 ports 4 chg 0004 evt 0000 [ 3622.696175] usb 5-2-port2: status 0301, change 0000, 1.5 Mb/s [ 3622.696661] usb 5-2-port2: indicator auto status 0 [ 3622.773415] usb 5-2.2: new low-speed USB device number 8 using xhci_hcd
# connecting a third mouse to hub 1 has no effect
Regards,
Kuangyi
Quoted 11 lines · Kuangyi Chiang
I tested again on an EJ188 with three USB2 hubs connected, without the proposed fix but with extra local debug messages to detect ports that are in the resume state without a Port Status Change Event.
When I connected the first mouse to hub 3, I saw the same behavior as in your test: the USB core checked all root hub ports, and all three hubs completed resume (evt 000e).
However, when I connected a second mouse to hub 2, the root hub was already active. Port 1 also entered the resume state without an event, but only port 2 was reported in the status bitmap (evt 0004).
OK, so I'm not sure how you reproduced this problem on the two-port chip, and commit message was wrong - the root hub must be awake.
But now, if I disable root hub autosuspend (echo on > power/control), connect two devices which use autosuspend and remote wake one device, the RH wakes both ports and only generates one Port Status Change. It seems nobody expects the other port to be affected so it stays stuck in the Resume state (SW is responsible for transition to U0).
I don't see similar behavior in other xHCI root hubs, nor in a few external hubs. Anyone knows if this violates the USB2 spec?
Regards,
Michal
Quoted 16 lines · Michal Pecio
Quoted 11 lines · Kuangyi Chiang
I tested again on an EJ188 with three USB2 hubs connected, without the proposed fix but with extra local debug messages to detect ports that are in the resume state without a Port Status Change Event.
When I connected the first mouse to hub 3, I saw the same behavior as in your test: the USB core checked all root hub ports, and all three hubs completed resume (evt 000e).
However, when I connected a second mouse to hub 2, the root hub was already active. Port 1 also entered the resume state without an event, but only port 2 was reported in the status bitmap (evt 0004).
OK, so I'm not sure how you reproduced this problem on the two-port chip, and commit message was wrong - the root hub must be awake.
Quoted 8 lines
But now, if I disable root hub autosuspend (echo on > power/control), connect two devices which use autosuspend and remote wake one device, the RH wakes both ports and only generates one Port Status Change. It seems nobody expects the other port to be affected so it stays stuck in the Resume state (SW is responsible for transition to U0).
I don't see similar behavior in other xHCI root hubs, nor in a few external hubs. Anyone knows if this violates the USB2 spec?
Yes, it does.
Alan Stern