From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Alan Stern <stern@rowland.harvard.edu>
Subject: [ 33/57] USB: OHCI: accept very late isochronous URBs
Date: Wed, 2 Oct 2013 21:08:59 -0700 [thread overview]
Message-ID: <20131003040638.867435357@linuxfoundation.org> (raw)
In-Reply-To: <20131003040636.600441214@linuxfoundation.org>
3.11-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <stern@rowland.harvard.edu>
commit a8693424c751b8247ee19bd8b857f1d4f432b972 upstream.
Commit 24f531371de1 (USB: EHCI: accept very late isochronous URBs)
changed the isochronous API provided by ehci-hcd. URBs submitted too
late, so that the time slots for all their packets have already
expired, are no longer rejected outright. Instead the submission is
accepted, and the URB completes normally with a -EXDEV error for each
packet. This is what client drivers expect.
This patch implements the same policy in ohci-hcd. The change is more
complicated than it was in ehci-hcd, because ohci-hcd doesn't scan for
isochronous completions in the same way as ehci-hcd does. Rather, it
depends on the hardware adding completed TDs to a "done queue". Some
OHCI controller don't handle this properly when a TD's time slot has
already expired, so we have to avoid adding such TDs to the schedule
in the first place. As a result, if the URB was submitted too late
then none of its TDs will get put on the schedule, so none of them
will end up on the done queue, so the driver will never realize that
the URB should be completed.
To solve this problem, the patch adds one to urb_priv->td_cnt for such
URBs, making it larger than urb_priv->length (td_cnt already gets set
to the number of TD's that had to be skipped because their slots have
expired). Each time an URB is given back, the finish_urb() routine
looks to see if urb_priv->td_cnt for the next URB on the same endpoint
is marked in this way. If so, it gives back the next URB right away.
This should be applied to all kernels containing commit 815fa7b91761
(USB: OHCI: fix logic for scheduling isochronous URBs).
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/host/ohci-hcd.c | 22 ++++++++++++----------
drivers/usb/host/ohci-q.c | 26 ++++++++++++++++++++++----
2 files changed, 34 insertions(+), 14 deletions(-)
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -216,31 +216,26 @@ static int ohci_urb_enqueue (
frame &= ~(ed->interval - 1);
frame |= ed->branch;
urb->start_frame = frame;
+ ed->last_iso = frame + ed->interval * (size - 1);
}
} else if (ed->type == PIPE_ISOCHRONOUS) {
u16 next = ohci_frame_no(ohci) + 1;
u16 frame = ed->last_iso + ed->interval;
+ u16 length = ed->interval * (size - 1);
/* Behind the scheduling threshold? */
if (unlikely(tick_before(frame, next))) {
- /* USB_ISO_ASAP: Round up to the first available slot */
+ /* URB_ISO_ASAP: Round up to the first available slot */
if (urb->transfer_flags & URB_ISO_ASAP) {
frame += (next - frame + ed->interval - 1) &
-ed->interval;
/*
- * Not ASAP: Use the next slot in the stream. If
- * the entire URB falls before the threshold, fail.
+ * Not ASAP: Use the next slot in the stream,
+ * no matter what.
*/
} else {
- if (tick_before(frame + ed->interval *
- (urb->number_of_packets - 1), next)) {
- retval = -EXDEV;
- usb_hcd_unlink_urb_from_ep(hcd, urb);
- goto fail;
- }
-
/*
* Some OHCI hardware doesn't handle late TDs
* correctly. After retiring them it proceeds
@@ -251,9 +246,16 @@ static int ohci_urb_enqueue (
urb_priv->td_cnt = DIV_ROUND_UP(
(u16) (next - frame),
ed->interval);
+ if (urb_priv->td_cnt >= urb_priv->length) {
+ ++urb_priv->td_cnt; /* Mark it */
+ ohci_dbg(ohci, "iso underrun %p (%u+%u < %u)\n",
+ urb, frame, length,
+ next);
+ }
}
}
urb->start_frame = frame;
+ ed->last_iso = frame + length;
}
/* fill the TDs and link them to the ed; and
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -41,9 +41,13 @@ finish_urb(struct ohci_hcd *ohci, struct
__releases(ohci->lock)
__acquires(ohci->lock)
{
- struct device *dev = ohci_to_hcd(ohci)->self.controller;
+ struct device *dev = ohci_to_hcd(ohci)->self.controller;
+ struct usb_host_endpoint *ep = urb->ep;
+ struct urb_priv *urb_priv;
+
// ASSERT (urb->hcpriv != 0);
+ restart:
urb_free_priv (ohci, urb->hcpriv);
urb->hcpriv = NULL;
if (likely(status == -EINPROGRESS))
@@ -80,6 +84,21 @@ __acquires(ohci->lock)
ohci->hc_control &= ~(OHCI_CTRL_PLE|OHCI_CTRL_IE);
ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
}
+
+ /*
+ * An isochronous URB that is sumitted too late won't have any TDs
+ * (marked by the fact that the td_cnt value is larger than the
+ * actual number of TDs). If the next URB on this endpoint is like
+ * that, give it back now.
+ */
+ if (!list_empty(&ep->urb_list)) {
+ urb = list_first_entry(&ep->urb_list, struct urb, urb_list);
+ urb_priv = urb->hcpriv;
+ if (urb_priv->td_cnt > urb_priv->length) {
+ status = 0;
+ goto restart;
+ }
+ }
}
@@ -546,7 +565,6 @@ td_fill (struct ohci_hcd *ohci, u32 info
td->hwCBP = cpu_to_hc32 (ohci, data & 0xFFFFF000);
*ohci_hwPSWp(ohci, td, 0) = cpu_to_hc16 (ohci,
(data & 0x0FFF) | 0xE000);
- td->ed->last_iso = info & 0xffff;
} else {
td->hwCBP = cpu_to_hc32 (ohci, data);
}
@@ -996,7 +1014,7 @@ rescan_this:
urb_priv->td_cnt++;
/* if URB is done, clean up */
- if (urb_priv->td_cnt == urb_priv->length) {
+ if (urb_priv->td_cnt >= urb_priv->length) {
modified = completed = 1;
finish_urb(ohci, urb, 0);
}
@@ -1086,7 +1104,7 @@ static void takeback_td(struct ohci_hcd
urb_priv->td_cnt++;
/* If all this urb's TDs are done, call complete() */
- if (urb_priv->td_cnt == urb_priv->length)
+ if (urb_priv->td_cnt >= urb_priv->length)
finish_urb(ohci, urb, status);
/* clean schedule: unlink EDs that are no longer busy */
next prev parent reply other threads:[~2013-10-03 4:08 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-03 4:08 [ 00/57] 3.11.4-stable review Greg Kroah-Hartman
2013-10-03 4:08 ` [ 01/57] block: Fix bio_copy_data() Greg Kroah-Hartman
2013-10-03 4:08 ` [ 02/57] sysv: Add forgotten superblock lock init for v7 fs Greg Kroah-Hartman
2013-10-03 4:08 ` [ 03/57] bcache: Fix a dumb journal discard bug Greg Kroah-Hartman
2013-10-03 4:08 ` [ 04/57] bcache: Strip endline when writing the label through sysfs Greg Kroah-Hartman
2013-10-03 4:08 ` [ 05/57] bcache: Fix for when no journal entries are found Greg Kroah-Hartman
2013-10-03 4:08 ` [ 06/57] bcache: Fix a writeback performance regression Greg Kroah-Hartman
2013-10-03 4:08 ` [ 07/57] bcache: Fix a flush/fua performance bug Greg Kroah-Hartman
2013-10-03 4:08 ` [ 08/57] bcache: Fix a dumb CPU spinning bug in writeback Greg Kroah-Hartman
2013-10-03 4:08 ` [ 09/57] bcache: Fix a shrinker deadlock Greg Kroah-Hartman
2013-10-03 4:08 ` [ 10/57] bcache: Fix for handling overlapping extents when reading in a btree node Greg Kroah-Hartman
2013-10-03 4:08 ` [ 11/57] bcache: Fix flushes in writeback mode Greg Kroah-Hartman
2013-10-03 4:08 ` [ 12/57] kernel/reboot.c: re-enable the function of variable reboot_default Greg Kroah-Hartman
2013-10-03 4:08 ` [ 13/57] x86/reboot: Add quirk to make Dell C6100 use reboot=pci automatically Greg Kroah-Hartman
2013-10-03 4:08 ` [ 14/57] tools lib lk: Uninclude linux/magic.h in debugfs.c Greg Kroah-Hartman
2013-10-03 4:08 ` [ 15/57] x86, efi: Dont map Boot Services on i386 Greg Kroah-Hartman
2013-10-03 4:08 ` [ 16/57] mei: make me client counters less error prone Greg Kroah-Hartman
2013-10-03 4:08 ` [ 17/57] mei: bus: stop wait for read during cl state transition Greg Kroah-Hartman
2013-10-03 4:08 ` [ 18/57] mei: cancel stall timers in mei_reset Greg Kroah-Hartman
2013-10-03 4:08 ` [ 19/57] tty: Fix SIGTTOU not sent with tcflush() Greg Kroah-Hartman
2013-10-03 4:08 ` [ 20/57] serial: tegra: fix tty-kref leak Greg Kroah-Hartman
2013-10-03 4:08 ` [ 21/57] serial: pch_uart: fix tty-kref leak in rx-error path Greg Kroah-Hartman
2013-10-03 4:08 ` [ 22/57] serial: pch_uart: fix tty-kref leak in dma-rx path Greg Kroah-Hartman
2013-10-03 4:08 ` [ 23/57] ARM: 7837/3: fix Thumb-2 bug in AES assembler code Greg Kroah-Hartman
2013-10-03 4:08 ` [ 24/57] staging: vt6656: [BUG] main_usb.c oops on device_close move flag earlier Greg Kroah-Hartman
2013-10-03 4:08 ` [ 25/57] staging: vt6656: [BUG] iwctl_siwencodeext return if device not open Greg Kroah-Hartman
2013-10-03 4:08 ` [ 26/57] drm/i915/tv: clear adjusted_mode.flags Greg Kroah-Hartman
2013-10-03 4:08 ` [ 27/57] Revert "cw1200: Dont perform SPI transfers in interrupt context" Greg Kroah-Hartman
2013-10-03 4:08 ` [ 28/57] cw1200: Use a threaded oneshot irq handler for cw1200_spi Greg Kroah-Hartman
2013-10-03 4:08 ` [ 29/57] xhci: Ensure a command structure points to the correct trb on the command ring Greg Kroah-Hartman
2013-10-03 4:08 ` [ 30/57] xhci: Fix oops happening after address device timeout Greg Kroah-Hartman
2013-10-03 4:08 ` [ 31/57] USB: fix PM config symbol in uhci-hcd, ehci-hcd, and xhci-hcd Greg Kroah-Hartman
2013-10-03 4:08 ` [ 32/57] xhci: Fix race between ep halt and URB cancellation Greg Kroah-Hartman
2013-10-03 4:08 ` Greg Kroah-Hartman [this message]
2013-10-03 4:09 ` [ 34/57] USB: UHCI: accept very late isochronous URBs Greg Kroah-Hartman
2013-10-03 4:09 ` [ 35/57] USB: Fix breakage in ffs_fs_mount() Greg Kroah-Hartman
2013-10-03 4:09 ` [ 36/57] fsl/usb: Resolve PHY_CLK_VLD instability issue for ULPI phy Greg Kroah-Hartman
2013-10-03 4:09 ` [ 37/57] usb: dwc3: pci: add support for BayTrail Greg Kroah-Hartman
2013-10-03 4:09 ` [ 38/57] usb: dwc3: add support for Merrifield Greg Kroah-Hartman
2013-10-03 4:09 ` [ 39/57] usb/core/devio.c: Dont reject control message to endpoint with wrong direction bit Greg Kroah-Hartman
2013-10-03 4:09 ` [ 40/57] driver core : Fix use after free of dev->parent in device_shutdown Greg Kroah-Hartman
2013-10-03 4:09 ` [ 41/57] dm snapshot: workaround for a false positive lockdep warning Greg Kroah-Hartman
2013-10-03 4:09 ` [ 42/57] dm-snapshot: fix performance degradation due to small hash size Greg Kroah-Hartman
2013-10-03 4:09 ` [ 43/57] dm mpath: disable WRITE SAME if it fails Greg Kroah-Hartman
2013-10-03 4:09 ` [ 44/57] drm/i915: preserve pipe A quirk in i9xx_set_pipeconf Greg Kroah-Hartman
2013-10-03 4:09 ` [ 45/57] drm/i915/dp: increase i2c-over-aux retry interval on AUX DEFER Greg Kroah-Hartman
2013-10-03 4:09 ` [ 46/57] drm/radeon/cik: Fix printing of client name on VM protection fault Greg Kroah-Hartman
2013-10-03 4:09 ` [ 47/57] drm/radeon/cik: Fix encoding of number of banks in tiling configuration info Greg Kroah-Hartman
2013-10-03 4:09 ` [ 48/57] drm/radeon/cik: fix overflow in vram fetch Greg Kroah-Hartman
2013-10-03 4:09 ` [ 49/57] drm/radeon: avoid UVD corruption on AGP cards using GPU gart Greg Kroah-Hartman
2013-10-03 4:09 ` [ 50/57] drm/radeon: Make r100_cp_ring_info() and radeon_ring_gfx() safe (v2) Greg Kroah-Hartman
2013-10-03 4:09 ` [ 51/57] drm/radeon: dont set default clocks for SI when DPM is disabled Greg Kroah-Hartman
2013-10-03 4:09 ` [ 52/57] drm/radeon: disable tests/benchmarks if accel " Greg Kroah-Hartman
2013-10-03 4:09 ` [ 53/57] drm/radeon: add missing hdmi callbacks for rv6xx Greg Kroah-Hartman
2013-10-03 4:09 ` [ 54/57] drm/radeon: fix hdmi audio on DCE3.0/3.1 asics Greg Kroah-Hartman
2013-10-03 4:09 ` [ 55/57] hwmon: (applesmc) Check key count before proceeding Greg Kroah-Hartman
2013-10-03 4:09 ` [ 56/57] ALSA: compress: Fix compress device unregister Greg Kroah-Hartman
2013-10-03 4:09 ` [ 57/57] irq: Always define devm_{request_threaded,free}_irq() Greg Kroah-Hartman
2013-10-03 13:35 ` [ 00/57] 3.11.4-stable review Guenter Roeck
2013-10-03 18:41 ` Greg Kroah-Hartman
2013-10-03 22:56 ` Shuah Khan
2013-10-03 23:03 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131003040638.867435357@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).