Skip to contentSkip to conversation

usb: xhci-pci: add support for hosts with zero USB3 ports

PATCH In review Niklas Neronin 2 participants 4 messages Aug 26, 2025 – Oct 10, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: xhci-pci: add support for hosts with zero USB3 ports

Add xhci support for PCI hosts that have zero USB3 ports. Avoid creating a shared Host Controller Driver (HCD) when there is only one root hub. Additionally, all references to 'xhci->shared_hcd' are now checked before use.

Only xhci-pci.c requires modification to accommodate this change, as the xhci core already supports configurations with zero USB3 ports. This capability was introduced when xHCI Platform and MediaTek added support for zero USB3 ports.

---
 drivers/usb/host/xhci-pci.c | 44 +++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 19 deletions(-)
drivers/usb/host/xhci-pci.c +25 -19
index 00fac8b233d2..5c8ab519f497 100644
@@ -610,7 +610,7 @@ int xhci_pci_common_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
 	int retval;
 	struct xhci_hcd *xhci;
-	struct usb_hcd *hcd;
+	struct usb_hcd *hcd, *usb3_hcd;
 	struct reset_control *reset;
 
 	reset = devm_reset_control_get_optional_exclusive(&dev->dev, NULL);
@@ -636,26 +636,32 @@ int xhci_pci_common_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	hcd = dev_get_drvdata(&dev->dev);
 	xhci = hcd_to_xhci(hcd);
 	xhci->reset = reset;
-	xhci->shared_hcd = usb_create_shared_hcd(&xhci_pci_hc_driver, &dev->dev,
-						 pci_name(dev), hcd);
-	if (!xhci->shared_hcd) {
-		retval = -ENOMEM;
-		goto dealloc_usb2_hcd;
+
+	xhci->allow_single_roothub = 1;
+	if (!xhci_has_one_roothub(xhci)) {
+		xhci->shared_hcd = usb_create_shared_hcd(&xhci_pci_hc_driver, &dev->dev,
+							 pci_name(dev), hcd);
+		if (!xhci->shared_hcd) {
+			retval = -ENOMEM;
+			goto dealloc_usb2_hcd;
+		}
+
+		retval = xhci_ext_cap_init(xhci);
+		if (retval)
+			goto put_usb3_hcd;
+
+		retval = usb_add_hcd(xhci->shared_hcd, dev->irq, IRQF_SHARED);
+		if (retval)
+			goto put_usb3_hcd;
+	} else {
+		retval = xhci_ext_cap_init(xhci);
+		if (retval)
+			goto dealloc_usb2_hcd;
 	}
 
-	retval = xhci_ext_cap_init(xhci);
-	if (retval)
-		goto put_usb3_hcd;
-
-	retval = usb_add_hcd(xhci->shared_hcd, dev->irq,
-			IRQF_SHARED);
-	if (retval)
-		goto put_usb3_hcd;
-	/* Roothub already marked as USB 3.0 speed */
-
-	if (!(xhci->quirks & XHCI_BROKEN_STREAMS) &&
-			HCC_MAX_PSA(xhci->hcc_params) >= 4)
-		xhci->shared_hcd->can_do_streams = 1;
+	usb3_hcd = xhci_get_usb3_hcd(xhci);
+	if (usb3_hcd && !(xhci->quirks & XHCI_BROKEN_STREAMS) && HCC_MAX_PSA(xhci->hcc_params) >= 4)
+		usb3_hcd->can_do_streams = 1;
 
 	/* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */
 	pm_runtime_put_noidle(&dev->dev);
Signature · 1 line
2.50.1
#1 lore raw

Regression - commit 719de070f764 usb: xhci-pci: add support for hosts with zero USB3 ports

Quoted 10 lines · Niklas Neronin

Add xhci support for PCI hosts that have zero USB3 ports. Avoid creating a shared Host Controller Driver (HCD) when there is only one root hub. Additionally, all references to 'xhci->shared_hcd' are now checked before use.

Only xhci-pci.c requires modification to accommodate this change, as the xhci core already supports configurations with zero USB3 ports. This capability was introduced when xHCI Platform and MediaTek added support for zero USB3 ports.

Quoted 4 lines

Hello,

while testing 6.18 merge window snapshots, I hit an issue which bisected to this patch, mainline commit 719de070f764 ("usb: xhci-pci: add support for hosts with zero USB3 ports").

When booting any kernel with it, my keyboard attached to USB port intended for it does not respond. Comparing the logs between "good" and "bad" kernel boot, it looks like hubs 9 and 10 are not detected at all when booting a kernel with commit 719de070f764.

This is what the topology looks like when booting "good" kernel (v6.17):

lion:~ # lsusb -t

/:  Bus 10.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/0p, 5000M
/:  Bus 09.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 1: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 1: Dev 3, If 1, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 1: Dev 3, If 2, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 3: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 3: Dev 4, If 1, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 3: Dev 4, If 2, Class=Human Interface Device, Driver=usbhid, 12M
/:  Bus 08.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 10000M
    |__ Port 2: Dev 2, If 0, Class=Hub, Driver=hub/4p, 5000M
/:  Bus 07.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
    |__ Port 2: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 2: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 4: Dev 4, If 0, Class=Audio, Driver=snd-usb-audio, 12M
        |__ Port 4: Dev 4, If 1, Class=Audio, Driver=snd-usb-audio, 12M
        |__ Port 4: Dev 4, If 2, Class=Audio, Driver=snd-usb-audio, 12M
        |__ Port 4: Dev 4, If 3, Class=Human Interface Device, Driver=usbhid, 12M
/:  Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 10000M
/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 20000M/x2
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/5p, 20000M/x2
    |__ Port 3: Dev 2, If 0, Class=Hub, Driver=hub/4p, 5000M
        |__ Port 4: Dev 3, If 0, Class=Hub, Driver=hub/4p, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M
    |__ Port 2: Dev 2, If 0, Class=Video, Driver=uvcvideo, 480M
    |__ Port 2: Dev 2, If 1, Class=Video, Driver=uvcvideo, 480M
    |__ Port 2: Dev 2, If 2, Class=Audio, Driver=snd-usb-audio, 480M
    |__ Port 2: Dev 2, If 3, Class=Audio, Driver=snd-usb-audio, 480M
    |__ Port 2: Dev 2, If 4, Class=Vendor Specific Class, Driver=, 480M
    |__ Port 2: Dev 2, If 5, Class=Human Interface Device, Driver=usbhid, 480M
    |__ Port 3: Dev 3, If 0, Class=Hub, Driver=hub/4p, 480M

|__ Port 4: Dev 5, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 2: Dev 6, If 0, Class=Human Interface Device, Driver=usbhid, 12M |__ Port 2: Dev 6, If 1, Class=Chip/SmartCard, Driver=usbfs, 12M
|__ Port 6: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 12M |__ Port 6: Dev 4, If 1, Class=Human Interface Device, Driver=usbhid, 12M |__ Port 8: Dev 7, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M

lion:~ # lsusb
Bus 009 Device 004: ID 0951:16b7 Kingston Technology HyperX Alloy FPS Mechanical Gaming Keyboard Bus 009 Device 003: ID 1532:00b2 Razer USA, Ltd Razer DeathAdder V3
Bus 009 Device 002: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 009 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 010 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 008 Device 002: ID 0bda:0411 Realtek Semiconductor Corp. Hub
Bus 008 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 007 Device 004: ID 1532:0511 Razer USA, Ltd RZ19-0229 Gaming Microphone
Bus 007 Device 003: ID 051d:0002 American Power Conversion Uninterruptible Power Supply Bus 007 Device 002: ID 0bda:5411 Realtek Semiconductor Corp. RTS5411 Hub
Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 0bda:0411 Realtek Semiconductor Corp. Hub
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp. Hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 007: ID 04f2:0110 Chicony Electronics Co., Ltd KU-2971 Keyboard Bus 001 Device 004: ID 048d:5711 Integrated Technology Express, Inc. GIGABYTE Device Bus 001 Device 006: ID 1050:0406 Yubico.com Yubikey 4/5 U2F+CCID
Bus 001 Device 005: ID 0bda:5411 Realtek Semiconductor Corp. RTS5411 Hub
Bus 001 Device 003: ID 0bda:5411 Realtek Semiconductor Corp. RTS5411 Hub
Bus 001 Device 002: ID 046d:0893 Logitech, Inc. StreamCam
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Please tell me if you need more information.

Michal Kubecek

#2 lore raw

Re: Regression - commit 719de070f764 usb: xhci-pci: add support for hosts with zero USB3 ports

Quoted 18 lines · Michal Kubecek
Quoted 10 lines · Niklas Neronin

Add xhci support for PCI hosts that have zero USB3 ports. Avoid creating a shared Host Controller Driver (HCD) when there is only one root hub. Additionally, all references to 'xhci->shared_hcd' are now checked before use.

Only xhci-pci.c requires modification to accommodate this change, as the xhci core already supports configurations with zero USB3 ports. This capability was introduced when xHCI Platform and MediaTek added support for zero USB3 ports.

Quoted 4 lines

Hello,

Quoted 9 lines

while testing 6.18 merge window snapshots, I hit an issue which bisected to this patch, mainline commit 719de070f764 ("usb: xhci-pci: add support for hosts with zero USB3 ports").

When booting any kernel with it, my keyboard attached to USB port intended for it does not respond. Comparing the logs between "good" and "bad" kernel boot, it looks like hubs 9 and 10 are not detected at all when booting a kernel with commit 719de070f764.

Hello,

Thank you for reporting.

A fix has been proposed in this thread:
https://lore.kernel.org/linux-usb/CABpa4MA9unucCoKtSdzJyOLjHNVy+Cwgz5AnAxPkKw6vuox1Nw@mail.gmail.com/

The specific fix:
https://lore.kernel.org/linux-usb/[email protected]/

Best Regards,
Niklas

#3 lore raw

Re: Regression - commit 719de070f764 usb: xhci-pci: add support for hosts with zero USB3 ports

Quoted 4 lines · Niklas

Hello,

Thank you for reporting.

Quoted 8 lines

A fix has been proposed in this thread:
https://lore.kernel.org/linux-usb/CABpa4MA9unucCoKtSdzJyOLjHNVy+Cwgz5AnAxPkKw6vuox1Nw@mail.gmail.com/

The specific fix:
https://lore.kernel.org/linux-usb/[email protected]/

Best Regards,
Niklas

Thank you for a quick reply. I'll test the patch on my system.

Michal