Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: host: xhci: Avoid XHCI resume delay if SSUSB device is not present

There is a 120ms delay implemented for allowing the XHCI host controller to
detect a U3 wakeup pulse. The intention is to wait for the device to retry
the wakeup event if the USB3 PORTSC doesn't reflect the RESUME link status
by the time it is checked. As per the USB3 specification:

tU3WakeupRetryDelay ("Table 7-12. LTSSM State Transition Timeouts")

This would allow the XHCI resume sequence to determine if the root hub
needs to be also resumed. However, in case there is no device connected,
or if there is only a HSUSB device connected, this delay would still affect
the overall resume timing.

Since this delay is solely for detecting U3 wake events (USB3 specific)
then ignore this delay for the disconnected case and the HSUSB connected
only case.

[skip helper function, rename usb3_connected variable -Mathias ]

Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20231019102924.2797346-20-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Wesley Cheng and committed by
Greg Kroah-Hartman
6add6dd3 a5f928db

+10 -2
+10 -2
drivers/usb/host/xhci.c
··· 992 992 int retval = 0; 993 993 bool comp_timer_running = false; 994 994 bool pending_portevent = false; 995 + bool suspended_usb3_devs = false; 995 996 bool reinit_xhc = false; 996 997 997 998 if (!hcd->state) ··· 1140 1139 /* 1141 1140 * Resume roothubs only if there are pending events. 1142 1141 * USB 3 devices resend U3 LFPS wake after a 100ms delay if 1143 - * the first wake signalling failed, give it that chance. 1142 + * the first wake signalling failed, give it that chance if 1143 + * there are suspended USB 3 devices. 1144 1144 */ 1145 + if (xhci->usb3_rhub.bus_state.suspended_ports || 1146 + xhci->usb3_rhub.bus_state.bus_suspended) 1147 + suspended_usb3_devs = true; 1148 + 1145 1149 pending_portevent = xhci_pending_portevent(xhci); 1146 - if (!pending_portevent && msg.event == PM_EVENT_AUTO_RESUME) { 1150 + 1151 + if (suspended_usb3_devs && !pending_portevent && 1152 + msg.event == PM_EVENT_AUTO_RESUME) { 1147 1153 msleep(120); 1148 1154 pending_portevent = xhci_pending_portevent(xhci); 1149 1155 }