All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] usb: dwc2: Allow selection of data buffer size
@ 2018-02-28 13:16 Alexey Brodkin
  2018-03-01 17:33 ` Marek Vasut
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Brodkin @ 2018-02-28 13:16 UTC (permalink / raw)
  To: u-boot

If we use hardware with very small RAM (let's consider just a couple
of hundreds of kB but not megabytes) it is not super convenient to lose
64kB for statically allocated bufer which most probably won't be used
as big as it is. Typically we'll have much shorter data packages to
excahnge and in the worst case longer packets will be split on separate
transactions.

For those corner-cases user will be able to set his buffer size of
choice via USB_DWC2_BUFFER_SIZE option in menuconfig.

By default we'll use 64 kB as it was hard-coeded before so existing
users shouldn't be affected at all.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Marek Vasut <marex@denx.de>
---
 drivers/usb/host/Kconfig | 12 ++++++++++++
 drivers/usb/host/dwc2.c  |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 90b2f78ec7d9..a7249b7511f4 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -245,3 +245,15 @@ config USB_DWC2
 	  Hi-Speed (480 Mbps), Full-Speed (12 Mbps), and Low-Speed (1.5 Mbps)
 	  operation is compliant to the controller Supplement. If you want to
 	  enable this controller in host mode, say Y.
+
+if USB_DWC2
+config USB_DWC2_BUFFER_SIZE
+	int "Data buffer size in kB"
+	default 64
+	---help---
+	  By default 64 kB buffer is used but if amount of RAM avaialble on
+	  the target is not enough to accommodate allocation of buffer of
+	  that size it is possible to shrink it. Smaller sizes should be fine
+	  because larger transactions could be split in smaller ones.
+
+endif # USB_DWC2
diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index 0efe645044c5..e436c711e720 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -25,7 +25,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define DWC2_HC_CHANNEL			0
 
 #define DWC2_STATUS_BUF_SIZE		64
-#define DWC2_DATA_BUF_SIZE		(64 * 1024)
+#define DWC2_DATA_BUF_SIZE		(CONFIG_USB_DWC2_BUFFER_SIZE * 1024)
 
 #define MAX_DEVICE			16
 #define MAX_ENDPOINT			16
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] usb: dwc2: Allow selection of data buffer size
  2018-02-28 13:16 [U-Boot] [PATCH] usb: dwc2: Allow selection of data buffer size Alexey Brodkin
@ 2018-03-01 17:33 ` Marek Vasut
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Vasut @ 2018-03-01 17:33 UTC (permalink / raw)
  To: u-boot

On 02/28/2018 02:16 PM, Alexey Brodkin wrote:
> If we use hardware with very small RAM (let's consider just a couple
> of hundreds of kB but not megabytes) it is not super convenient to lose
> 64kB for statically allocated bufer which most probably won't be used
> as big as it is. Typically we'll have much shorter data packages to
> excahnge and in the worst case longer packets will be split on separate
> transactions.
> 
> For those corner-cases user will be able to set his buffer size of
> choice via USB_DWC2_BUFFER_SIZE option in menuconfig.
> 
> By default we'll use 64 kB as it was hard-coeded before so existing
> users shouldn't be affected at all.
> 
> Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
> Cc: Marek Vasut <marex@denx.de>

Applied, thanks

-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-01 17:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-28 13:16 [U-Boot] [PATCH] usb: dwc2: Allow selection of data buffer size Alexey Brodkin
2018-03-01 17:33 ` Marek Vasut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.