Patchwork usbnet: runtime pm: fix usb_autopm_get_interface failure

login
register
mail settings
Submitter tom.leiming@gmail.com
Date Oct. 27, 2010, 2:45 p.m.
Message ID <1288190703-3154-1-git-send-email-tom.leiming@gmail.com>
Download mbox | patch
Permalink /patch/69360/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

tom.leiming@gmail.com - Oct. 27, 2010, 2:45 p.m.
From: Ming Lei <tom.leiming@gmail.com>

Since usbnet already took usb runtime pm, we have to
enable runtime pm for usb interface of usbnet, otherwise
usb_autopm_get_interface may return failure and cause
'ifconfig usb0 up' failed if USB_SUSPEND(RUNTIME_PM) is
enabled.

Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: Joe Perches <joe@perches.com>
Cc: Oliver Neukum <oliver@neukum.org>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: stable@kernel.org
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
 drivers/net/usb/usbnet.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
David Miller - Nov. 1, 2010, 1:40 p.m.
From: tom.leiming@gmail.com
Date: Wed, 27 Oct 2010 22:45:03 +0800

> From: Ming Lei <tom.leiming@gmail.com>
> 
> Since usbnet already took usb runtime pm, we have to
> enable runtime pm for usb interface of usbnet, otherwise
> usb_autopm_get_interface may return failure and cause
> 'ifconfig usb0 up' failed if USB_SUSPEND(RUNTIME_PM) is
> enabled.
> 
> Cc: David Brownell <dbrownell@users.sourceforge.net>
> Cc: Greg Kroah-Hartman <gregkh@suse.de>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Ben Hutchings <ben@decadent.org.uk>
> Cc: Joe Perches <joe@perches.com>
> Cc: Oliver Neukum <oliver@neukum.org>
> Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
> Cc: stable@kernel.org
> Signed-off-by: Ming Lei <tom.leiming@gmail.com>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Nov. 1, 2010, 1:42 p.m.
From: David Miller <davem@davemloft.net>
Date: Mon, 01 Nov 2010 06:40:52 -0700 (PDT)

> Applied, thanks.

Actually, I had to revert, this doesn't compile when CONFIG_PM is
disabled:

drivers/net/usb/usbnet.c: In function 'usbnet_probe':
drivers/net/usb/usbnet.c:1284:3: error: implicit declaration of function 'pm_runtime_enable'
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index ca7fc9d..765308f 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1273,6 +1273,16 @@  usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 	struct usb_device		*xdev;
 	int				status;
 	const char			*name;
+	struct usb_driver 	*driver = to_usb_driver(udev->dev.driver);
+
+	/*usbnet already took usb runtime pm, so have to enable the feature
+ 	* for usb interface, otherwise usb_autopm_get_interface may return
+ 	* failure if USB_SUSPEND(RUNTIME_PM) is enabled.
+ 	* */
+	if (!driver->supports_autosuspend) {
+		driver->supports_autosuspend = 1;
+		pm_runtime_enable(&udev->dev);
+	}
 
 	name = udev->dev.driver->name;
 	info = (struct driver_info *) prod->driver_info;