Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: dwc3: drop FIFO resizing logic

That FIFO resizing logic was added to support OMAP5
ES1.0 which had a bogus default FIFO size. I can't
remember the exact size of default FIFO, but it was
less than one bulk superspeed packet (<1024) which
would prevent USB3 from ever working on OMAP5 ES1.0.

However, OMAP5 ES1.0 support has been dropped by
commit aa2f4b16f830 ("ARM: OMAP5: id: Remove ES1.0
support") which renders FIFO resizing unnecessary.

Tested-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

+2 -108
+2 -2
Documentation/devicetree/bindings/usb/dwc3.txt
··· 14 14 the second element is expected to be a handle to the USB3/SS PHY 15 15 - phys: from the *Generic PHY* bindings 16 16 - phy-names: from the *Generic PHY* bindings 17 - - tx-fifo-resize: determines if the FIFO *has* to be reallocated. 18 17 - snps,usb3_lpm_capable: determines if platform is USB3 LPM capable 19 18 - snps,disable_scramble_quirk: true when SW should disable data scrambling. 20 19 Only really useful for FPGA builds. ··· 46 47 register for post-silicon frame length adjustment when the 47 48 fladj_30mhz_sdbnd signal is invalid or incorrect. 48 49 50 + - <DEPRECATED> tx-fifo-resize: determines if the FIFO *has* to be reallocated. 51 + 49 52 This is usually a subnode to DWC3 glue to which it is connected. 50 53 51 54 dwc3@4a030000 { ··· 55 54 reg = <0x4a030000 0xcfff>; 56 55 interrupts = <0 92 4> 57 56 usb-phy = <&usb2_phy>, <&usb3,phy>; 58 - tx-fifo-resize; 59 57 };
-1
Documentation/devicetree/bindings/usb/qcom,dwc3.txt
··· 59 59 interrupts = <0 205 0x4>; 60 60 phys = <&hs_phy>, <&ss_phy>; 61 61 phy-names = "usb2-phy", "usb3-phy"; 62 - tx-fifo-resize; 63 62 dr_mode = "host"; 64 63 }; 65 64 };
-4
drivers/usb/dwc3/core.c
··· 882 882 dwc->usb3_lpm_capable = device_property_read_bool(dev, 883 883 "snps,usb3_lpm_capable"); 884 884 885 - dwc->needs_fifo_resize = device_property_read_bool(dev, 886 - "tx-fifo-resize"); 887 - 888 885 dwc->disable_scramble_quirk = device_property_read_bool(dev, 889 886 "snps,disable_scramble_quirk"); 890 887 dwc->u2exit_lfps_quirk = device_property_read_bool(dev, ··· 923 926 if (pdata->hird_threshold) 924 927 hird_threshold = pdata->hird_threshold; 925 928 926 - dwc->needs_fifo_resize = pdata->tx_fifo_resize; 927 929 dwc->usb3_lpm_capable = pdata->usb3_lpm_capable; 928 930 dwc->dr_mode = pdata->dr_mode; 929 931
-5
drivers/usb/dwc3/core.h
··· 709 709 * 0 - utmi_sleep_n 710 710 * 1 - utmi_l1_suspend_n 711 711 * @is_fpga: true when we are using the FPGA board 712 - * @needs_fifo_resize: not all users might want fifo resizing, flag it 713 712 * @pullups_connected: true when Run/Stop bit is set 714 - * @resize_fifos: tells us it's ok to reconfigure our TxFIFO sizes. 715 713 * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround 716 714 * @start_config_issued: true when StartConfig command has been issued 717 715 * @three_stage_setup: set if we perform a three phase setup ··· 853 855 unsigned has_lpm_erratum:1; 854 856 unsigned is_utmi_l1_suspend:1; 855 857 unsigned is_fpga:1; 856 - unsigned needs_fifo_resize:1; 857 858 unsigned pullups_connected:1; 858 - unsigned resize_fifos:1; 859 859 unsigned setup_packet_pending:1; 860 860 unsigned three_stage_setup:1; 861 861 unsigned usb3_lpm_capable:1; ··· 1021 1025 1022 1026 /* prototypes */ 1023 1027 void dwc3_set_mode(struct dwc3 *dwc, u32 mode); 1024 - int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc); 1025 1028 1026 1029 /* check whether we are on the DWC_usb31 core */ 1027 1030 static inline bool dwc3_is_usb31(struct dwc3 *dwc)
-9
drivers/usb/dwc3/ep0.c
··· 586 586 reg = dwc3_readl(dwc->regs, DWC3_DCTL); 587 587 reg |= (DWC3_DCTL_ACCEPTU1ENA | DWC3_DCTL_ACCEPTU2ENA); 588 588 dwc3_writel(dwc->regs, DWC3_DCTL, reg); 589 - 590 - dwc->resize_fifos = true; 591 - dwc3_trace(trace_dwc3_ep0, "resize FIFOs flag SET"); 592 589 } 593 590 break; 594 591 ··· 1024 1027 1025 1028 static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep) 1026 1029 { 1027 - if (dwc->resize_fifos) { 1028 - dwc3_trace(trace_dwc3_ep0, "Resizing FIFOs"); 1029 - dwc3_gadget_resize_tx_fifos(dwc); 1030 - dwc->resize_fifos = 0; 1031 - } 1032 - 1033 1030 WARN_ON(dwc3_ep0_start_control_status(dep)); 1034 1031 } 1035 1032
-86
drivers/usb/dwc3/gadget.c
··· 145 145 return -ETIMEDOUT; 146 146 } 147 147 148 - /** 149 - * dwc3_gadget_resize_tx_fifos - reallocate fifo spaces for current use-case 150 - * @dwc: pointer to our context structure 151 - * 152 - * This function will a best effort FIFO allocation in order 153 - * to improve FIFO usage and throughput, while still allowing 154 - * us to enable as many endpoints as possible. 155 - * 156 - * Keep in mind that this operation will be highly dependent 157 - * on the configured size for RAM1 - which contains TxFifo -, 158 - * the amount of endpoints enabled on coreConsultant tool, and 159 - * the width of the Master Bus. 160 - * 161 - * In the ideal world, we would always be able to satisfy the 162 - * following equation: 163 - * 164 - * ((512 + 2 * MDWIDTH-Bytes) + (Number of IN Endpoints - 1) * \ 165 - * (3 * (1024 + MDWIDTH-Bytes) + MDWIDTH-Bytes)) / MDWIDTH-Bytes 166 - * 167 - * Unfortunately, due to many variables that's not always the case. 168 - */ 169 - int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc) 170 - { 171 - int last_fifo_depth = 0; 172 - int ram1_depth; 173 - int fifo_size; 174 - int mdwidth; 175 - int num; 176 - 177 - if (!dwc->needs_fifo_resize) 178 - return 0; 179 - 180 - ram1_depth = DWC3_RAM1_DEPTH(dwc->hwparams.hwparams7); 181 - mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0); 182 - 183 - /* MDWIDTH is represented in bits, we need it in bytes */ 184 - mdwidth >>= 3; 185 - 186 - /* 187 - * FIXME For now we will only allocate 1 wMaxPacketSize space 188 - * for each enabled endpoint, later patches will come to 189 - * improve this algorithm so that we better use the internal 190 - * FIFO space 191 - */ 192 - for (num = 0; num < dwc->num_in_eps; num++) { 193 - /* bit0 indicates direction; 1 means IN ep */ 194 - struct dwc3_ep *dep = dwc->eps[(num << 1) | 1]; 195 - int mult = 1; 196 - int tmp; 197 - 198 - if (!(dep->flags & DWC3_EP_ENABLED)) 199 - continue; 200 - 201 - if (usb_endpoint_xfer_bulk(dep->endpoint.desc) 202 - || usb_endpoint_xfer_isoc(dep->endpoint.desc)) 203 - mult = 3; 204 - 205 - /* 206 - * REVISIT: the following assumes we will always have enough 207 - * space available on the FIFO RAM for all possible use cases. 208 - * Make sure that's true somehow and change FIFO allocation 209 - * accordingly. 210 - * 211 - * If we have Bulk or Isochronous endpoints, we want 212 - * them to be able to be very, very fast. So we're giving 213 - * those endpoints a fifo_size which is enough for 3 full 214 - * packets 215 - */ 216 - tmp = mult * (dep->endpoint.maxpacket + mdwidth); 217 - tmp += mdwidth; 218 - 219 - fifo_size = DIV_ROUND_UP(tmp, mdwidth); 220 - 221 - fifo_size |= (last_fifo_depth << 16); 222 - 223 - dwc3_trace(trace_dwc3_gadget, "%s: Fifo Addr %04x Size %d", 224 - dep->name, last_fifo_depth, fifo_size & 0xffff); 225 - 226 - dwc3_writel(dwc->regs, DWC3_GTXFIFOSIZ(num), fifo_size); 227 - 228 - last_fifo_depth += (fifo_size & 0xffff); 229 - } 230 - 231 - return 0; 232 - } 233 - 234 148 void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, 235 149 int status) 236 150 {
-1
drivers/usb/dwc3/platform_data.h
··· 23 23 struct dwc3_platform_data { 24 24 enum usb_device_speed maximum_speed; 25 25 enum usb_dr_mode dr_mode; 26 - bool tx_fifo_resize; 27 26 bool usb3_lpm_capable; 28 27 29 28 unsigned is_utmi_l1_suspend:1;