096-07-usb-dwc3-drop-FIFO-resizing-logic.patch 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. From bc5081617faeb3b2f0c126dc37264b87af7da47f Mon Sep 17 00:00:00 2001
  2. From: Felipe Balbi <felipe.balbi@linux.intel.com>
  3. Date: Thu, 4 Feb 2016 14:18:01 +0200
  4. Subject: usb: dwc3: drop FIFO resizing logic
  5. That FIFO resizing logic was added to support OMAP5
  6. ES1.0 which had a bogus default FIFO size. I can't
  7. remember the exact size of default FIFO, but it was
  8. less than one bulk superspeed packet (<1024) which
  9. would prevent USB3 from ever working on OMAP5 ES1.0.
  10. However, OMAP5 ES1.0 support has been dropped by
  11. commit aa2f4b16f830 ("ARM: OMAP5: id: Remove ES1.0
  12. support") which renders FIFO resizing unnecessary.
  13. Tested-by: Kishon Vijay Abraham I <kishon@ti.com>
  14. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
  15. ---
  16. Documentation/devicetree/bindings/usb/dwc3.txt | 4 +-
  17. .../devicetree/bindings/usb/qcom,dwc3.txt | 1 -
  18. drivers/usb/dwc3/core.c | 4 -
  19. drivers/usb/dwc3/core.h | 5 --
  20. drivers/usb/dwc3/ep0.c | 9 ---
  21. drivers/usb/dwc3/gadget.c | 86 ----------------------
  22. drivers/usb/dwc3/platform_data.h | 1 -
  23. 7 files changed, 2 insertions(+), 108 deletions(-)
  24. --- a/Documentation/devicetree/bindings/usb/dwc3.txt
  25. +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
  26. @@ -14,7 +14,6 @@ Optional properties:
  27. the second element is expected to be a handle to the USB3/SS PHY
  28. - phys: from the *Generic PHY* bindings
  29. - phy-names: from the *Generic PHY* bindings
  30. - - tx-fifo-resize: determines if the FIFO *has* to be reallocated.
  31. - snps,usb3_lpm_capable: determines if platform is USB3 LPM capable
  32. - snps,disable_scramble_quirk: true when SW should disable data scrambling.
  33. Only really useful for FPGA builds.
  34. @@ -47,6 +46,8 @@ Optional properties:
  35. register for post-silicon frame length adjustment when the
  36. fladj_30mhz_sdbnd signal is invalid or incorrect.
  37. + - <DEPRECATED> tx-fifo-resize: determines if the FIFO *has* to be reallocated.
  38. +
  39. This is usually a subnode to DWC3 glue to which it is connected.
  40. dwc3@4a030000 {
  41. @@ -54,5 +55,4 @@ dwc3@4a030000 {
  42. reg = <0x4a030000 0xcfff>;
  43. interrupts = <0 92 4>
  44. usb-phy = <&usb2_phy>, <&usb3,phy>;
  45. - tx-fifo-resize;
  46. };
  47. --- a/Documentation/devicetree/bindings/usb/qcom,dwc3.txt
  48. +++ b/Documentation/devicetree/bindings/usb/qcom,dwc3.txt
  49. @@ -59,7 +59,6 @@ Example device nodes:
  50. interrupts = <0 205 0x4>;
  51. phys = <&hs_phy>, <&ss_phy>;
  52. phy-names = "usb2-phy", "usb3-phy";
  53. - tx-fifo-resize;
  54. dr_mode = "host";
  55. };
  56. };
  57. --- a/drivers/usb/dwc3/core.c
  58. +++ b/drivers/usb/dwc3/core.c
  59. @@ -882,9 +882,6 @@ static int dwc3_probe(struct platform_de
  60. dwc->usb3_lpm_capable = device_property_read_bool(dev,
  61. "snps,usb3_lpm_capable");
  62. - dwc->needs_fifo_resize = device_property_read_bool(dev,
  63. - "tx-fifo-resize");
  64. -
  65. dwc->disable_scramble_quirk = device_property_read_bool(dev,
  66. "snps,disable_scramble_quirk");
  67. dwc->u2exit_lfps_quirk = device_property_read_bool(dev,
  68. @@ -926,7 +923,6 @@ static int dwc3_probe(struct platform_de
  69. if (pdata->hird_threshold)
  70. hird_threshold = pdata->hird_threshold;
  71. - dwc->needs_fifo_resize = pdata->tx_fifo_resize;
  72. dwc->usb3_lpm_capable = pdata->usb3_lpm_capable;
  73. dwc->dr_mode = pdata->dr_mode;
  74. --- a/drivers/usb/dwc3/core.h
  75. +++ b/drivers/usb/dwc3/core.h
  76. @@ -707,9 +707,7 @@ struct dwc3_scratchpad_array {
  77. * 0 - utmi_sleep_n
  78. * 1 - utmi_l1_suspend_n
  79. * @is_fpga: true when we are using the FPGA board
  80. - * @needs_fifo_resize: not all users might want fifo resizing, flag it
  81. * @pullups_connected: true when Run/Stop bit is set
  82. - * @resize_fifos: tells us it's ok to reconfigure our TxFIFO sizes.
  83. * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround
  84. * @start_config_issued: true when StartConfig command has been issued
  85. * @three_stage_setup: set if we perform a three phase setup
  86. @@ -852,9 +850,7 @@ struct dwc3 {
  87. unsigned has_lpm_erratum:1;
  88. unsigned is_utmi_l1_suspend:1;
  89. unsigned is_fpga:1;
  90. - unsigned needs_fifo_resize:1;
  91. unsigned pullups_connected:1;
  92. - unsigned resize_fifos:1;
  93. unsigned setup_packet_pending:1;
  94. unsigned three_stage_setup:1;
  95. unsigned usb3_lpm_capable:1;
  96. @@ -1022,7 +1018,6 @@ struct dwc3_gadget_ep_cmd_params {
  97. /* prototypes */
  98. void dwc3_set_mode(struct dwc3 *dwc, u32 mode);
  99. -int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc);
  100. /* check whether we are on the DWC_usb31 core */
  101. static inline bool dwc3_is_usb31(struct dwc3 *dwc)
  102. --- a/drivers/usb/dwc3/ep0.c
  103. +++ b/drivers/usb/dwc3/ep0.c
  104. @@ -587,9 +587,6 @@ static int dwc3_ep0_set_config(struct dw
  105. reg = dwc3_readl(dwc->regs, DWC3_DCTL);
  106. reg |= (DWC3_DCTL_ACCEPTU1ENA | DWC3_DCTL_ACCEPTU2ENA);
  107. dwc3_writel(dwc->regs, DWC3_DCTL, reg);
  108. -
  109. - dwc->resize_fifos = true;
  110. - dwc3_trace(trace_dwc3_ep0, "resize FIFOs flag SET");
  111. }
  112. break;
  113. @@ -1028,12 +1025,6 @@ static int dwc3_ep0_start_control_status
  114. static void __dwc3_ep0_do_control_status(struct dwc3 *dwc, struct dwc3_ep *dep)
  115. {
  116. - if (dwc->resize_fifos) {
  117. - dwc3_trace(trace_dwc3_ep0, "Resizing FIFOs");
  118. - dwc3_gadget_resize_tx_fifos(dwc);
  119. - dwc->resize_fifos = 0;
  120. - }
  121. -
  122. WARN_ON(dwc3_ep0_start_control_status(dep));
  123. }
  124. --- a/drivers/usb/dwc3/gadget.c
  125. +++ b/drivers/usb/dwc3/gadget.c
  126. @@ -145,92 +145,6 @@ int dwc3_gadget_set_link_state(struct dw
  127. return -ETIMEDOUT;
  128. }
  129. -/**
  130. - * dwc3_gadget_resize_tx_fifos - reallocate fifo spaces for current use-case
  131. - * @dwc: pointer to our context structure
  132. - *
  133. - * This function will a best effort FIFO allocation in order
  134. - * to improve FIFO usage and throughput, while still allowing
  135. - * us to enable as many endpoints as possible.
  136. - *
  137. - * Keep in mind that this operation will be highly dependent
  138. - * on the configured size for RAM1 - which contains TxFifo -,
  139. - * the amount of endpoints enabled on coreConsultant tool, and
  140. - * the width of the Master Bus.
  141. - *
  142. - * In the ideal world, we would always be able to satisfy the
  143. - * following equation:
  144. - *
  145. - * ((512 + 2 * MDWIDTH-Bytes) + (Number of IN Endpoints - 1) * \
  146. - * (3 * (1024 + MDWIDTH-Bytes) + MDWIDTH-Bytes)) / MDWIDTH-Bytes
  147. - *
  148. - * Unfortunately, due to many variables that's not always the case.
  149. - */
  150. -int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc)
  151. -{
  152. - int last_fifo_depth = 0;
  153. - int ram1_depth;
  154. - int fifo_size;
  155. - int mdwidth;
  156. - int num;
  157. -
  158. - if (!dwc->needs_fifo_resize)
  159. - return 0;
  160. -
  161. - ram1_depth = DWC3_RAM1_DEPTH(dwc->hwparams.hwparams7);
  162. - mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0);
  163. -
  164. - /* MDWIDTH is represented in bits, we need it in bytes */
  165. - mdwidth >>= 3;
  166. -
  167. - /*
  168. - * FIXME For now we will only allocate 1 wMaxPacketSize space
  169. - * for each enabled endpoint, later patches will come to
  170. - * improve this algorithm so that we better use the internal
  171. - * FIFO space
  172. - */
  173. - for (num = 0; num < dwc->num_in_eps; num++) {
  174. - /* bit0 indicates direction; 1 means IN ep */
  175. - struct dwc3_ep *dep = dwc->eps[(num << 1) | 1];
  176. - int mult = 1;
  177. - int tmp;
  178. -
  179. - if (!(dep->flags & DWC3_EP_ENABLED))
  180. - continue;
  181. -
  182. - if (usb_endpoint_xfer_bulk(dep->endpoint.desc)
  183. - || usb_endpoint_xfer_isoc(dep->endpoint.desc))
  184. - mult = 3;
  185. -
  186. - /*
  187. - * REVISIT: the following assumes we will always have enough
  188. - * space available on the FIFO RAM for all possible use cases.
  189. - * Make sure that's true somehow and change FIFO allocation
  190. - * accordingly.
  191. - *
  192. - * If we have Bulk or Isochronous endpoints, we want
  193. - * them to be able to be very, very fast. So we're giving
  194. - * those endpoints a fifo_size which is enough for 3 full
  195. - * packets
  196. - */
  197. - tmp = mult * (dep->endpoint.maxpacket + mdwidth);
  198. - tmp += mdwidth;
  199. -
  200. - fifo_size = DIV_ROUND_UP(tmp, mdwidth);
  201. -
  202. - fifo_size |= (last_fifo_depth << 16);
  203. -
  204. - dwc3_trace(trace_dwc3_gadget, "%s: Fifo Addr %04x Size %d",
  205. - dep->name, last_fifo_depth, fifo_size & 0xffff);
  206. -
  207. - dwc3_writel(dwc->regs, DWC3_GTXFIFOSIZ(num), fifo_size);
  208. -
  209. - last_fifo_depth += (fifo_size & 0xffff);
  210. - }
  211. -
  212. - return 0;
  213. -}
  214. -
  215. void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
  216. int status)
  217. {
  218. --- a/drivers/usb/dwc3/platform_data.h
  219. +++ b/drivers/usb/dwc3/platform_data.h
  220. @@ -23,7 +23,6 @@
  221. struct dwc3_platform_data {
  222. enum usb_device_speed maximum_speed;
  223. enum usb_dr_mode dr_mode;
  224. - bool tx_fifo_resize;
  225. bool usb3_lpm_capable;
  226. unsigned is_utmi_l1_suspend:1;