Re: XHCI without USB2 ports

From: Jan Henrik Weinstock
Date: Tue Feb 13 2024 - 09:51:03 EST


Am Di., 13. Feb. 2024 um 10:58 Uhr schrieb Mathias Nyman
<mathias.nyman@xxxxxxxxxxxxxxx>:
>
> On 12.2.2024 20.39, Jan Henrik Weinstock wrote:
> > Hi all,
> >
> > I am currently working on an XHCI platform device simulation model. I
> > noticed that the Linux driver (Linux 6.5.6 xhci-hcd) stops working
> > when I configure the model without any USB2 ports. During an interrupt
> > (TRB_PORT_STATUS), I only get "xhci-hcd 12100000.usb: ignore port
> > event for removed USB3 hcd."
> >
> > During xhci_irq, in handle_port_status, xhci->shared_hcd is NULL [1],
> > so the interrupt gets ignored. However, shared_hcd would only ever be
> > allocated during xhci_plat_probe [2], if the device has both USB2 and
> > USB3 ports, i.e. xhci_has_one_roothub returns false [3].
> >
> > Without any USB2 ports, a shared_hcd will never be allocated in the
> > first place, and handle_port_status will always exit early.
>
> This is true.
> That port handling code is from a time before xhci driver supported single
> roothub setups.
>
> I think all single roothub cases so far have been xHC hosts with only USB2
> ports. This is probably the first one with only USB3 ports.
>
> I have a vague memory that USB3 specification would require USB3 ports to
> be backwards compatible, and support USB2.
>
> But xhci driver could still support it, does this change help:
>
> diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
> index f0d8a607ff21..6ef081f5ef05 100644
> --- a/drivers/usb/host/xhci-ring.c
> +++ b/drivers/usb/host/xhci-ring.c
> @@ -1893,7 +1893,8 @@ static void handle_port_status(struct xhci_hcd *xhci,
> }
>
> /* We might get interrupts after shared_hcd is removed */
> - if (port->rhub == &xhci->usb3_rhub && xhci->shared_hcd == NULL) {
> + if (!xhci_has_one_roothub(xhci) && xhci->shared_hcd == NULL &&
> + port->rhub == &xhci->usb3_rhub) {
> xhci_dbg(xhci, "ignore port event for removed USB3 hcd\n");
> bogus_port_status = true;
> goto cleanup;
>
> Thanks
> Mathias
>

Yes, this patch fixes the problem for me. Thanks!

Is it so unusual to have an XHCI that has only USB3 ports?

My understanding was that a port can either be USB3 or USB2 (assigned
via the Supported Protocol Capability).

This would mean that in order to work correctly with Linux, all XHCIs
right now would have to support at least one USB2 port in addition to
their USB3 ports.

Best regards
Jan

--
Dr.-Ing. Jan Henrik Weinstock
Managing Director

MachineWare GmbH | www.machineware.de
Hühnermarkt 19, 52062 Aachen, Germany
Amtsgericht Aachen HRB25734

Geschäftsführung
Lukas Jünger
Dr.-Ing. Jan Henrik Weinstock