[U-Boot] [PATCH] usb: ehci: add ehci max xfer size ehci config entry

Robert Hancock hancock at sedsystems.ca
Mon Oct 28 17:35:01 UTC 2019


On 2019-10-25 8:30 a.m., Gilles DOFFE wrote:
> Some USB sticks cannot handle SIZE_MAX bytes (65535) blocks transfer,
> leading to 'EHCI timed out on TD' errors.
> As it is hardly predictable, this commit adds a configuration option
> to easily reduce this EHCI max transfer size. The default value is 65535
> which corresponds to size_t max value (SIZE_MAX).

This doesn't seem like an ideal solution, as one would have to rebuild
U-Boot to cope with such a device. Do you know how the Linux kernel EHCI
driver deals with this problem?

> 
> Signed-off-by: Gilles DOFFE <gilles.doffe at savoirfairelinux.com>
> ---
>  drivers/usb/host/Kconfig    | 7 +++++++
>  drivers/usb/host/ehci-hcd.c | 2 +-
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
> index 30c6b69be8..62054c9c7a 100644
> --- a/drivers/usb/host/Kconfig
> +++ b/drivers/usb/host/Kconfig
> @@ -222,6 +222,13 @@ config USB_EHCI_FSL
>  	select  CONFIG_EHCI_HCD_INIT_AFTER_RESET
>  	---help---
>  	  Enables support for the on-chip EHCI controller on FSL chips.
> +
> +config USB_EHCI_MAX_XFER_SIZE
> +    int "USB EHCI max transfer size. The default value is 65535 which
> +    corresponds to size_t max value (SIZE_MAX)."
> +    default 65535
> +    range 1 65535
> +
>  endif # USB_EHCI_HCD
>  
>  config USB_OHCI_HCD
> diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> index 61a61abb21..8be1319079 100644
> --- a/drivers/usb/host/ehci-hcd.c
> +++ b/drivers/usb/host/ehci-hcd.c
> @@ -1614,7 +1614,7 @@ static int ehci_get_max_xfer_size(struct udevice *dev, size_t *size)
>  	 * EHCD can handle any transfer length as long as there is enough
>  	 * free heap space left, hence set the theoretical max number here.
>  	 */
> -	*size = SIZE_MAX;
> +	*size = CONFIG_USB_EHCI_MAX_XFER_SIZE;
>  
>  	return 0;
>  }
> 

-- 
Robert Hancock
Senior Software Developer
SED Systems, a division of Calian Ltd.
Email: hancock at sedsystems.ca


More information about the U-Boot mailing list