From 5da9da3109c28aed196d9b18433595ffbae06947 Mon Sep 17 00:00:00 2001 From: William Wu Date: Mon, 22 May 2023 14:19:12 +0800 Subject: [PATCH] usb: dwc3: gadget: prepare at least twice txfifo for each ep The current logic to assign only one max packet limit for each IN endpoint txfifo, it's not enough for some usb functions on Rockchip platforms. For example, on RV1106 platform usb composite device with UVC function, if it sets one max packet limit for IN endpoint txfifo, the UVC function streaming ep may be assigned with ep4-in or ep5-in which have default HW value 1048B. But the UVC function needs to support high bandwidth isochronous transaction in a microframe (two or three transactions per microframe), the ep4-in or ep5-in has not enough txfifo space to fit the UVC. In addition, to meet performance requirement, a minimum TxFIFO size of 2x MaxPacketSize for BULK/ISOC endpoints is recommended in DWC3 databook. So this patch prepares at least twice txfifo for each IN endpoint on Rockchip platforms. Fixes: 767a36082669 ("UPSTREAM: usb: dwc3: gadget: Fix IN endpoint max packet size allocation") Change-Id: If97eb74ab6ec1a32fe162758bc8f704c15fa4f3c Signed-off-by: William Wu --- drivers/usb/dwc3/gadget.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 68ca3b99396e..f97430894f79 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -3195,6 +3195,16 @@ static int dwc3_gadget_init_in_endpoint(struct dwc3_ep *dep) else maxpacket = mdwidth * ((size - 1) - 1) - mdwidth; + + /* + * To meet performance requirement, a minimum TxFIFO size of 2x + * MaxPacketSize is recommended for endpoints that support for + * Rockchip platform with UVC function. + */ + if (IS_REACHABLE(CONFIG_ARCH_ROCKCHIP) && + (dwc->maximum_speed >= USB_SPEED_HIGH)) + maxpacket /= 2; + /* Functionally, space for one max packet is sufficient */ size = min_t(int, maxpacket, 1024); /*