public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* XHCI without USB2 ports
@ 2024-02-12 18:39 Jan Henrik Weinstock
  2024-02-13  9:59 ` Mathias Nyman
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Henrik Weinstock @ 2024-02-12 18:39 UTC (permalink / raw)
  To: mathias.nyman, gregkh, linux-usb, linux-kernel; +Cc: Lukas Jünger

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.

I am new to the USB driver framework, so it's quite likely I am just
overlooking something; but to me it seems that the driver cannot work
unless I have an XHCI device that has at least one USB2 and one USB3
port. But during boot, I only get "USB2 root hub has no ports", which
is not fatal.

Best regards
Jan

[1] https://elixir.bootlin.com/linux/v6.5.6/source/drivers/usb/host/xhci-ring.c#L1895
[2] https://elixir.bootlin.com/linux/v6.5.6/source/drivers/usb/host/xhci-plat.c#L282
[3] https://elixir.bootlin.com/linux/v6.5.6/source/drivers/usb/host/xhci.h#L2001

-- 
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

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

* Re: XHCI without USB2 ports
  2024-02-12 18:39 XHCI without USB2 ports Jan Henrik Weinstock
@ 2024-02-13  9:59 ` Mathias Nyman
  2024-02-13 14:50   ` Jan Henrik Weinstock
  0 siblings, 1 reply; 4+ messages in thread
From: Mathias Nyman @ 2024-02-13  9:59 UTC (permalink / raw)
  To: Jan Henrik Weinstock, mathias.nyman, gregkh, linux-usb,
	linux-kernel
  Cc: Lukas Jünger

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


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

* Re: XHCI without USB2 ports
  2024-02-13  9:59 ` Mathias Nyman
@ 2024-02-13 14:50   ` Jan Henrik Weinstock
  2024-02-13 15:42     ` Mathias Nyman
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Henrik Weinstock @ 2024-02-13 14:50 UTC (permalink / raw)
  To: Mathias Nyman, mathias.nyman, gregkh, linux-usb, linux-kernel
  Cc: Lukas Jünger

Am Di., 13. Feb. 2024 um 10:58 Uhr schrieb Mathias Nyman
<mathias.nyman@linux.intel.com>:
>
> 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

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

* Re: XHCI without USB2 ports
  2024-02-13 14:50   ` Jan Henrik Weinstock
@ 2024-02-13 15:42     ` Mathias Nyman
  0 siblings, 0 replies; 4+ messages in thread
From: Mathias Nyman @ 2024-02-13 15:42 UTC (permalink / raw)
  To: Jan Henrik Weinstock, mathias.nyman, gregkh, linux-usb,
	linux-kernel
  Cc: Lukas Jünger

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

Yes, this is the first one I've heard of.

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

Each USB3 host connector has both a USB3 and USB2 port in the Supported
Protocol Capability.
See xHCI specification 7.2.2.1 "USB Protocols" note:

"Note: To support USB3 device certification requirements for USB2 user attached
  devices, USB 2.0 and USB 3.x Supported Protocol Capabilities shall be declared
  if any USB3 connectors are associated with xHCI Root Hub ports that enable user
  attached devices. Refer to sections 11.1 and 11.3 in the USB3 spec"
> 
> 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.

Yes, that is currently the case.
But normally each USB3 connector has a matching USB3 and USB2 port pair.

USB 3.2 specification section 11.1 dictates that:

11.1 USB 3.2 Host Support for USB 2.0
"USB 3.2-capable ports on hosts shall also support USB 2.0 operation in order
  to enable backward compatibility with USB 2.0 devices. It should be noted,
  however, that USB 3.2-capable hosts are not required to support Enhanced
  SuperSpeed operation on all of the ports available on the host, i.e.,
  some USB 3.2-capable hosts may have a mix of USB 2.0-only and USB 3.2-capable
  ports."

(Similar statement exists in older USB 3.0 specification)

xHC with just one USB3 port could maybe be possible in some built in SSIC device
case without user attachable ports, or some setup with several host controllers
where one handles the USB3 traffic and the other the USB2 traffic of the same USB3
connector.

Thanks
Mathias


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

end of thread, other threads:[~2024-02-13 15:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-12 18:39 XHCI without USB2 ports Jan Henrik Weinstock
2024-02-13  9:59 ` Mathias Nyman
2024-02-13 14:50   ` Jan Henrik Weinstock
2024-02-13 15:42     ` Mathias Nyman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox