From e658b2131e7943e4fffd7d413b65b11b23c77686 Mon Sep 17 00:00:00 2001 From: Ren Jianing Date: Mon, 30 Nov 2020 15:00:08 +0800 Subject: [PATCH] usb: dwc3: gadget: fix tx fifos resize for disabled eps If we put other gadget function before UVC, for example UAC and UVC, the ep1in will be assigned to UAC and ep2in/ep3in will be assigned to UVC. Under these circumstances, if we open UVC before UAC, ep1in tx fifo will not be resized and get wrong base address which leading to UVC and UAC can not be opened at the same time. This patch make all epin tx fifos resized whether it is enabled or not. For RV1126/RV1109, total size of tx fifos is 0x51e(1310) and number of epin is 7 (Include ep0in). We can configured as UAC + RNDIS + UVC + ADB, followed by details of functions. | function | epin | xfer | mult |maxpacket(B)| fifo(* 8B)| -------------------------------------------------------- | CTRL | 0 | ctl | 1 | 64 | 10 | | UAC | 1 | isoc | 2 | 200 | 53 | | RNDIS | 2 | int | 1 | 8 | 3 | | RNDIS | 3 | bulk | 3 | 512 | 196 | | UVC | 4 | int | 1 | 16 | 4 | | UVC | 5 | isoc | 6 | 1024 | 775 | | ADB | 6 | bulk | 3 | 512 | 196 | | total | - | - | - | - | 1237 | Attention, the max_packetsize of UAC can be increased to 1024 to support multi-channel or high sampling depth. If we need all these four functions, we can set max_packetsize of UAC to (((1310 - 1237 + 53 ) * 8 - 8) / 2 - 8 = 492 Bytes at most, which can support 48K 16bits 5-channel audio source. Fixes: d4037f52e22b ("usb: dwc3: gadget: fix fifo number for txfifo resize") Signed-off-by: Ren Jianing Change-Id: Ib2d3854bd305289c30ea85c447eca49af28b62fd --- drivers/usb/dwc3/gadget.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index edbb47f8b840..00271cf32c8a 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -184,11 +184,8 @@ static int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc) continue; if (!(dep->flags & DWC3_EP_ENABLED)) { - fifo_number++; - continue; - } - - if (usb_endpoint_xfer_bulk(dep->endpoint.desc)) { + mult = 2; + } else if (usb_endpoint_xfer_bulk(dep->endpoint.desc)) { mult = 3; } else if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { if (dep->endpoint.mult > 0)