From dbbaf9e5f42261811cdb2bb0dde6fa201eebe263 Mon Sep 17 00:00:00 2001
From: "Chia-Lin Kao (AceLan)" <acelan.kao@canonical.com>
Date: Thu, 19 Mar 2026 10:57:17 +0800
Subject: [PATCH 1/3] xhci: restrict VDEV_PORT_ERROR to USB3 ports in
 handle_port_status()

Commit b69dfcab6894 ("xhci: fix stale flag preventig URBs after link
state error is cleared") removed the hcd->speed >= HCD_USB3 guard when
setting the VDEV_PORT_ERROR flag for ports with link state XDEV_INACTIVE
(PLS=6).

Per the xHCI specification, PLS value 6 (SS.Inactive) is only defined
for USB 3.0 ports. For USB 2.0 ports, this value is reserved and may be
read transiently, especially on ports behind Thunderbolt 4 docks with
Realtek USB 2.0 hubs. Without the USB3 guard, these transient reads
cause VDEV_PORT_ERROR to be incorrectly set on USB 2.0 devices,
blocking URB queueing and preventing device enumeration.

Restore the hcd->speed >= HCD_USB3 check on the VDEV_PORT_ERROR set
path, while preserving the other improvements from b69dfcab6894:
- The PORT_RESET guard preventing flag set during active reset
- The PORT_RC path to clear the flag when reset completes
- The vdev->flags = 0 clearing in xhci_discover_or_reset_device()

BugLink: https://bugs.launchpad.net/bugs/2144606
Fixes: b69dfcab6894 ("xhci: fix stale flag preventig URBs after link state error is cleared")
Cc: stable@vger.kernel.org
Signed-off-by: Chia-Lin Kao (AceLan) <acelan.kao@canonical.com>
---
 drivers/usb/host/xhci-ring.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index c94f22d8ea20c..bca44bc13ce75 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2046,7 +2046,8 @@ static void handle_port_status(struct xhci_hcd *xhci, union xhci_trb *event)
 		usb_hcd_resume_root_hub(hcd);
 	}
 
-	if (vdev && (portsc & PORT_PLS_MASK) == XDEV_INACTIVE) {
+	if (hcd->speed >= HCD_USB3 && vdev &&
+	    (portsc & PORT_PLS_MASK) == XDEV_INACTIVE) {
 		if (!(portsc & PORT_RESET))
 			vdev->flags |= VDEV_PORT_ERROR;
 	} else if (vdev && portsc & PORT_RC) {
-- 
2.53.0

