ChangeSet 1.831.15.11, 2002/12/09 10:08:07-08:00, david-b@pacbell.net

[PATCH] patch 2.5.50+, ehci-hcd loop termination

While in search of a different bug, I found this one
that got in with the recent 'async_next' patch.  The
schedule scan termination changed (had to), but it
wasn't quite correct.  Slower and/or misbehaving
devices might have wedged a CPU ... fix is simple,
only restart the scan when the list may have changed.


diff -Nru a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
--- a/drivers/usb/host/ehci-q.c	Mon Dec  9 11:41:13 2002
+++ b/drivers/usb/host/ehci-q.c	Mon Dec  9 11:41:13 2002
@@ -978,13 +978,18 @@
 		do {
 			/* clean any finished work for this qh */
 			if (!list_empty (&qh->qtd_list)) {
-				// dbg_qh ("scan_async", ehci, qh);
-				qh = qh_get (qh);
+				int temp;
 
-				/* concurrent unlink could happen here */
-				count += qh_completions (ehci, qh);
+				/* unlinks could happen here; completion
+				 * reporting drops the lock.
+				 */
+				qh = qh_get (qh);
+				temp = qh_completions (ehci, qh);
 				qh_put (ehci, qh);
-				goto rescan;
+				if (temp != 0) {
+					count += temp;
+					goto rescan;
+				}
 			}
 
 			/* unlink idle entries, reducing HC PCI usage as
