* Dealing nicely with PM failure
@ 2012-12-14 14:56 Oliver Neukum
2012-12-15 14:14 ` Dave Wiltshire
2012-12-15 14:33 ` Ming Lei
0 siblings, 2 replies; 3+ messages in thread
From: Oliver Neukum @ 2012-12-14 14:56 UTC (permalink / raw)
To: Ming Lei, Steve Glendinning, netdev
Hi,
this question about the smsc devices gave me an idea.
How about this?
>From f1bdff89eea4c10102f867f9f22cb2b60519e425 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oliver@neukum.org>
Date: Fri, 14 Dec 2012 15:51:36 +0100
Subject: [PATCH] usbnet: handle PM failure gracefully
If a device fails to do remote wakeup, this is no reason
to abort an open totally. This patch just continues without
runtime PM.
Signed-off-by: Oliver Neukum <oneukum@suse.de>
---
drivers/net/usb/usbnet.c | 17 +++++++++--------
include/linux/usb/usbnet.h | 1 +
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index c04110b..2010eef 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -719,7 +719,8 @@ int usbnet_stop (struct net_device *net)
dev->flags = 0;
del_timer_sync (&dev->delay);
tasklet_kill (&dev->bh);
- if (info->manage_power)
+ if (info->manage_power &&
+ !test_and_clear_bit(EVENT_NO_RUNTIME_PM, &dev->flags))
info->manage_power(dev, 0);
else
usb_autopm_put_interface(dev->intf);
@@ -793,15 +794,15 @@ int usbnet_open (struct net_device *net)
// delay posting reads until we're fully open
tasklet_schedule (&dev->bh);
if (info->manage_power) {
- retval = info->manage_power(dev, 1);
- if (retval < 0)
- goto done_manage_power_error;
- usb_autopm_put_interface(dev->intf);
+ int r;
+
+ r = info->manage_power(dev, 1);
+ if (r < 0)
+ set_bit(EVENT_NO_RUNTIME_PM, &dev->flags);
+ else
+ usb_autopm_put_interface(dev->intf);
}
return retval;
-
-done_manage_power_error:
- clear_bit(EVENT_DEV_OPEN, &dev->flags);
done:
usb_autopm_put_interface(dev->intf);
done_nopm:
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 9bbeabf..288b32a 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -69,6 +69,7 @@ struct usbnet {
# define EVENT_DEV_ASLEEP 6
# define EVENT_DEV_OPEN 7
# define EVENT_DEVICE_REPORT_IDLE 8
+# define EVENT_NO_RUNTIME_PM 9
};
static inline struct usb_driver *driver_of(struct usb_interface *intf)
--
1.7.7
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: Dealing nicely with PM failure
2012-12-14 14:56 Dealing nicely with PM failure Oliver Neukum
@ 2012-12-15 14:14 ` Dave Wiltshire
2012-12-15 14:33 ` Ming Lei
1 sibling, 0 replies; 3+ messages in thread
From: Dave Wiltshire @ 2012-12-15 14:14 UTC (permalink / raw)
To: Oliver Neukum; +Cc: Ming Lei, Steve Glendinning, netdev
On Fri, Dec 14, 2012 at 03:56:26PM +0100, Oliver Neukum wrote:
> @@ -793,15 +794,15 @@ int usbnet_open (struct net_device *net)
> // delay posting reads until we're fully open
> tasklet_schedule (&dev->bh);
> if (info->manage_power) {
> - retval = info->manage_power(dev, 1);
> - if (retval < 0)
> - goto done_manage_power_error;
> - usb_autopm_put_interface(dev->intf);
> + int r;
> +
> + r = info->manage_power(dev, 1);
> + if (r < 0)
> + set_bit(EVENT_NO_RUNTIME_PM, &dev->flags);
> + else
> + usb_autopm_put_interface(dev->intf);
> }
> return retval;
Did you mean to change the return value in the successful case? This
used to return 0 on a successful call to info->manage_power(dev, 1).
This patch changes that - perhaps it's still the same (if retval is set
above).
Dave
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Dealing nicely with PM failure
2012-12-14 14:56 Dealing nicely with PM failure Oliver Neukum
2012-12-15 14:14 ` Dave Wiltshire
@ 2012-12-15 14:33 ` Ming Lei
1 sibling, 0 replies; 3+ messages in thread
From: Ming Lei @ 2012-12-15 14:33 UTC (permalink / raw)
To: Oliver Neukum; +Cc: Steve Glendinning, netdev
On Fri, Dec 14, 2012 at 10:56 PM, Oliver Neukum <oneukum@suse.de> wrote:
> Hi,
>
> this question about the smsc devices gave me an idea.
> How about this?
It is a good idea to handle remote wakeup failure, but I am wondering
if it is suitable to apply it on current smsc problem because we know
in advance if these devices can support auto suspend.
>
> From f1bdff89eea4c10102f867f9f22cb2b60519e425 Mon Sep 17 00:00:00 2001
> From: Oliver Neukum <oliver@neukum.org>
> Date: Fri, 14 Dec 2012 15:51:36 +0100
> Subject: [PATCH] usbnet: handle PM failure gracefully
>
> If a device fails to do remote wakeup, this is no reason
> to abort an open totally. This patch just continues without
> runtime PM.
>
> Signed-off-by: Oliver Neukum <oneukum@suse.de>
> ---
> drivers/net/usb/usbnet.c | 17 +++++++++--------
> include/linux/usb/usbnet.h | 1 +
> 2 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
> index c04110b..2010eef 100644
> --- a/drivers/net/usb/usbnet.c
> +++ b/drivers/net/usb/usbnet.c
> @@ -719,7 +719,8 @@ int usbnet_stop (struct net_device *net)
> dev->flags = 0;
> del_timer_sync (&dev->delay);
> tasklet_kill (&dev->bh);
> - if (info->manage_power)
> + if (info->manage_power &&
> + !test_and_clear_bit(EVENT_NO_RUNTIME_PM, &dev->flags))
> info->manage_power(dev, 0);
> else
> usb_autopm_put_interface(dev->intf);
> @@ -793,15 +794,15 @@ int usbnet_open (struct net_device *net)
> // delay posting reads until we're fully open
> tasklet_schedule (&dev->bh);
> if (info->manage_power) {
> - retval = info->manage_power(dev, 1);
> - if (retval < 0)
> - goto done_manage_power_error;
> - usb_autopm_put_interface(dev->intf);
> + int r;
> +
> + r = info->manage_power(dev, 1);
> + if (r < 0)
> + set_bit(EVENT_NO_RUNTIME_PM, &dev->flags);
> + else
> + usb_autopm_put_interface(dev->intf);
> }
> return retval;
> -
> -done_manage_power_error:
> - clear_bit(EVENT_DEV_OPEN, &dev->flags);
> done:
> usb_autopm_put_interface(dev->intf);
> done_nopm:
> diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
> index 9bbeabf..288b32a 100644
> --- a/include/linux/usb/usbnet.h
> +++ b/include/linux/usb/usbnet.h
> @@ -69,6 +69,7 @@ struct usbnet {
> # define EVENT_DEV_ASLEEP 6
> # define EVENT_DEV_OPEN 7
> # define EVENT_DEVICE_REPORT_IDLE 8
> +# define EVENT_NO_RUNTIME_PM 9
> };
>
> static inline struct usb_driver *driver_of(struct usb_interface *intf)
> --
> 1.7.7
>
>
Thanks,
--
Ming Lei
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-15 14:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-14 14:56 Dealing nicely with PM failure Oliver Neukum
2012-12-15 14:14 ` Dave Wiltshire
2012-12-15 14:33 ` 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).