git: 6d5c80aee3ae - main - xhci: only set the slot context parent hub fields on xHCI 1.2

From: Abdelkader Boudih <seuros_at_FreeBSD.org>
Date: Sat, 07 Nov 2026 09:56:21 UTC
The branch main has been updated by seuros:

URL: https://cgit.FreeBSD.org/src/commit/?id=6d5c80aee3ae8b16a0b08b25852430fb076fed37

commit 6d5c80aee3ae8b16a0b08b25852430fb076fed37
Author:     Abdelkader Boudih <seuros@FreeBSD.org>
AuthorDate: 2026-11-07 09:56:13 +0000
Commit:     Abdelkader Boudih <seuros@FreeBSD.org>
CommitDate: 2026-11-07 09:56:13 +0000

    xhci: only set the slot context parent hub fields on xHCI 1.2
    
    The Enhanced SuperSpeed meaning of the slot context parent hub slot ID
    and port number fields was introduced in xHCI 1.2. Controllers built to
    an earlier revision define them only for a Low- or Full-speed device
    behind a High-speed hub.
    
    A SuperSpeed device behind a USB 3.2 hub on an Intel Alpine Ridge
    controller, an xHCI 1.1 part, stops responding to Address Device and
    loops in uhub_reattach_port until the port is disabled.
    
    Fixes:          20b19982545e ("usb: support SSP and SSPx2 xHCI")
    
    Reviewed by:    aokblast, ngie, adrian
    Differential Revision:  https://reviews.freebsd.org/D61278
---
 sys/dev/usb/controller/xhci.c    | 11 +++++++++--
 sys/dev/usb/controller/xhci.h    |  2 ++
 sys/dev/usb/controller/xhcireg.h |  2 ++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c
index 3f3ab299647b..894cd159c281 100644
--- a/sys/dev/usb/controller/xhci.c
+++ b/sys/dev/usb/controller/xhci.c
@@ -574,7 +574,9 @@ xhci_init(struct xhci_softc *sc, device_t self, uint8_t dma32)
 	DPRINTF("RUNTIMEOFFSET=0x%x\n", sc->sc_runt_off);
 	DPRINTF("DOOROFFSET=0x%x\n", sc->sc_door_off);
 
-	DPRINTF("xHCI version = 0x%04x\n", XREAD2(sc, capa, XHCI_HCIVERSION));
+	sc->sc_hcversion = XREAD2(sc, capa, XHCI_HCIVERSION);
+
+	DPRINTF("xHCI version = 0x%04x\n", sc->sc_hcversion);
 
 	if (!(XREAD4(sc, oper, XHCI_PAGESIZE) & XHCI_PAGESIZE_4K)) {
 		device_printf(sc->sc_bus.parent, "Controller does "
@@ -713,7 +715,8 @@ xhci_get_xecp(struct xhci_softc *sc)
 	 * documented in Table 7.2 of eXtensible Host Controller Interface for
 	 * Universal Serial Bus (xHCI) Rev 1.2b 2023.
 	 */
-	device_printf(sc->sc_bus.parent, "xECP capabilities <");
+	device_printf(sc->sc_bus.parent, "xHCI %u.%u, xECP capabilities <",
+	    sc->sc_hcversion >> 8, (sc->sc_hcversion >> 4) & 0xF);
 
 	eec = -1;
 	for (eecp = XHCI_HCS0_XECP(hccp1) << 2;
@@ -2764,6 +2767,10 @@ xhci_ss_parent_hub(struct xhci_softc *sc, struct usb_device *udev,
 	struct usb_device *adev = udev;
 	struct usb_device *hubdev = udev->parent_hub;
 
+	/* These fields have no Enhanced SuperSpeed meaning before xHCI 1.2. */
+	if (sc->sc_hcversion < XHCI_HCIVERSION_1_2)
+		return (NULL);
+
 	if (udev->speed >= xhci_ss_highest(sc))
 		return (NULL);
 
diff --git a/sys/dev/usb/controller/xhci.h b/sys/dev/usb/controller/xhci.h
index 9a84243eb8f5..e54ac6c66bbd 100644
--- a/sys/dev/usb/controller/xhci.h
+++ b/sys/dev/usb/controller/xhci.h
@@ -562,6 +562,8 @@ struct xhci_softc {
 	uint8_t			sc_noslot;
 	/* Enhanced SuperSpeed speed IDs of the controller, see XHCI_PSIV_BIT */
 	uint16_t		sc_ss_psiv;
+	/* xHCI interface version, see XHCI_HCIVERSION_* */
+	uint16_t		sc_hcversion;
 	/* number of ports on root HUB */
 	uint8_t			sc_noport;
 	/* root HUB device configuration */
diff --git a/sys/dev/usb/controller/xhcireg.h b/sys/dev/usb/controller/xhcireg.h
index ac6c7393ab49..ddcab112b941 100644
--- a/sys/dev/usb/controller/xhcireg.h
+++ b/sys/dev/usb/controller/xhcireg.h
@@ -46,6 +46,8 @@
 #define	XHCI_HCIVERSION		0x02	/* RO Interface version number */
 #define	XHCI_HCIVERSION_0_9	0x0090	/* xHCI version 0.9 */
 #define	XHCI_HCIVERSION_1_0	0x0100	/* xHCI version 1.0 */
+#define	XHCI_HCIVERSION_1_1	0x0110	/* xHCI version 1.1 */
+#define	XHCI_HCIVERSION_1_2	0x0120	/* xHCI version 1.2 */
 #define	XHCI_HCSPARAMS1		0x04	/* RO structural parameters 1 */
 #define	XHCI_HCS1_DEVSLOT_MAX(x)((x) & 0xFF)
 #define	XHCI_HCS1_IRQ_MAX(x)	(((x) >> 8) & 0x3FF)