mirror-linux/drivers/usb/core
Mathias Nyman 2521106fc7 usb: hub: Don't try to recover devices lost during warm reset.
Hub driver warm-resets ports in SS.Inactive or Compliance mode to
recover a possible connected device. The port reset code correctly
detects if a connection is lost during reset, but hub driver
port_event() fails to take this into account in some cases.
port_event() ends up using stale values and assumes there is a
connected device, and will try all means to recover it, including
power-cycling the port.

Details:
This case was triggered when xHC host was suspended with DbC (Debug
Capability) enabled and connected. DbC turns one xHC port into a simple
usb debug device, allowing debugging a system with an A-to-A USB debug
cable.

xhci DbC code disables DbC when xHC is system suspended to D3, and
enables it back during resume.
We essentially end up with two hosts connected to each other during
suspend, and, for a short while during resume, until DbC is enabled back.
The suspended xHC host notices some activity on the roothub port, but
can't train the link due to being suspended, so xHC hardware sets a CAS
(Cold Attach Status) flag for this port to inform xhci host driver that
the port needs to be warm reset once xHC resumes.

CAS is xHCI specific, and not part of USB specification, so xhci driver
tells usb core that the port has a connection and link is in compliance
mode. Recovery from complinace mode is similar to CAS recovery.

xhci CAS driver support that fakes a compliance mode connection was added
in commit 8bea2bd37d ("usb: Add support for root hub port status CAS")

Once xHCI resumes and DbC is enabled back, all activity on the xHC
roothub host side port disappears. The hub driver will anyway think
port has a connection and link is in compliance mode, and hub driver
will try to recover it.

The port power-cycle during recovery seems to cause issues to the active
DbC connection.

Fix this by clearing connect_change flag if hub_port_reset() returns
-ENOTCONN, thus avoiding the whole unnecessary port recovery and
initialization attempt.

Cc: stable@vger.kernel.org
Fixes: 8bea2bd37d ("usb: Add support for root hub port status CAS")
Tested-by: Łukasz Bartosik <ukaszb@chromium.org>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20250623133947.3144608-1-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-07-16 09:48:11 +02:00
..
Kconfig
Makefile
buffer.c
config.c usb: core: config: Use USB API functions rather than constants 2025-05-21 13:13:18 +02:00
devices.c
devio.c USB: core: remove dead code in do_proc_bulk() 2024-11-13 07:06:41 +01:00
driver.c USB: Optimize goto logic in API usb_register_driver() 2024-12-23 18:40:34 +01:00
endpoint.c usb: core: use sysfs_emit() instead of sprintf() 2024-10-29 04:33:49 +01:00
file.c
generic.c USB: Replace own str_plural with common one 2025-01-15 18:28:12 +01:00
hcd-pci.c USB: Fix the issue of task recovery failure caused by USB status when S4 wakes up 2024-12-04 16:14:08 +01:00
hcd.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
hub.c usb: hub: Don't try to recover devices lost during warm reset. 2025-07-16 09:48:11 +02:00
hub.h usb: hub: Fix flushing of delayed work used for post resume purposes 2025-06-30 15:36:00 +02:00
ledtrig-usbport.c usb: core: use sysfs_emit() instead of sprintf() 2024-10-29 04:33:49 +01:00
message.c
notify.c
of.c usb: core: add missing of_node_put() in usb_of_has_devices_or_graph 2024-07-03 16:04:10 +02:00
otg_productlist.h
phy.c
phy.h
port.c USB: Use str_enable_disable-like helpers 2025-01-15 18:28:13 +01:00
quirks.c Logitech C-270 even more broken 2025-06-19 12:35:50 +02:00
sysfs.c usb: core: sysfs: Constify 'struct bin_attribute' 2024-12-24 08:56:04 +01:00
urb.c usb: core: Don't use %pK through printk 2025-03-14 09:17:29 +01:00
usb-acpi.c usb: acpi: fix device link removal 2025-06-19 12:36:19 +02:00
usb.c usb: Add checks for snprintf() calls in usb_alloc_dev() 2025-04-11 16:08:34 +02:00
usb.h USB: make to_usb_device_driver() use container_of_const() 2024-11-14 17:57:33 +01:00