Loading drivers/usb/dwc3/gadget.c +20 −22 Original line number Diff line number Diff line Loading @@ -203,6 +203,7 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc) int mdwidth; int num; int num_eps; int max_packet; struct usb_composite_dev *cdev = get_gadget_data(&dwc->gadget); if (!(cdev && cdev->config) || !dwc->needs_fifo_resize) Loading @@ -217,20 +218,28 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc) /* MDWIDTH is represented in bits, we need it in bytes */ mdwidth >>= 3; dev_dbg(dwc->dev, "%s: num eps: %d\n", __func__, num_eps); if (dwc->gadget.speed == USB_SPEED_FULL) { max_packet = 64; } else if (dwc->gadget.speed == USB_SPEED_HIGH) { max_packet = 512; } else if (dwc->gadget.speed == USB_SPEED_SUPER) { max_packet = 1024; } else { dev_warn(dwc->dev, "USB speed (%d) is not valid.\n", dwc->gadget.speed); return -EINVAL; } /* * FIXME For now we will only allocate 1 wMaxPacketSize space * for each enabled endpoint, later patches will come to * improve this algorithm so that we better use the internal * FIFO space */ for (num = 0; num < num_eps; num++) { last_fifo_depth = (dwc3_readl(dwc->regs, DWC3_GTXFIFOSIZ(0)) & 0xFFFF); dev_dbg(dwc->dev, "%s: num eps:%d max_packet:%d last_fifo_depth:%04x\n", __func__, num_eps, max_packet, last_fifo_depth); /* Don't resize ep0IN TxFIFO, start with ep1IN only. */ for (num = 1; num < num_eps; num++) { /* bit0 indicates direction; 1 means IN ep */ struct dwc3_ep *dep = dwc->eps[(num << 1) | 1]; int mult = 1; int tmp; int max_packet = 1024; if (!(dep->flags & DWC3_EP_ENABLED)) { dev_warn(dwc->dev, "ep%dIn not enabled", num); Loading @@ -243,18 +252,7 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc) || usb_endpoint_xfer_isoc(dep->endpoint.desc)) mult = 3; /* * REVISIT: the following assumes we will always have enough * space available on the FIFO RAM for all possible use cases. * Make sure that's true somehow and change FIFO allocation * accordingly. * * If we have Bulk (burst only) or Isochronous endpoints, we * want them to be able to be very, very fast. So we're giving * those endpoints a fifo_size which is enough for 3 full * packets */ tmp = mult * (dep->endpoint.maxpacket + mdwidth); tmp = mult * (max_packet + mdwidth); resize_fifo: tmp += mdwidth; Loading @@ -262,7 +260,7 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc) fifo_size |= (last_fifo_depth << 16); dwc3_trace(trace_dwc3_gadget, "%s: Fifo Addr %04x Size %d", dev_dbg(dwc->dev, "%s: Fifo Addr %04x Size %d", dep->name, last_fifo_depth, fifo_size & 0xffff); last_fifo_depth += (fifo_size & 0xffff); Loading Loading
drivers/usb/dwc3/gadget.c +20 −22 Original line number Diff line number Diff line Loading @@ -203,6 +203,7 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc) int mdwidth; int num; int num_eps; int max_packet; struct usb_composite_dev *cdev = get_gadget_data(&dwc->gadget); if (!(cdev && cdev->config) || !dwc->needs_fifo_resize) Loading @@ -217,20 +218,28 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc) /* MDWIDTH is represented in bits, we need it in bytes */ mdwidth >>= 3; dev_dbg(dwc->dev, "%s: num eps: %d\n", __func__, num_eps); if (dwc->gadget.speed == USB_SPEED_FULL) { max_packet = 64; } else if (dwc->gadget.speed == USB_SPEED_HIGH) { max_packet = 512; } else if (dwc->gadget.speed == USB_SPEED_SUPER) { max_packet = 1024; } else { dev_warn(dwc->dev, "USB speed (%d) is not valid.\n", dwc->gadget.speed); return -EINVAL; } /* * FIXME For now we will only allocate 1 wMaxPacketSize space * for each enabled endpoint, later patches will come to * improve this algorithm so that we better use the internal * FIFO space */ for (num = 0; num < num_eps; num++) { last_fifo_depth = (dwc3_readl(dwc->regs, DWC3_GTXFIFOSIZ(0)) & 0xFFFF); dev_dbg(dwc->dev, "%s: num eps:%d max_packet:%d last_fifo_depth:%04x\n", __func__, num_eps, max_packet, last_fifo_depth); /* Don't resize ep0IN TxFIFO, start with ep1IN only. */ for (num = 1; num < num_eps; num++) { /* bit0 indicates direction; 1 means IN ep */ struct dwc3_ep *dep = dwc->eps[(num << 1) | 1]; int mult = 1; int tmp; int max_packet = 1024; if (!(dep->flags & DWC3_EP_ENABLED)) { dev_warn(dwc->dev, "ep%dIn not enabled", num); Loading @@ -243,18 +252,7 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc) || usb_endpoint_xfer_isoc(dep->endpoint.desc)) mult = 3; /* * REVISIT: the following assumes we will always have enough * space available on the FIFO RAM for all possible use cases. * Make sure that's true somehow and change FIFO allocation * accordingly. * * If we have Bulk (burst only) or Isochronous endpoints, we * want them to be able to be very, very fast. So we're giving * those endpoints a fifo_size which is enough for 3 full * packets */ tmp = mult * (dep->endpoint.maxpacket + mdwidth); tmp = mult * (max_packet + mdwidth); resize_fifo: tmp += mdwidth; Loading @@ -262,7 +260,7 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc) fifo_size |= (last_fifo_depth << 16); dwc3_trace(trace_dwc3_gadget, "%s: Fifo Addr %04x Size %d", dev_dbg(dwc->dev, "%s: Fifo Addr %04x Size %d", dep->name, last_fifo_depth, fifo_size & 0xffff); last_fifo_depth += (fifo_size & 0xffff); Loading