Commit 01c17142 authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

USB: fix EHCI periodic transfers

As noted by Stefan Neis <Stefan.Neis@kobil.com>, we had a recent
regression with EHCI periodic transfers, in some (seemingly not
all that common) cases.

The root cause was that the schedule activation was only loosely
coupled to the addition or removal of transfers, so two different
execution contexts could both think they had to deactivate (or
conversely activate) the schedule.  So this fix tightens that
coupling, managing it more like a refcount.
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 0590d587
...@@ -437,6 +437,9 @@ static int enable_periodic (struct ehci_hcd *ehci) ...@@ -437,6 +437,9 @@ static int enable_periodic (struct ehci_hcd *ehci)
u32 cmd; u32 cmd;
int status; int status;
if (ehci->periodic_sched++)
return 0;
/* did clearing PSE did take effect yet? /* did clearing PSE did take effect yet?
* takes effect only at frame boundaries... * takes effect only at frame boundaries...
*/ */
...@@ -461,6 +464,9 @@ static int disable_periodic (struct ehci_hcd *ehci) ...@@ -461,6 +464,9 @@ static int disable_periodic (struct ehci_hcd *ehci)
u32 cmd; u32 cmd;
int status; int status;
if (--ehci->periodic_sched)
return 0;
/* did setting PSE not take effect yet? /* did setting PSE not take effect yet?
* takes effect only at frame boundaries... * takes effect only at frame boundaries...
*/ */
...@@ -544,13 +550,10 @@ static int qh_link_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh) ...@@ -544,13 +550,10 @@ static int qh_link_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh)
: (qh->usecs * 8); : (qh->usecs * 8);
/* maybe enable periodic schedule processing */ /* maybe enable periodic schedule processing */
if (!ehci->periodic_sched++) return enable_periodic(ehci);
return enable_periodic (ehci);
return 0;
} }
static void qh_unlink_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh) static int qh_unlink_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh)
{ {
unsigned i; unsigned i;
unsigned period; unsigned period;
...@@ -586,9 +589,7 @@ static void qh_unlink_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh) ...@@ -586,9 +589,7 @@ static void qh_unlink_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh)
qh_put (qh); qh_put (qh);
/* maybe turn off periodic schedule */ /* maybe turn off periodic schedule */
ehci->periodic_sched--; return disable_periodic(ehci);
if (!ehci->periodic_sched)
(void) disable_periodic (ehci);
} }
static void intr_deschedule (struct ehci_hcd *ehci, struct ehci_qh *qh) static void intr_deschedule (struct ehci_hcd *ehci, struct ehci_qh *qh)
...@@ -1562,9 +1563,7 @@ itd_link_urb ( ...@@ -1562,9 +1563,7 @@ itd_link_urb (
urb->hcpriv = NULL; urb->hcpriv = NULL;
timer_action (ehci, TIMER_IO_WATCHDOG); timer_action (ehci, TIMER_IO_WATCHDOG);
if (unlikely (!ehci->periodic_sched++)) return enable_periodic(ehci);
return enable_periodic (ehci);
return 0;
} }
#define ISO_ERRS (EHCI_ISOC_BUF_ERR | EHCI_ISOC_BABBLE | EHCI_ISOC_XACTERR) #define ISO_ERRS (EHCI_ISOC_BUF_ERR | EHCI_ISOC_BABBLE | EHCI_ISOC_XACTERR)
...@@ -1642,7 +1641,7 @@ itd_complete ( ...@@ -1642,7 +1641,7 @@ itd_complete (
ehci_urb_done(ehci, urb, 0); ehci_urb_done(ehci, urb, 0);
retval = true; retval = true;
urb = NULL; urb = NULL;
ehci->periodic_sched--; (void) disable_periodic(ehci);
ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--;
if (unlikely (list_empty (&stream->td_list))) { if (unlikely (list_empty (&stream->td_list))) {
...@@ -1951,9 +1950,7 @@ sitd_link_urb ( ...@@ -1951,9 +1950,7 @@ sitd_link_urb (
urb->hcpriv = NULL; urb->hcpriv = NULL;
timer_action (ehci, TIMER_IO_WATCHDOG); timer_action (ehci, TIMER_IO_WATCHDOG);
if (!ehci->periodic_sched++) return enable_periodic(ehci);
return enable_periodic (ehci);
return 0;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -2019,7 +2016,7 @@ sitd_complete ( ...@@ -2019,7 +2016,7 @@ sitd_complete (
ehci_urb_done(ehci, urb, 0); ehci_urb_done(ehci, urb, 0);
retval = true; retval = true;
urb = NULL; urb = NULL;
ehci->periodic_sched--; (void) disable_periodic(ehci);
ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--;
if (list_empty (&stream->td_list)) { if (list_empty (&stream->td_list)) {
...@@ -2243,8 +2240,7 @@ restart: ...@@ -2243,8 +2240,7 @@ restart:
if (unlikely (modified)) { if (unlikely (modified)) {
if (likely(ehci->periodic_sched > 0)) if (likely(ehci->periodic_sched > 0))
goto restart; goto restart;
/* maybe we can short-circuit this scan! */ /* short-circuit this scan */
disable_periodic(ehci);
now_uframe = clock; now_uframe = clock;
break; break;
} }
......
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