[SLOF] [PATCH 4/4] usb: Build correct route string for USB3 devices behind a hub

Thomas Huth thuth at redhat.com
Tue Aug 2 18:25:55 AEST 2016


On 02.08.2016 04:09, Nikunj A Dadhania wrote:
> Thomas Huth <thuth at redhat.com> writes:
> 
>> To support USB3 devices attached to a hub, we've got to set
>> the so-called "route string" in the slot context, which is
>> a concatenation of the hub port numbers that need to be
>> traversed between the root hub port and the destination device.
>>
>> Signed-off-by: Thomas Huth <thuth at redhat.com>
>> ---
>>  lib/libusb/usb-xhci.c | 14 ++++++++++----
>>  1 file changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/lib/libusb/usb-xhci.c b/lib/libusb/usb-xhci.c
>> index 2d34133..7c931d3 100644
>> --- a/lib/libusb/usb-xhci.c
>> +++ b/lib/libusb/usb-xhci.c
>> @@ -538,7 +538,7 @@ static bool xhci_alloc_dev(struct xhci_hcd *xhcd, struct usb_dev *hub,
>>  	struct xhci_ep_ctx *ep0;
>>  	uint32_t ctx_size, val;
>>  	uint16_t max_packet;
>> -	uint32_t newport;
>> +	uint32_t newport, rootport;
>>
>>  	if (slot_id > XHCI_CONFIG_MAX_SLOT) {
>>  		dprintf("USB3 slot ID %d is too high (max is %d)\n", slot_id,
>> @@ -565,10 +565,16 @@ static bool xhci_alloc_dev(struct xhci_hcd *xhcd, struct usb_dev *hub,
>>
>>  	/* Step 3 */
>>  	slot = xhci_get_slot_ctx(&xdev->in_ctx, ctx_size);
>> -	newport = port + 1;
>> -	val = LAST_CONTEXT(1) | SLOT_SPEED_SS | (newport << 16); /* FIXME speed, read from PS */
>> +	newport = rootport = port + 1;
>> +	val = newport & 0xf;
>> +	for (dev = hub; dev != NULL; dev = dev->hub) {
>> +		val = (val << 4) | (dev->port & 0xf);	/* Build route string */
>> +		rootport = dev->port;
>> +	}
>> +	val >>= 4;
>> +	val |= LAST_CONTEXT(1) | SLOT_SPEED_SS;  /* FIXME speed, read from
>>  	PS */
> 
> I think we will have to get rid of this as well, i.e. getting the SPEED
> from the port structure now.

At least QEMU does not seem to care ... but yes, let's be better safe
than sorry and do it the right way. I'll try to add a corresponding
patch to v2 of my series.

 Thomas



More information about the SLOF mailing list