netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usbnet: Activate halt interrupt endpoint before re-submit URB
@ 2012-06-13 12:50 Huajun Li
  2012-06-17 23:30 ` David Miller
  0 siblings, 1 reply; 12+ messages in thread
From: Huajun Li @ 2012-06-13 12:50 UTC (permalink / raw)
  To: David Miller; +Cc: Ming Lei, Alan Stern, lud, netdev, Huajun Li

intr_complete() submits URB even the interrupt endpoint stalls.
This patch will try to activate the endpoint once the exception
occurs, and then re-submit the URB if the endpoint works again.

Signed-off-by: Huajun Li <huajun.li.lee@gmail.com>
---
 drivers/net/usb/usbnet.c   |   31 +++++++++++++++++++++++++++++++
 include/linux/usb/usbnet.h |   13 +++++++------
 2 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index ac2e493..314aaea 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -198,6 +198,10 @@ static void intr_complete (struct urb *urb)
 			  "intr shutdown, code %d\n", status);
 		return;

+	case -EPIPE:
+		usbnet_defer_kevent(dev, EVENT_STS_HALT);
+		return;
+
 	/* NOTE:  not throttling like RX/TX, since this endpoint
 	 * already polls infrequently
 	 */
@@ -964,6 +968,33 @@ fail_halt:
 		}
 	}

+	if (test_bit(EVENT_STS_HALT, &dev->flags)) {
+		unsigned pipe;
+		struct usb_endpoint_descriptor *desc;
+
+		desc = &dev->status->desc;
+		pipe = usb_rcvintpipe(dev->udev,
+			desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
+		status = usb_autopm_get_interface(dev->intf);
+		if (status < 0)
+			goto fail_sts;
+		status = usb_clear_halt(dev->udev, pipe);
+		if (status < 0) {
+			usb_autopm_put_interface(dev->intf);
+fail_sts:
+			netdev_err(dev->net,
+				"can't clear intr halt, status %d\n", status);
+		} else {
+			clear_bit(EVENT_STS_HALT, &dev->flags);
+			status = usb_submit_urb(dev->interrupt, GFP_KERNEL);
+			if (status != 0)
+				netif_err(dev, timer, dev->net,
+					"intr resubmit --> %d\n", status);
+
+			usb_autopm_put_interface(dev->intf);
+		}
+	}
+
 	/* tasklet could resubmit itself forever if memory is tight */
 	if (test_bit (EVENT_RX_MEMORY, &dev->flags)) {
 		struct urb	*urb = NULL;
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index f87cf62..81b4473 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -62,12 +62,13 @@ struct usbnet {
 	unsigned long		flags;
 #		define EVENT_TX_HALT	0
 #		define EVENT_RX_HALT	1
-#		define EVENT_RX_MEMORY	2
-#		define EVENT_STS_SPLIT	3
-#		define EVENT_LINK_RESET	4
-#		define EVENT_RX_PAUSED	5
-#		define EVENT_DEV_ASLEEP 6
-#		define EVENT_DEV_OPEN	7
+#		define EVENT_STS_HALT	2
+#		define EVENT_RX_MEMORY	3
+#		define EVENT_STS_SPLIT	4
+#		define EVENT_LINK_RESET	5
+#		define EVENT_RX_PAUSED	6
+#		define EVENT_DEV_ASLEEP 7
+#		define EVENT_DEV_OPEN	8
 };

 static inline struct usb_driver *driver_of(struct usb_interface *intf)
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-06-20 10:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-13 12:50 [PATCH] usbnet: Activate halt interrupt endpoint before re-submit URB Huajun Li
2012-06-17 23:30 ` David Miller
     [not found]   ` <20120617.163017.1067800063889498786.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-06-18  7:23     ` Oliver Neukum
     [not found]       ` <201206180923.36091.oneukum-l3A5Bk7waGM@public.gmane.org>
2012-06-18 16:25         ` Huajun Li
     [not found]           ` <CA+v9cxZG6b1O7kOQpeTELtv0vHzqy-8NH84boMpim0BM+tp1eQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-06-18 16:51             ` Oliver Neukum
     [not found]               ` <201206181851.49765.oneukum-l3A5Bk7waGM@public.gmane.org>
2012-06-19 15:50                 ` Ming Lei
2012-06-20  8:00             ` Oliver Neukum
     [not found]               ` <201206201000.21845.oneukum-l3A5Bk7waGM@public.gmane.org>
2012-06-20  8:07                 ` Ming Lei
2012-06-20  8:58                   ` Oliver Neukum
     [not found]                     ` <201206201058.55519.oneukum-l3A5Bk7waGM@public.gmane.org>
2012-06-20 10:15                       ` Ming Lei
2012-06-20 10:21                         ` Oliver Neukum
2012-06-20 10:56                           ` Ming Lei

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).