Skip to content

Commit a03bede

Browse files
AlanSterngregkh
authored andcommitted
USB: update documentation for URB_ISO_ASAP
This patch (as1611) updates the USB documentation and kerneldoc to give a more precise meaning for the URB_ISO_ASAP flag and to explain more of the details of scheduling for isochronous URBs. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7267547 commit a03bede

3 files changed

Lines changed: 37 additions & 17 deletions

File tree

‎Documentation/usb/error-codes.txt‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ USB-specific:
3535
d) ISO: number_of_packets is < 0
3636
e) various other cases
3737

38-
-EAGAIN a) specified ISO start frame too early
39-
b) (using ISO-ASAP) too much scheduled for the future
40-
wait some time and try again.
38+
-EXDEV ISO: URB_ISO_ASAP wasn't specified and all the frames
39+
the URB would be scheduled in have already expired.
4140

4241
-EFBIG Host controller driver can't schedule that many ISO frames.
4342

‎drivers/usb/core/urb.c‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,25 @@ EXPORT_SYMBOL_GPL(usb_unanchor_urb);
214214
* urb->interval is modified to reflect the actual transfer period used
215215
* (normally some power of two units). And for isochronous urbs,
216216
* urb->start_frame is modified to reflect when the URB's transfers were
217-
* scheduled to start. Not all isochronous transfer scheduling policies
218-
* will work, but most host controller drivers should easily handle ISO
219-
* queues going from now until 10-200 msec into the future.
217+
* scheduled to start.
218+
*
219+
* Not all isochronous transfer scheduling policies will work, but most
220+
* host controller drivers should easily handle ISO queues going from now
221+
* until 10-200 msec into the future. Drivers should try to keep at
222+
* least one or two msec of data in the queue; many controllers require
223+
* that new transfers start at least 1 msec in the future when they are
224+
* added. If the driver is unable to keep up and the queue empties out,
225+
* the behavior for new submissions is governed by the URB_ISO_ASAP flag.
226+
* If the flag is set, or if the queue is idle, then the URB is always
227+
* assigned to the first available (and not yet expired) slot in the
228+
* endpoint's schedule. If the flag is not set and the queue is active
229+
* then the URB is always assigned to the next slot in the schedule
230+
* following the end of the endpoint's previous URB, even if that slot is
231+
* in the past. When a packet is assigned in this way to a slot that has
232+
* already expired, the packet is not transmitted and the corresponding
233+
* usb_iso_packet_descriptor's status field will return -EXDEV. If this
234+
* would happen to all the packets in the URB, submission fails with a
235+
* -EXDEV error code.
220236
*
221237
* For control endpoints, the synchronous usb_control_msg() call is
222238
* often used (in non-interrupt context) instead of this call.

‎include/linux/usb.h‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,8 +1129,8 @@ extern int usb_disabled(void);
11291129
* Note: URB_DIR_IN/OUT is automatically set in usb_submit_urb().
11301130
*/
11311131
#define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */
1132-
#define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame
1133-
* ignored */
1132+
#define URB_ISO_ASAP 0x0002 /* iso-only; use the first unexpired
1133+
* slot in the schedule */
11341134
#define URB_NO_TRANSFER_DMA_MAP 0x0004 /* urb->transfer_dma valid on submit */
11351135
#define URB_NO_FSBR 0x0020 /* UHCI-specific */
11361136
#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */
@@ -1309,15 +1309,20 @@ typedef void (*usb_complete_t)(struct urb *);
13091309
* the transfer interval in the endpoint descriptor is logarithmic.
13101310
* Device drivers must convert that value to linear units themselves.)
13111311
*
1312-
* Isochronous URBs normally use the URB_ISO_ASAP transfer flag, telling
1313-
* the host controller to schedule the transfer as soon as bandwidth
1314-
* utilization allows, and then set start_frame to reflect the actual frame
1315-
* selected during submission. Otherwise drivers must specify the start_frame
1316-
* and handle the case where the transfer can't begin then. However, drivers
1317-
* won't know how bandwidth is currently allocated, and while they can
1318-
* find the current frame using usb_get_current_frame_number () they can't
1319-
* know the range for that frame number. (Ranges for frame counter values
1320-
* are HC-specific, and can go from 256 to 65536 frames from "now".)
1312+
* If an isochronous endpoint queue isn't already running, the host
1313+
* controller will schedule a new URB to start as soon as bandwidth
1314+
* utilization allows. If the queue is running then a new URB will be
1315+
* scheduled to start in the first transfer slot following the end of the
1316+
* preceding URB, if that slot has not already expired. If the slot has
1317+
* expired (which can happen when IRQ delivery is delayed for a long time),
1318+
* the scheduling behavior depends on the URB_ISO_ASAP flag. If the flag
1319+
* is clear then the URB will be scheduled to start in the expired slot,
1320+
* implying that some of its packets will not be transferred; if the flag
1321+
* is set then the URB will be scheduled in the first unexpired slot,
1322+
* breaking the queue's synchronization. Upon URB completion, the
1323+
* start_frame field will be set to the (micro)frame number in which the
1324+
* transfer was scheduled. Ranges for frame counter values are HC-specific
1325+
* and can go from as low as 256 to as high as 65536 frames.
13211326
*
13221327
* Isochronous URBs have a different data transfer model, in part because
13231328
* the quality of service is only "best effort". Callers provide specially

0 commit comments

Comments
 (0)