aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2015-06-30 11:25:54 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-07-22 17:46:50 -0400
commit7d8021c967648accd1b78e5e1ddaad655cd2c61f (patch)
treeafd9fdfe29eb3ffdeaac8b2745ff6275d56da475
parent2d2a316765d956bc5cb6bb367b2ec52ca59ab8e9 (diff)
USB: OHCI: Fix race between ED unlink and URB submission
This patch fixes a bug introduced by commit 977dcfdc6031 ("USB: OHCI: don't lose track of EDs when a controller dies"). The commit changed ed_state from ED_UNLINK to ED_IDLE too early, before finish_urb() had been called. The user-visible consequence is that the driver occasionally crashes or locks up when an URB is submitted while another URB for the same endpoint is being unlinked. This patch moves the ED state change later, to the right place. The drawback is that now we may unnecessarily execute some instructions multiple times when a controller dies. Since controllers dying is an exceptional occurrence, a little wasted time won't matter. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reported-by: Heiko Przybyl <lil_tux@web.de> Tested-by: Heiko Przybyl <lil_tux@web.de> Fixes: 977dcfdc60311e7aa571cabf6f39c36dde13339e CC: <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/host/ohci-q.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index f7d561ed3c23..d029bbe9eb36 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -981,10 +981,6 @@ rescan_all:
981 int completed, modified; 981 int completed, modified;
982 __hc32 *prev; 982 __hc32 *prev;
983 983
984 /* Is this ED already invisible to the hardware? */
985 if (ed->state == ED_IDLE)
986 goto ed_idle;
987
988 /* only take off EDs that the HC isn't using, accounting for 984 /* only take off EDs that the HC isn't using, accounting for
989 * frame counter wraps and EDs with partially retired TDs 985 * frame counter wraps and EDs with partially retired TDs
990 */ 986 */
@@ -1012,12 +1008,10 @@ skip_ed:
1012 } 1008 }
1013 1009
1014 /* ED's now officially unlinked, hc doesn't see */ 1010 /* ED's now officially unlinked, hc doesn't see */
1015 ed->state = ED_IDLE;
1016 ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_H); 1011 ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_H);
1017 ed->hwNextED = 0; 1012 ed->hwNextED = 0;
1018 wmb(); 1013 wmb();
1019 ed->hwINFO &= ~cpu_to_hc32(ohci, ED_SKIP | ED_DEQUEUE); 1014 ed->hwINFO &= ~cpu_to_hc32(ohci, ED_SKIP | ED_DEQUEUE);
1020ed_idle:
1021 1015
1022 /* reentrancy: if we drop the schedule lock, someone might 1016 /* reentrancy: if we drop the schedule lock, someone might
1023 * have modified this list. normally it's just prepending 1017 * have modified this list. normally it's just prepending
@@ -1088,6 +1082,7 @@ rescan_this:
1088 if (list_empty(&ed->td_list)) { 1082 if (list_empty(&ed->td_list)) {
1089 *last = ed->ed_next; 1083 *last = ed->ed_next;
1090 ed->ed_next = NULL; 1084 ed->ed_next = NULL;
1085 ed->state = ED_IDLE;
1091 list_del(&ed->in_use_list); 1086 list_del(&ed->in_use_list);
1092 } else if (ohci->rh_state == OHCI_RH_RUNNING) { 1087 } else if (ohci->rh_state == OHCI_RH_RUNNING) {
1093 *last = ed->ed_next; 1088 *last = ed->ed_next;