Thread (3 messages) 3 messages, 3 authors, 2011-04-26

Re: [PATCHv5] usbnet: Resubmit interrupt URB once if halted

From: Paul Stewart <hidden>
Date: 2011-04-22 15:59:15

Possibly related (same subject, not in this thread)

On Fri, Apr 22, 2011 at 8:47 AM, Alan Stern [off-list ref] wrote:
On Tue, 19 Apr 2011, Paul Stewart wrote:
quoted
Resubmit interrupt URB if device is open.  Use a flag set in
usbnet_open() to determine this state.  Also kill and free
interrupt URB in usbnet_disconnect().
Generally good, but a couple of things are questionable...
quoted
Signed-off-by: Paul Stewart <redacted>
---
 drivers/net/usb/usbnet.c   |   14 ++++++++++++++
 include/linux/usb/usbnet.h |    1 +
 2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 02d25c7..c7cf4af 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -643,6 +643,7 @@ static int usbnet_open (struct net_device *net)
              }
      }

+     set_bit(EVENT_DEV_OPEN, &dev->flags);
      netif_start_queue (net);
      if (netif_msg_ifup (dev)) {
              char    *framing;
You forgot to clear this flag in usbnet_stop().
Actually, I didn't.  Note that flags are set to 0 in usbnet_stop().
By the way, there is FLAG_AVOID_UNLINK_URBS defined in usbnet.h and
used in usbnet_stop().  Is it meant to apply to the interrupt URB as
well as the others?
I don't know who to ask about that.  Whether or not the flag is set,
in practice the interrupt URB still seems to be killed by some other
facility, so regardless of that request, they may lose anyway.
quoted
@@ -1105,6 +1106,11 @@ void usbnet_disconnect (struct usb_interface *intf)
      if (dev->driver_info->unbind)
              dev->driver_info->unbind (dev, intf);

+     if (dev->interrupt) {
+             usb_kill_urb(dev->interrupt);
+             usb_free_urb(dev->interrupt);
+     }
+
usb_kill_urb and usb_free_urb include their own tests for urb == NULL;
you don't need to test it here or below.
Okay.
quoted
      free_netdev(net);
      usb_put_dev (xdev);
 }
@@ -1285,6 +1291,10 @@ int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
               * wake the device
               */
              netif_device_attach (dev->net);
+
+             /* Stop interrupt URBs */
+             if (dev->interrupt)
+                     usb_kill_urb(dev->interrupt);
      }
      return 0;
 }
There is a subtle question here: When is the best time to kill the
interrupt URB?  Without knowing any of the details, I'd guess that the
interrupt URB reports asynchronous events and the driver could run into
trouble if one of those events occurred while everything else was
turned off.  This suggests that the interrupt URB should be killed as
soon as possible rather than as late as possible.  But maybe it doesn't
matter; it all depends on the design of the driver.
I'm not sure I can answer this question either.  As it stands, nobody
was killing them before.  Just trying to make it better.
quoted
@@ -1297,6 +1307,10 @@ int usbnet_resume (struct usb_interface *intf)
      if (!--dev->suspend_count)
              tasklet_schedule (&dev->bh);

+             /* resume interrupt URBs */
+             if (dev->interrupt && test_bit(EVENT_DEV_OPEN, &dev->flags))
+                     usb_submit_urb(dev->interrupt, GFP_NOIO);
+
      return 0;
 }
Alan Stern
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help