xhci: Handle missing USB2 resume events on Etron hosts
Subsystems (2)
PATCH 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