summaryrefslogtreecommitdiff
path: root/drivers/usb/gadget/udc/dummy_hcd.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2017-09-26 15:16:05 -0400
committerFelipe Balbi <felipe.balbi@linux.intel.com>2017-10-11 13:07:35 +0300
commitffc4ea79bc06f42283da10ea06bb17b9a3e2b2b4 (patch)
treeaa1ce1da2947226fc8d672f084dd9c3f8bab0ed4 /drivers/usb/gadget/udc/dummy_hcd.c
parent8a5776a5f49812d29fe4b2d0a2d71675c3facf3f (diff)
USB: dummy-hcd: bandwidth limits for non-bulk transfers
Part of the emulation performed by dummy-hcd is accounting for bandwidth utilization. The total amount of data transferred in a single frame is supposed to be no larger than an actual USB connection could accommodate. Currently the driver performs bandwidth limiting only for bulk transfers; control and periodic transfers are effectively unlimited. (Presumably drivers were not expected to request extremely large control or interrupt transfers.) This patch improves the situation somewhat by restricting them as well. The emulation still isn't perfect. On a real system, even 0-length transfers use some bandwidth because of transaction overhead (IN, OUT, ACK, NACK packets) and packet overhead (SYNC, PID, bit stuffing, CRC, EOP). Adding in those factors is left as an exercise for a later patch. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb/gadget/udc/dummy_hcd.c')
-rw-r--r--drivers/usb/gadget/udc/dummy_hcd.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index b17618a55f1b..d177d63e16d7 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -1766,6 +1766,7 @@ static void dummy_timer(unsigned long _dum_hcd)
int i;
/* simplistic model for one frame's bandwidth */
+ /* FIXME: account for transaction and packet overhead */
switch (dum->gadget.speed) {
case USB_SPEED_LOW:
total = 8/*bytes*/ * 12/*packets*/;
@@ -1810,7 +1811,6 @@ restart:
struct dummy_request *req;
u8 address;
struct dummy_ep *ep = NULL;
- int type;
int status = -EINPROGRESS;
/* stop when we reach URBs queued after the timer interrupt */
@@ -1822,14 +1822,10 @@ restart:
goto return_urb;
else if (dum_hcd->rh_state != DUMMY_RH_RUNNING)
continue;
- type = usb_pipetype(urb->pipe);
- /* used up this frame's non-periodic bandwidth?
- * FIXME there's infinite bandwidth for control and
- * periodic transfers ... unrealistic.
- */
- if (total <= 0 && type == PIPE_BULK)
- continue;
+ /* Used up this frame's bandwidth? */
+ if (total <= 0)
+ break;
/* find the gadget's ep for this request (if configured) */
address = usb_pipeendpoint (urb->pipe);