All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: xhci-pci: add support for hosts with zero USB3 ports
@ 2025-08-26 10:04 Niklas Neronin
  2025-10-10 13:12 ` Regression - commit 719de070f764 " Michal Kubecek
  0 siblings, 1 reply; 4+ messages in thread
From: Niklas Neronin @ 2025-08-26 10:04 UTC (permalink / raw)
  To: mathias.nyman; +Cc: linux-usb, Niklas Neronin, Nick Nielsen, grm1

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.

Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220181
Tested-by: Nick Nielsen <nick.kainielsen@free.fr>
Tested-by: grm1 <grm1@mailbox.org>
Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
---
 drivers/usb/host/xhci-pci.c | 44 +++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 00fac8b233d2..5c8ab519f497 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -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);
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Regression - commit 719de070f764 usb: xhci-pci: add support for hosts with zero USB3 ports
  2025-08-26 10:04 [PATCH] usb: xhci-pci: add support for hosts with zero USB3 ports Niklas Neronin
@ 2025-10-10 13:12 ` Michal Kubecek
  2025-10-10 13:24   ` Neronin, Niklas
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Kubecek @ 2025-10-10 13:12 UTC (permalink / raw)
  To: Niklas Neronin; +Cc: mathias.nyman, linux-usb, Nick Nielsen, grm1

[-- Attachment #1: Type: text/plain, Size: 5997 bytes --]

On Tue, Aug 26, 2025 at 12:04:16PM GMT, Niklas Neronin wrote:
> 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.
> 
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220181
> Tested-by: Nick Nielsen <nick.kainielsen@free.fr>
> Tested-by: grm1 <grm1@mailbox.org>
> Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Regression - commit 719de070f764 usb: xhci-pci: add support for hosts with zero USB3 ports
  2025-10-10 13:12 ` Regression - commit 719de070f764 " Michal Kubecek
@ 2025-10-10 13:24   ` Neronin, Niklas
  2025-10-10 13:31     ` Michal Kubecek
  0 siblings, 1 reply; 4+ messages in thread
From: Neronin, Niklas @ 2025-10-10 13:24 UTC (permalink / raw)
  To: Michal Kubecek; +Cc: mathias.nyman, linux-usb, Nick Nielsen, grm1



On 10/10/2025 16.12, Michal Kubecek wrote:
> On Tue, Aug 26, 2025 at 12:04:16PM GMT, Niklas Neronin wrote:
>> 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.
>>
>> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220181
>> Tested-by: Nick Nielsen <nick.kainielsen@free.fr>
>> Tested-by: grm1 <grm1@mailbox.org>
>> Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
> 
> 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.
> 

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/20251009142911.6069c164.michal.pecio@gmail.com/

Best Regards,
Niklas


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Regression - commit 719de070f764 usb: xhci-pci: add support for hosts with zero USB3 ports
  2025-10-10 13:24   ` Neronin, Niklas
@ 2025-10-10 13:31     ` Michal Kubecek
  0 siblings, 0 replies; 4+ messages in thread
From: Michal Kubecek @ 2025-10-10 13:31 UTC (permalink / raw)
  To: Neronin, Niklas; +Cc: mathias.nyman, linux-usb, Nick Nielsen, grm1

On Fri, Oct 10, 2025 at 04:24:20PM GMT, Neronin, Niklas wrote:
> 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/20251009142911.6069c164.michal.pecio@gmail.com/
> 
> Best Regards,
> Niklas

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

Michal

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-10-10 13:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-26 10:04 [PATCH] usb: xhci-pci: add support for hosts with zero USB3 ports Niklas Neronin
2025-10-10 13:12 ` Regression - commit 719de070f764 " Michal Kubecek
2025-10-10 13:24   ` Neronin, Niklas
2025-10-10 13:31     ` Michal Kubecek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.