Re: USB Disconnects / resets after commit b963801164618e25fbdc0cd452ce49c3628b46c8

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 18 Apr 2011, Matej Kenda wrote:

> Hi,
> 
> This message contains additional information that might help resolving
> the issue which was discussed on this mailing list two weeks ago:
> 
> http://article.gmane.org/gmane.linux.usb.general/44862
> 
> https://bugzilla.kernel.org/show_bug.cgi?id=32432
> 
> A bug report 701011 in Launchpad contains additional description of
> the problem and kernel logs with traces created with
> options:
> 
> CONFIG_USB_STORAGE_DEBUG=y
> CONFIG_USB=y
> CONFIG_USB_DEBUG=y
> 
> https://bugs.launchpad.net/linux/+bug/701011
> https://launchpadlibrarian.net/62011653/hudson-slave-last-part.log

Here's a patch for you to test.  It isn't exactly a reversion of the 
"USB: ehci-hcd unlink speedups" commit.

It's worth noting that the log you posted does not indicate the real 
reason for the problem.

> Jan 10 10:41:24 hudson-slave [262397.557075] hub 1-0:1.0: state 7 ports 8 chg 0000 evt 0040
> Jan 10 10:41:24 hudson-slave [262397.558208] ehci_hcd 0000:00:1d.7: GetStatus port 6 status 001002 POWER sig=se0 CSC
> Jan 10 10:41:24 hudson-slave [262397.559358] hub 1-0:1.0: port 6, status 0100, change 0001, 12 Mb/s
> Jan 10 10:41:24 hudson-slave [262397.560489] usb 1-6: USB disconnect, address 6

This is where the trouble starts:  The USB drive disconnects.  It is
far from clear what relation might exist between the commit you found
and this disconnection.

Alan Stern



Index: 2.6.38/drivers/usb/host/ehci-hcd.c
===================================================================
--- 2.6.38.orig/drivers/usb/host/ehci-hcd.c
+++ 2.6.38/drivers/usb/host/ehci-hcd.c
@@ -90,7 +90,7 @@ static const char	hcd_name [] = "ehci_hc
 #define EHCI_IAA_MSECS		10		/* arbitrary */
 #define EHCI_IO_JIFFIES		(HZ/10)		/* io watchdog > irq_thresh */
 #define EHCI_ASYNC_JIFFIES	(HZ/20)		/* async idle timeout */
-#define EHCI_SHRINK_FRAMES	5		/* async qh unlink delay */
+#define EHCI_SHRINK_JIFFIES	(HZ/200 + 2)	/* async qh unlink delay */
 
 /* Initial IRQ latency:  faster than hw default */
 static int log2_irq_thresh = 0;		// 0 to 6
@@ -150,10 +150,7 @@ timer_action(struct ehci_hcd *ehci, enum
 			break;
 		/* case TIMER_ASYNC_SHRINK: */
 		default:
-			/* add a jiffie since we synch against the
-			 * 8 KHz uframe counter.
-			 */
-			t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1;
+			t = EHCI_SHRINK_JIFFIES;
 			break;
 		}
 		mod_timer(&ehci->watchdog, t + jiffies);
Index: 2.6.38/drivers/usb/host/ehci-q.c
===================================================================
--- 2.6.38.orig/drivers/usb/host/ehci-q.c
+++ 2.6.38/drivers/usb/host/ehci-q.c
@@ -1260,7 +1260,8 @@ static void scan_async (struct ehci_hcd 
 	struct ehci_qh		*qh;
 	enum ehci_timer_action	action = TIMER_IO_WATCHDOG;
 
-	ehci->stamp = ehci_readl(ehci, &ehci->regs->frame_index);
+	ehci->stamp++;
+	ehci->stamp += !ehci->stamp;
 	timer_action_done (ehci, TIMER_ASYNC_SHRINK);
 rescan:
 	qh = ehci->async->qh_next.qh;
@@ -1281,6 +1282,7 @@ rescan:
 				temp = qh_completions (ehci, qh);
 				if (qh->needs_rescan)
 					unlink_async(ehci, qh);
+				qh->unlink_time = jiffies + EHCI_SHRINK_JIFFIES;
 				qh_put (qh);
 				if (temp != 0) {
 					goto rescan;
@@ -1295,9 +1297,8 @@ rescan:
 			 */
 			if (list_empty(&qh->qtd_list)
 					&& qh->qh_state == QH_STATE_LINKED) {
-				if (!ehci->reclaim
-					&& ((ehci->stamp - qh->stamp) & 0x1fff)
-						>= (EHCI_SHRINK_FRAMES * 8))
+				if (!ehci->reclaim && time_after_eq(jiffies,
+						qh->unlink_time))
 					start_unlink_async(ehci, qh);
 				else
 					action = TIMER_ASYNC_SHRINK;
Index: 2.6.38/drivers/usb/host/ehci.h
===================================================================
--- 2.6.38.orig/drivers/usb/host/ehci.h
+++ 2.6.38/drivers/usb/host/ehci.h
@@ -336,6 +336,8 @@ struct ehci_qh {
 	struct ehci_qh		*reclaim;	/* next to reclaim */
 
 	struct ehci_hcd		*ehci;
+	unsigned long		unlink_time;
+	unsigned		stamp;
 
 	/*
 	 * Do NOT use atomic operations for QH refcounting. On some CPUs
@@ -344,7 +346,6 @@ struct ehci_qh {
 	 * Spinlocks are used to protect all QH fields.
 	 */
 	u32			refcount;
-	unsigned		stamp;
 
 	u8			needs_rescan;	/* Dequeue during giveback */
 	u8			qh_state;

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux