Skip to contentSkip to conversation

usb: ehci: add ehci max xfer size ehci config entry

PATCH New Gilles DOFFE 3 participants 5 messages Oct 25, 2019 – Nov 13, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: ehci: add ehci max xfer size ehci config entry

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).

---
 drivers/usb/host/Kconfig    | 7 +++++++
 drivers/usb/host/ehci-hcd.c | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/usb/host/Kconfig +7 -0
index 30c6b69be8..62054c9c7a 100644
@@ -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
drivers/usb/host/ehci-hcd.c +1 -1
index 61a61abb21..8be1319079 100644
@@ -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;
 }
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 usb: ehci: add ehci max xfer size ehci config entry

Quoted 5 lines · Gilles DOFFE

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?

Quoted 39 lines
---
 drivers/usb/host/Kconfig    | 7 +++++++
 drivers/usb/host/ehci-hcd.c | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/usb/host/Kconfig +7 -0
index 30c6b69be8..62054c9c7a 100644
@@ -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
drivers/usb/host/ehci-hcd.c +1 -1
index 61a61abb21..8be1319079 100644
@@ -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;
 }
Signature · 4 lines
Robert Hancock
Senior Software Developer
SED Systems, a division of Calian Ltd.
Email: hancock at sedsystems.ca
#2 lore raw

PATCH 1/1 usb: ehci: add ehci max xfer size ehci config entry

Quoted 10 lines · Robert Hancock
Quoted 5 lines · Gilles DOFFE

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?

I presume this is already fixed in u-boot-usb/next by:
https://gitlab.denx.de/u-boot/custodians/u-boot-usb/commit/78d49f89e1dd9bdfa891389343bc3016bcaaeee4
https://gitlab.denx.de/u-boot/custodians/u-boot-usb/commit/b43c016256a5eb1070fbca24309e0e66590b7771
https://gitlab.denx.de/u-boot/custodians/u-boot-usb/commit/4bf7e8b7ad6231cf161fcf95d5c3cc6f1de9fff9

#3 lore raw

PATCH 1/1 usb: ehci: add ehci max xfer size ehci config entry

Quoted 8 lines · Marek Vasut marex at denx.de
Quoted 7 lines · Robert Hancock
Quoted 5 lines · Gilles DOFFE

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).

Quoted 8 lines
Quoted 3 lines

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?

I presume this is already fixed in u-boot-usb/next by:
https://gitlab.denx.de/u-boot/custodians/u-boot-usb/commit/78d49f89e1dd9bdfa891389343bc3016bcaaeee4
https://gitlab.denx.de/u-boot/custodians/u-boot-usb/commit/b43c016256a5eb1070fbca24309e0e66590b7771
https://gitlab.denx.de/u-boot/custodians/u-boot-usb/commit/4bf7e8b7ad6231cf161fcf95d5c3cc6f1de9fff9

Indeed it could solve the problem.
I was not aware of this repo, so I missed it.
Thanks for pointing me on it. I'll give it a try.

#4 lore raw

PATCH 1/1 usb: ehci: add ehci max xfer size ehci config entry

On 11/13/19 9:58 AM, Gilles Doffe wrote:
[...]

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines

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?

Quoted 7 lines
Quoted 4 lines

I presume this is already fixed in u-boot-usb/next by:
https://gitlab.denx.de/u-boot/custodians/u-boot-usb/commit/78d49f89e1dd9bdfa891389343bc3016bcaaeee4
https://gitlab.denx.de/u-boot/custodians/u-boot-usb/commit/b43c016256a5eb1070fbca24309e0e66590b7771
https://gitlab.denx.de/u-boot/custodians/u-boot-usb/commit/4bf7e8b7ad6231cf161fcf95d5c3cc6f1de9fff9

Indeed it could solve the problem.
I was not aware of this repo, so I missed it.

It's a downstream custodian repository. The patches are now in U-Boot master as well, so you can again forget about this repository.

Quoted 1 line

Thanks for pointing me on it. I'll give it a try.

Great, thanks. Please let me know how it went.