aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2012-10-01 10:32:15 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-10-22 14:10:24 -0400
commit6a41b4d3fe8cd4cc95181516fc6fba7b1747a27c (patch)
tree2b4dc08f94a67985f595d157c399774cee4e661a /drivers
parentc44b225077bb1fb25ed5cd5c4f226897b91bedd4 (diff)
OHCI: implement new semantics for URB_ISO_ASAP
This patch (as1614) updates the isochronous scheduling in ohci-hcd to match the new semantics for URB_ISO_ASAP. Testing revealed a hardware bug in the way my OHCI controller handles expired isochronous TDs; consequently the patch tries hard to avoid creating them (unlike the ehci-hcd and uhci-hcd drivers). Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/host/ohci-hcd.c36
-rw-r--r--drivers/usb/host/ohci-q.c4
2 files changed, 34 insertions, 6 deletions
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 4a1d64d92338..cfc1da30667c 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -231,13 +231,41 @@ static int ohci_urb_enqueue (
231 frame &= ~(ed->interval - 1); 231 frame &= ~(ed->interval - 1);
232 frame |= ed->branch; 232 frame |= ed->branch;
233 urb->start_frame = frame; 233 urb->start_frame = frame;
234 }
235 } else if (ed->type == PIPE_ISOCHRONOUS) {
236 u16 next = ohci_frame_no(ohci) + 2;
237 u16 frame = ed->last_iso + ed->interval;
238
239 /* Behind the scheduling threshold? */
240 if (unlikely(tick_before(frame, next))) {
234 241
235 /* yes, only URB_ISO_ASAP is supported, and 242 /* USB_ISO_ASAP: Round up to the first available slot */
236 * urb->start_frame is never used as input. 243 if (urb->transfer_flags & URB_ISO_ASAP)
244 frame += (next - frame + ed->interval - 1) &
245 -ed->interval;
246
247 /*
248 * Not ASAP: Use the next slot in the stream. If
249 * the entire URB falls before the threshold, fail.
237 */ 250 */
251 else if (tick_before(frame + ed->interval *
252 (urb->number_of_packets - 1), next)) {
253 retval = -EXDEV;
254 usb_hcd_unlink_urb_from_ep(hcd, urb);
255 goto fail;
256 }
257
258 /*
259 * Some OHCI hardware doesn't handle late TDs
260 * correctly. After retiring them it proceeds to
261 * the next ED instead of the next TD. Therefore
262 * we have to omit the late TDs entirely.
263 */
264 urb_priv->td_cnt = DIV_ROUND_UP(next - frame,
265 ed->interval);
238 } 266 }
239 } else if (ed->type == PIPE_ISOCHRONOUS) 267 urb->start_frame = frame;
240 urb->start_frame = ed->last_iso + ed->interval; 268 }
241 269
242 /* fill the TDs and link them to the ed; and 270 /* fill the TDs and link them to the ed; and
243 * enable that part of the schedule, if needed 271 * enable that part of the schedule, if needed
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index c5a1ea9145fa..177a213790d4 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -596,7 +596,6 @@ static void td_submit_urb (
596 urb_priv->ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_C); 596 urb_priv->ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_C);
597 } 597 }
598 598
599 urb_priv->td_cnt = 0;
600 list_add (&urb_priv->pending, &ohci->pending); 599 list_add (&urb_priv->pending, &ohci->pending);
601 600
602 if (data_len) 601 if (data_len)
@@ -672,7 +671,8 @@ static void td_submit_urb (
672 * we could often reduce the number of TDs here. 671 * we could often reduce the number of TDs here.
673 */ 672 */
674 case PIPE_ISOCHRONOUS: 673 case PIPE_ISOCHRONOUS:
675 for (cnt = 0; cnt < urb->number_of_packets; cnt++) { 674 for (cnt = urb_priv->td_cnt; cnt < urb->number_of_packets;
675 cnt++) {
676 int frame = urb->start_frame; 676 int frame = urb->start_frame;
677 677
678 // FIXME scheduling should handle frame counter 678 // FIXME scheduling should handle frame counter