[PATCH 1/4] usb: dwc2: gadget: Fix in TX FIFO initialization flow.
From: Sevak Arakelyan
Date: Wed Apr 26 2017 - 15:23:35 EST
We need to update DPTXFSIZN even if the depth of
current TX FIFO is set to 0.
Loop only for needed TX FIFO count times. This will fix the issue with
wrong insufficient fifo memory WARN_ON.
Signed-off-by: Sevak Arakelyan <sevaka@xxxxxxxxxxxx>
---
drivers/usb/dwc2/gadget.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index bc3b3fda5000..0b2d9bf43283 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -293,9 +293,13 @@ static void dwc2_hsotg_init_fifo(struct dwc2_hsotg *hsotg)
unsigned int ep;
unsigned int addr;
int timeout;
+ int fifo_count;
u32 val;
u32 *txfsz = hsotg->params.g_tx_fifo_size;
+ if (!hsotg->params.enable_dynamic_fifo)
+ return;
+
/* Reset fifo map if not correctly cleared during previous session */
WARN_ON(hsotg->fifo_map);
hsotg->fifo_map = 0;
@@ -321,9 +325,9 @@ static void dwc2_hsotg_init_fifo(struct dwc2_hsotg *hsotg)
* them to endpoints dynamically according to maxpacket size value of
* given endpoint.
*/
- for (ep = 1; ep < MAX_EPS_CHANNELS; ep++) {
- if (!txfsz[ep])
- continue;
+ fifo_count = dwc2_hsotg_tx_fifo_count(hsotg);
+
+ for (ep = 1; ep <= fifo_count; ep++) {
val = addr;
val |= txfsz[ep] << FIFOSIZE_DEPTH_SHIFT;
WARN_ONCE(addr + txfsz[ep] > hsotg->fifo_mem,
--
2.11.0