Loading drivers/usb/dwc3/gadget.c +16 −10 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ #include <linux/module.h> #include <linux/usb/ch9.h> #include <linux/usb/composite.h> #include <linux/usb/gadget.h> #include <linux/usb/otg.h> Loading Loading @@ -197,30 +198,34 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc) int fifo_size; int mdwidth; int num; int num_eps; struct usb_composite_dev *cdev = get_gadget_data(&dwc->gadget); if (!dwc->needs_fifo_resize) return 0; /* gadget.num_eps never be greater than dwc->num_in_eps */ num_eps = min_t(int, dwc->num_in_eps, cdev->config->num_ineps_used + 1); ram1_depth = DWC3_RAM1_DEPTH(dwc->hwparams.hwparams7); mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0); /* MDWIDTH is represented in bits, we need it in bytes */ mdwidth >>= 3; /* * 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. Also consider the case where TxFIFO RAM space * may change dynamically based on the USB configuration. */ for (num = 0; num < dwc->num_in_eps; num++) { dev_dbg(dwc->dev, "%s: num eps: %d\n", __func__, num_eps); for (num = 0; num < num_eps; num++) { struct dwc3_ep *dep = dwc->eps[(num << 1) | 1]; int mult = 1; int tmp; int max_packet = 1024; if (!(dep->flags & DWC3_EP_ENABLED)) continue; if (!(dep->flags & DWC3_EP_ENABLED)) { dev_warn(dwc->dev, "ep%dIn not enabled", num); tmp = max_packet + mdwidth; goto resize_fifo; } if (((dep->endpoint.maxburst > 1) && usb_endpoint_xfer_bulk(dep->endpoint.desc)) Loading Loading @@ -256,6 +261,7 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc) tmp = mult * (1024 + mdwidth); } resize_fifo: tmp += mdwidth; fifo_size = DIV_ROUND_UP(tmp, mdwidth); Loading drivers/usb/gadget/composite.c +6 −0 Original line number Diff line number Diff line Loading @@ -729,6 +729,8 @@ static int set_config(struct usb_composite_dev *cdev, goto done; cdev->config = c; c->num_ineps_used = 0; c->num_outeps_used = 0; /* Initialize all interfaces by setting them to altsetting zero. */ for (tmp = 0; tmp < MAX_CONFIG_INTERFACES; tmp++) { Loading Loading @@ -766,6 +768,10 @@ static int set_config(struct usb_composite_dev *cdev, addr = ((ep->bEndpointAddress & 0x80) >> 3) | (ep->bEndpointAddress & 0x0f); set_bit(addr, f->endpoints); if (usb_endpoint_dir_in(ep)) c->num_ineps_used++; else c->num_outeps_used++; } result = f->set_alt(f, tmp, 0); Loading include/linux/usb/composite.h +4 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,10 @@ struct usb_configuration { unsigned highspeed:1; unsigned fullspeed:1; struct usb_function *interface[MAX_CONFIG_INTERFACES]; /* number of in and out eps used in this configuration */ int num_ineps_used; int num_outeps_used; }; int usb_add_config(struct usb_composite_dev *, Loading Loading
drivers/usb/dwc3/gadget.c +16 −10 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ #include <linux/module.h> #include <linux/usb/ch9.h> #include <linux/usb/composite.h> #include <linux/usb/gadget.h> #include <linux/usb/otg.h> Loading Loading @@ -197,30 +198,34 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc) int fifo_size; int mdwidth; int num; int num_eps; struct usb_composite_dev *cdev = get_gadget_data(&dwc->gadget); if (!dwc->needs_fifo_resize) return 0; /* gadget.num_eps never be greater than dwc->num_in_eps */ num_eps = min_t(int, dwc->num_in_eps, cdev->config->num_ineps_used + 1); ram1_depth = DWC3_RAM1_DEPTH(dwc->hwparams.hwparams7); mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0); /* MDWIDTH is represented in bits, we need it in bytes */ mdwidth >>= 3; /* * 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. Also consider the case where TxFIFO RAM space * may change dynamically based on the USB configuration. */ for (num = 0; num < dwc->num_in_eps; num++) { dev_dbg(dwc->dev, "%s: num eps: %d\n", __func__, num_eps); for (num = 0; num < num_eps; num++) { struct dwc3_ep *dep = dwc->eps[(num << 1) | 1]; int mult = 1; int tmp; int max_packet = 1024; if (!(dep->flags & DWC3_EP_ENABLED)) continue; if (!(dep->flags & DWC3_EP_ENABLED)) { dev_warn(dwc->dev, "ep%dIn not enabled", num); tmp = max_packet + mdwidth; goto resize_fifo; } if (((dep->endpoint.maxburst > 1) && usb_endpoint_xfer_bulk(dep->endpoint.desc)) Loading Loading @@ -256,6 +261,7 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc) tmp = mult * (1024 + mdwidth); } resize_fifo: tmp += mdwidth; fifo_size = DIV_ROUND_UP(tmp, mdwidth); Loading
drivers/usb/gadget/composite.c +6 −0 Original line number Diff line number Diff line Loading @@ -729,6 +729,8 @@ static int set_config(struct usb_composite_dev *cdev, goto done; cdev->config = c; c->num_ineps_used = 0; c->num_outeps_used = 0; /* Initialize all interfaces by setting them to altsetting zero. */ for (tmp = 0; tmp < MAX_CONFIG_INTERFACES; tmp++) { Loading Loading @@ -766,6 +768,10 @@ static int set_config(struct usb_composite_dev *cdev, addr = ((ep->bEndpointAddress & 0x80) >> 3) | (ep->bEndpointAddress & 0x0f); set_bit(addr, f->endpoints); if (usb_endpoint_dir_in(ep)) c->num_ineps_used++; else c->num_outeps_used++; } result = f->set_alt(f, tmp, 0); Loading
include/linux/usb/composite.h +4 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,10 @@ struct usb_configuration { unsigned highspeed:1; unsigned fullspeed:1; struct usb_function *interface[MAX_CONFIG_INTERFACES]; /* number of in and out eps used in this configuration */ int num_ineps_used; int num_outeps_used; }; int usb_add_config(struct usb_composite_dev *, Loading