Skip to content

Commit 3eff494

Browse files
roychl666gregkh
authored andcommitted
usb: xhci: Skip xhci_reset in xhci_resume if xhci is being removed
xhci_reset() currently returns -ENODEV if XHCI_STATE_REMOVING is set, without completing the xhci handshake, unless the reset completes exceptionally quickly. This behavior causes a regression on Synopsys DWC3 USB controllers with dual-role capabilities. Specifically, when a DWC3 controller exits host mode and removes xhci while a reset is still in progress, and then attempts to configure its hardware for device mode, the ongoing, incomplete reset leads to critical register access issues. All register reads return zero, not just within the xHCI register space (which might be expected during a reset), but across the entire DWC3 IP block. This patch addresses the issue by preventing xhci_reset() from being called in xhci_resume() and bailing out early in the reinit flow when XHCI_STATE_REMOVING is set. Cc: stable <[email protected]> Fixes: 6ccb83d ("usb: xhci: Implement xhci_handshake_check_state() helper") Suggested-by: Mathias Nyman <[email protected]> Signed-off-by: Roy Luo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c529c37 commit 3eff494

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/usb/host/xhci.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,10 @@ int xhci_resume(struct xhci_hcd *xhci, bool power_lost, bool is_auto_resume)
11821182
xhci_dbg(xhci, "Stop HCD\n");
11831183
xhci_halt(xhci);
11841184
xhci_zero_64b_regs(xhci);
1185-
retval = xhci_reset(xhci, XHCI_RESET_LONG_USEC);
1185+
if (xhci->xhc_state & XHCI_STATE_REMOVING)
1186+
retval = -ENODEV;
1187+
else
1188+
retval = xhci_reset(xhci, XHCI_RESET_LONG_USEC);
11861189
spin_unlock_irq(&xhci->lock);
11871190
if (retval)
11881191
return retval;

0 commit comments

Comments
 (0)