[U-Boot] [PATCH 6/6] usb: Implement static USB port configuration to speed up USB scanning

Stefan Roese sr at denx.de
Fri Mar 11 16:08:24 CET 2016


Hi Hans,

On 10.03.2016 20:18, Hans de Goede wrote:
> Hi,
>
> On 10-03-16 16:50, Stefan Roese wrote:
>> This patch implements an optionally quasi static USB port configuration.
>> This is done by using an environment variable, that describes the ports
>> that shall be scanned at the next USB scans (usb start, usb reset).
>>
>> The "usb_port_use" env variable is used to describe this static USB
>> configuration. For this, each USB hub is represented by a 8-bit value.
>> Making it possible to configure a maximum of 8 ports for each USB hub.
>> A 64-bit representation is used, therefore 8 USB hubs can be described
>> in total.
>>
>> Here an example for this "usb_port_use" environment variable:
>>
>> usb_port_use = 0000000000040301
>> -------------------------------
>> 1st USB hub: 0x01 -> Use port 1 (first port)
>> 2nd USB hub: 0x03 -> Use port 1 and 2
>> 3rd USB hub: 0x04 -> Use port 3
>> 4th USB hub: 0x00 -> Use no ports
>> ...
>> 8th USB hub: 0x00 -> Use no ports
>>
>> To make this procedure of configuring this env variable less error prone
>> and less painful, this patch also introduces another env variable that
>> is dynamically generated at each USB scan: "usb_port_detected". This
>> variable is similar to "usb_port_use". It has a bit enabled for each
>> port that has been detected. This can be easily used on a new system,
>> where the USB configuration is static in this way:
>>
>> Run the USB scan (usb start, usb reset) without the "usb_port_use"
>> variable set. This will result in all ports being scanned and the result
>> written into the "usb_port_detected" variable. To configure the USB
>> subsystem to only scan these specific USB ports upon the next
>> scans, you only need to write the value from "usb_port_detected"
>> into the "usb_port_use" variable:
>>
>> => setenv usb_port_use ${usb_port_detected}
>> => saveenv
>>
>> The next scans will only scan those enabled ports.
>>
>> Its of course also possible to manually "tune" this env variable. If
>> some ports are not needed in U-Boot, they can be disabled this way.
>> This will result in less USB hub ports getting scanned and therefore
>> in a faster USB scan time. Here an example:
>>
>> With all USB devices enabled (usb_port_use not set):
>
> This will fall apart when you get multiple root hubs,
> if you want to do this (I believe there is much more low hanging fruit
> see my previous mails), you somehow need to describe the entire
> path to the hub in the env variable, currently if one hub gets removed,
> other hubs which are children of the same parent will get a different
> number in your hub-numbering scheme and things go awry, also what about
> hubs
> on a second host controller, do those number on from the hub-numbering of
> the first hcd ? That seems vary fragile and will break when we add
> (semi) parallel scanning.
>
> So NACK because this disallows later implementing parallel scanning
> without regressing this feature.

Yes, I see your point. But I still like the idea of this static USB
configuration. Best in a similar way as done in this patch (via some
env variables) to have a flexible means to configure the USB system.
I'll need to re-think this a bit more and will probably get back to
this at some point.

For now, I've removed this patch from the patch series (as you will
have noticed by now).

Thanks for all you comments so far.

Thanks,
Stefan



More information about the U-Boot mailing list