Skip to content

Commit 719de07

Browse files
Epicuriusgregkh
authored andcommitted
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. 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> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20250917210726.97100-4-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0ed023a commit 719de07

1 file changed

Lines changed: 24 additions & 18 deletions

File tree

drivers/usb/host/xhci-pci.c

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ int xhci_pci_common_probe(struct pci_dev *dev, const struct pci_device_id *id)
610610
{
611611
int retval;
612612
struct xhci_hcd *xhci;
613-
struct usb_hcd *hcd;
613+
struct usb_hcd *hcd, *usb3_hcd;
614614
struct reset_control *reset;
615615

616616
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)
636636
hcd = dev_get_drvdata(&dev->dev);
637637
xhci = hcd_to_xhci(hcd);
638638
xhci->reset = reset;
639-
xhci->shared_hcd = usb_create_shared_hcd(&xhci_pci_hc_driver, &dev->dev,
640-
pci_name(dev), hcd);
641-
if (!xhci->shared_hcd) {
642-
retval = -ENOMEM;
643-
goto dealloc_usb2_hcd;
644-
}
645639

646-
retval = xhci_ext_cap_init(xhci);
647-
if (retval)
648-
goto put_usb3_hcd;
640+
xhci->allow_single_roothub = 1;
641+
if (!xhci_has_one_roothub(xhci)) {
642+
xhci->shared_hcd = usb_create_shared_hcd(&xhci_pci_hc_driver, &dev->dev,
643+
pci_name(dev), hcd);
644+
if (!xhci->shared_hcd) {
645+
retval = -ENOMEM;
646+
goto dealloc_usb2_hcd;
647+
}
649648

650-
retval = usb_add_hcd(xhci->shared_hcd, dev->irq,
651-
IRQF_SHARED);
652-
if (retval)
653-
goto put_usb3_hcd;
654-
/* Roothub already marked as USB 3.0 speed */
649+
retval = xhci_ext_cap_init(xhci);
650+
if (retval)
651+
goto put_usb3_hcd;
652+
653+
retval = usb_add_hcd(xhci->shared_hcd, dev->irq, IRQF_SHARED);
654+
if (retval)
655+
goto put_usb3_hcd;
656+
} else {
657+
retval = xhci_ext_cap_init(xhci);
658+
if (retval)
659+
goto dealloc_usb2_hcd;
660+
}
655661

656-
if (!(xhci->quirks & XHCI_BROKEN_STREAMS) &&
657-
HCC_MAX_PSA(xhci->hcc_params) >= 4)
658-
xhci->shared_hcd->can_do_streams = 1;
662+
usb3_hcd = xhci_get_usb3_hcd(xhci);
663+
if (usb3_hcd && !(xhci->quirks & XHCI_BROKEN_STREAMS) && HCC_MAX_PSA(xhci->hcc_params) >= 4)
664+
usb3_hcd->can_do_streams = 1;
659665

660666
/* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */
661667
pm_runtime_put_noidle(&dev->dev);

0 commit comments

Comments
 (0)