The XHCI spec outlines a supported protocol capability, which potentially defines a list of speeds for devices attached to a port supporting that protocol. The driver is expected to use this list of speeds to figure out the device speed on the root hub (PORTSC speed field), and also it is expected to set the speed ID in the slot context to the correct value.
The problem is that I've had a report of a machine on which PORTSC reports speed ID 4, but the supported protocol for that port only lists 3 speeds (IDs 1-3). As such, the driver fails to determine the device speed. After looking at the Linux code for a possible answer, it seems like Linux completely ignores the custom IDs specified by the controller, and instead always uses the default IDs from a table in the spec. For now I've decided to do the same in my driver.
My question is whether is the Linux behavior correct, or have I misunderstood the Linux code (in which case how am I supposed to handle the missing ID)?
XHCI and speeds defined by th supported protocols capability
Re: XHCI and speeds defined by th supported protocols capabi
I don't quite understand what your question is.
The xHCI does have a Supported Protocol Capability list and this list is used to indicate which port register set is to be used depending on the speed of the attached device. USB3 for Super-speed devices, USB2 for lower speeds.
If your specific xHCI card does not support any speeds above, for example, USB 3.0, it will only run at a max speed of USB 3.0. Just because the attached device can and may run at a higher speed, doesn't mean that the HC will run at that speed as well.
When you state that "it" returned a Speed Value of 4, do you mean a speed of 4.0? Probably not. A value of 4 indicates a speed of 3.0Gen1x1, or USB 3.0, Generation 1x1, which is a speed of 5 Gigabits/Sec.
Currently (circa Jan 2022), a value of 7 is the highest speed allowed, requiring a xHCI controller with an HC version of 1.2. This speed is 10 Gigabits/Sec with a name of "USB 3.2, Generation 2x2" or for short, "3.2Gen2x2".
Hope this helps,
Ben
- https://www.fysnet.net/the_universal_serial_bus.htm
The xHCI does have a Supported Protocol Capability list and this list is used to indicate which port register set is to be used depending on the speed of the attached device. USB3 for Super-speed devices, USB2 for lower speeds.
If your specific xHCI card does not support any speeds above, for example, USB 3.0, it will only run at a max speed of USB 3.0. Just because the attached device can and may run at a higher speed, doesn't mean that the HC will run at that speed as well.
When you state that "it" returned a Speed Value of 4, do you mean a speed of 4.0? Probably not. A value of 4 indicates a speed of 3.0Gen1x1, or USB 3.0, Generation 1x1, which is a speed of 5 Gigabits/Sec.
Currently (circa Jan 2022), a value of 7 is the highest speed allowed, requiring a xHCI controller with an HC version of 1.2. This speed is 10 Gigabits/Sec with a name of "USB 3.2, Generation 2x2" or for short, "3.2Gen2x2".
Hope this helps,
Ben
- https://www.fysnet.net/the_universal_serial_bus.htm
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: XHCI and speeds defined by th supported protocols capabi
xHCI § 5.4.8 wrote:Port Speed (Port Speed) – ROS. Default = ‘0’. This field identifies the speed of the connected USB Device. This field is only relevant if a device is connected (CCS = ‘1’) in all other cases this field shall indicate Undefined Speed. Refer to section 4.19.3.
0 = Undefined Speed
1 - 15 = Protocol Speed ID (PSI), refer to section 7.2.1 for the definition of PSIV field in the PSI Dword
Note: This field is invalid on a USB2 protocol port until after the port is reset.
xHCI § 7.2 wrote:Protocol Speed ID Count (PSIC) – RO. This field indicates the number of Protocol Speed ID (PSI) Dwords that the xHCI Supported Protocol Capability data structure contains. If this field is non-zero, then all speeds supported by the protocol shall be defined using PSI Dwords, i.e. no implied Speed ID mappings apply
xHCI § 7.2.1 wrote:Protocol Speed ID Value (PSIV) – RO. If a device is attached that operates at the bit rate defined by this PSI Dword, then the value of this field shall be reported in the Port Speed field of PORTSC register (5.4.8) of a compatible port.
Note, the PSIV value of ‘0’ is reserved and shall not be defined by a PSI.
It sounds like Linux is wrong here, but it works anyway because the hardware is also wrong in the same way.xHCI § 7.2.2.1.1 wrote:The Default Speed ID Values shall be presented in PORTSC Port Speed field only if no PSI Dwords are defined (PSIC = ‘0’).
Re: XHCI and speeds defined by th supported protocols capabi
What I meant is that PORTSC.Port Speed has a value of 4, and the supported protocol associated with this port only defines PSIs 1-3. Possibly worth noting is that those 3 speeds are SSIC speeds.BenLunt wrote:I don't quite understand what your question is.
When you state that "it" returned a Speed Value of 4, do you mean a speed of 4.0? Probably not. A value of 4 indicates a speed of 3.0Gen1x1, or USB 3.0, Generation 1x1, which is a speed of 5 Gigabits/Sec.
Linux handles this by ignoring the supported protocol speeds altogether, and I was wondering whether that's the correct solution.
Working on managarm.