Commit ffc4ea79 authored by Alan Stern's avatar Alan Stern Committed by Felipe Balbi

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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 8a5776a5
...@@ -1766,6 +1766,7 @@ static void dummy_timer(unsigned long _dum_hcd) ...@@ -1766,6 +1766,7 @@ static void dummy_timer(unsigned long _dum_hcd)
int i; int i;
/* simplistic model for one frame's bandwidth */ /* simplistic model for one frame's bandwidth */
/* FIXME: account for transaction and packet overhead */
switch (dum->gadget.speed) { switch (dum->gadget.speed) {
case USB_SPEED_LOW: case USB_SPEED_LOW:
total = 8/*bytes*/ * 12/*packets*/; total = 8/*bytes*/ * 12/*packets*/;
...@@ -1810,7 +1811,6 @@ static void dummy_timer(unsigned long _dum_hcd) ...@@ -1810,7 +1811,6 @@ static void dummy_timer(unsigned long _dum_hcd)
struct dummy_request *req; struct dummy_request *req;
u8 address; u8 address;
struct dummy_ep *ep = NULL; struct dummy_ep *ep = NULL;
int type;
int status = -EINPROGRESS; int status = -EINPROGRESS;
/* stop when we reach URBs queued after the timer interrupt */ /* stop when we reach URBs queued after the timer interrupt */
...@@ -1822,14 +1822,10 @@ static void dummy_timer(unsigned long _dum_hcd) ...@@ -1822,14 +1822,10 @@ static void dummy_timer(unsigned long _dum_hcd)
goto return_urb; goto return_urb;
else if (dum_hcd->rh_state != DUMMY_RH_RUNNING) else if (dum_hcd->rh_state != DUMMY_RH_RUNNING)
continue; continue;
type = usb_pipetype(urb->pipe);
/* used up this frame's non-periodic bandwidth? /* Used up this frame's bandwidth? */
* FIXME there's infinite bandwidth for control and if (total <= 0)
* periodic transfers ... unrealistic. break;
*/
if (total <= 0 && type == PIPE_BULK)
continue;
/* find the gadget's ep for this request (if configured) */ /* find the gadget's ep for this request (if configured) */
address = usb_pipeendpoint (urb->pipe); address = usb_pipeendpoint (urb->pipe);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment