[U-Boot] [PATCH v4 2/2] common: usb_storage : Implement logic to calculate optimal usb maximum trasfer blocks

Simon Glass sjg at chromium.org
Fri Jun 10 02:34:55 CEST 2016


On 9 June 2016 at 00:32, Rajesh Bhagat <rajesh.bhagat at nxp.com> wrote:
> From: Rajesh Bhagat <rajesh.bhagat at freescale.com>
>
> Implements the logic to calculate the optimal usb maximum trasfer blocks
> instead of sending USB_MAX_XFER_BLK blocks which is 65535 and 20 in case
> of EHCI and other USB protocols respectively.
>
> It defines USB_MIN_XFER_BLK/USB_MAX_XFER_BLK trasfer blocks that should
> be checked for success starting from minimum to maximum, and rest of the
> read/write are performed with that optimal value. It tries to increase/
> decrease the blocks in follwing scenarios:
>
> 1.decrease blocks: when read/write for a particular number of blocks
> fails.
> 2. increase blocks: when read/write for a particular number of blocks
> pass and amount left to trasfer is greater than current number of
> blocks.
>
> Currently changes are done for EHCI where min = 4096 and max = 65535
> is taken. And for other cases code is left unchanged by keeping min
> = max = 20.
>
> Signed-off-by: Sriram Dash <sriram.dash at nxp.com>
> Signed-off-by: Rajesh Bhagat <rajesh.bhagat at nxp.com>
> ---
> Changes in v4:
>  - Adds udev paramater in dec/inc_cur_xfer_blks function and adds
>    sanity check on it.
>  - Changes type of pos varible to unsigned int in dec/inc_cur_xfer_blks
>  - Removes usage of pos varible from usb_stor_read/write
>
> Changes in v3:
>  - Adds cur_xfer_blks in struct usb_device to retain values
>  - Adds functions dec/inc_cur_xfer_blks to remove code duplication
>  - Moves check from macro to calling functions
>
> Changes in v2:
>  - Removes table to store blocks and use formula (1 << (12 + n)) - 1
>  - Adds logic to start from minimum, go to maximum in each read/write
>
>  common/usb_storage.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++----
>  include/usb.h        |  1 +
>  2 files changed, 64 insertions(+), 5 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>

I'm not keen on the 'unsigned short' for the size. Perhaps add a
comment to your 65535 #define that it cannot go higher?


More information about the U-Boot mailing list