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

usb: dwc3: gadget: allocate 3 packets for bulk and isoc endpoints

Those transfer types are generally high bandwidth, so we
want to optimize transfers with those endpoints.

For that, databook suggests allocating 3 * wMaxPacketSize
of FIFO. Let's do that.

Signed-off-by: Felipe Balbi <balbi@ti.com>

+18 -2
+18 -2
drivers/usb/dwc3/gadget.c
··· 172 172 for (num = 0; num < DWC3_ENDPOINTS_NUM; num++) { 173 173 struct dwc3_ep *dep = dwc->eps[num]; 174 174 int fifo_number = dep->number >> 1; 175 + int mult = 1; 175 176 int tmp; 176 177 177 178 if (!(dep->number & 1)) ··· 181 180 if (!(dep->flags & DWC3_EP_ENABLED)) 182 181 continue; 183 182 184 - tmp = dep->endpoint.maxpacket; 185 - tmp += mdwidth; 183 + if (usb_endpoint_xfer_bulk(dep->desc) 184 + || usb_endpoint_xfer_isoc(dep->desc)) 185 + mult = 3; 186 + 187 + /* 188 + * REVISIT: the following assumes we will always have enough 189 + * space available on the FIFO RAM for all possible use cases. 190 + * Make sure that's true somehow and change FIFO allocation 191 + * accordingly. 192 + * 193 + * If we have Bulk or Isochronous endpoints, we want 194 + * them to be able to be very, very fast. So we're giving 195 + * those endpoints a fifo_size which is enough for 3 full 196 + * packets 197 + */ 198 + tmp = mult * (dep->endpoint.maxpacket + mdwidth); 186 199 tmp += mdwidth; 187 200 188 201 fifo_size = DIV_ROUND_UP(tmp, mdwidth); 202 + 189 203 fifo_size |= (last_fifo_depth << 16); 190 204 191 205 dev_vdbg(dwc->dev, "%s: Fifo Addr %04x Size %d\n",