aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2013-05-14 13:57:51 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-05-15 13:42:45 -0400
commit815fa7b917614261748d1ecd9600ff27f99508e5 (patch)
treed7f02412eaabbf21faa91ca44366d8be76147537 /drivers/usb/host
parente1944017839d7dfbf7329fac4bdec8b4050edf5e (diff)
USB: OHCI: fix logic for scheduling isochronous URBs
The isochronous scheduling logic in ohci-hcd has a bug. The calculation for skipping TDs that are too late should be carried out only in the !URB_ISO_ASAP case. When URB_ISO_ASAP is set, the URB is pushed back so that none of the TDs are too late, which would cause the calculation to overflow. The patch also fixes the calculation to avoid overflow in the case where the frame value wraps around. This should be applied to -stable kernels going back to 3.8. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> CC: <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/ohci-hcd.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index df1af0bcfe99..fc627fd54116 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -240,7 +240,7 @@ static int ohci_urb_enqueue (
240 if (unlikely(tick_before(frame, next))) { 240 if (unlikely(tick_before(frame, next))) {
241 241
242 /* USB_ISO_ASAP: Round up to the first available slot */ 242 /* USB_ISO_ASAP: Round up to the first available slot */
243 if (urb->transfer_flags & URB_ISO_ASAP) 243 if (urb->transfer_flags & URB_ISO_ASAP) {
244 frame += (next - frame + ed->interval - 1) & 244 frame += (next - frame + ed->interval - 1) &
245 -ed->interval; 245 -ed->interval;
246 246
@@ -248,21 +248,25 @@ static int ohci_urb_enqueue (
248 * Not ASAP: Use the next slot in the stream. If 248 * Not ASAP: Use the next slot in the stream. If
249 * the entire URB falls before the threshold, fail. 249 * the entire URB falls before the threshold, fail.
250 */ 250 */
251 else if (tick_before(frame + ed->interval * 251 } else {
252 if (tick_before(frame + ed->interval *
252 (urb->number_of_packets - 1), next)) { 253 (urb->number_of_packets - 1), next)) {
253 retval = -EXDEV; 254 retval = -EXDEV;
254 usb_hcd_unlink_urb_from_ep(hcd, urb); 255 usb_hcd_unlink_urb_from_ep(hcd, urb);
255 goto fail; 256 goto fail;
256 } 257 }
257 258
258 /* 259 /*
259 * Some OHCI hardware doesn't handle late TDs 260 * Some OHCI hardware doesn't handle late TDs
260 * correctly. After retiring them it proceeds to 261 * correctly. After retiring them it proceeds
261 * the next ED instead of the next TD. Therefore 262 * to the next ED instead of the next TD.
262 * we have to omit the late TDs entirely. 263 * Therefore we have to omit the late TDs
263 */ 264 * entirely.
264 urb_priv->td_cnt = DIV_ROUND_UP(next - frame, 265 */
265 ed->interval); 266 urb_priv->td_cnt = DIV_ROUND_UP(
267 (u16) (next - frame),
268 ed->interval);
269 }
266 } 270 }
267 urb->start_frame = frame; 271 urb->start_frame = frame;
268 } 272 }