OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 6:16 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: XHCI and speeds defined by th supported protocols capability
PostPosted: Thu Jun 02, 2022 12:44 am 
Offline
Member
Member
User avatar

Joined: Sun Apr 30, 2017 12:16 pm
Posts: 68
Location: Poland
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)?

_________________
Working on managarm.


Top
 Profile  
 
 Post subject: Re: XHCI and speeds defined by th supported protocols capabi
PostPosted: Thu Jun 02, 2022 4:42 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
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


Top
 Profile  
 
 Post subject: Re: XHCI and speeds defined by th supported protocols capabi
PostPosted: Thu Jun 02, 2022 6:51 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.
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’).


It sounds like Linux is wrong here, but it works anyway because the hardware is also wrong in the same way.


Top
 Profile  
 
 Post subject: Re: XHCI and speeds defined by th supported protocols capabi
PostPosted: Thu Jun 02, 2022 7:36 pm 
Offline
Member
Member
User avatar

Joined: Sun Apr 30, 2017 12:16 pm
Posts: 68
Location: Poland
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.


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.

Linux handles this by ignoring the supported protocol speeds altogether, and I was wondering whether that's the correct solution.

_________________
Working on managarm.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 64 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group