* [PATCH -v1 0/3] usbnet: usbnet: PM related fixes
@ 2012-06-20 7:15 Ming Lei
2012-06-20 7:15 ` [PATCH -v1 1/3] usbnet: clear OPEN flag in failure path Ming Lei
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Ming Lei @ 2012-06-20 7:15 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman; +Cc: Oliver Neukum, netdev, linux-usb
Hi David,
The 3 patches fix some PM related problems.
v1:
- one line fix in 3/3: GFP_ATOMIC -> flags in rx_alloc_submit
drivers/net/usb/usbnet.c | 47 +++++++++++++++++++++++++++++-----------------
1 file changed, 30 insertions(+), 17 deletions(-)
Thanks,
--
Ming Lei
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH -v1 1/3] usbnet: clear OPEN flag in failure path
2012-06-20 7:15 [PATCH -v1 0/3] usbnet: usbnet: PM related fixes Ming Lei
@ 2012-06-20 7:15 ` Ming Lei
2012-06-20 7:44 ` Oliver Neukum
2012-06-20 7:46 ` [PATCH -v1 0/3] usbnet: usbnet: PM related fixes Oliver Neukum
[not found] ` <1340176553-32225-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2 siblings, 1 reply; 11+ messages in thread
From: Ming Lei @ 2012-06-20 7:15 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, netdev, linux-usb, Ming Lei
Without clearing OPEN flag in failure path, runtime or system resume
may submit interrupt/rx URB and start tx queue mistakenly on a
interface in DOWN state.
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
drivers/net/usb/usbnet.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index ac2e493..f06cf9b 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -793,11 +793,13 @@ int usbnet_open (struct net_device *net)
if (info->manage_power) {
retval = info->manage_power(dev, 1);
if (retval < 0)
- goto done;
+ goto done_manage_power_error;
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:
--
1.7.9.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH -v1 2/3] usbnet: decrease suspend count if returning -EBUSY for runtime suspend
[not found] ` <1340176553-32225-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
@ 2012-06-20 7:15 ` Ming Lei
[not found] ` <1340176553-32225-3-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2012-06-20 7:15 ` [PATCH -v1 3/3] usbnet: handle remote wakeup asap Ming Lei
2012-06-23 0:34 ` [PATCH -v1 0/3] usbnet: usbnet: PM related fixes David Miller
2 siblings, 1 reply; 11+ messages in thread
From: Ming Lei @ 2012-06-20 7:15 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA, Ming Lei
This patch decreases dev->suspend_count in the -EBUSY failure path
of usbnet_suspend. Without the change, the later runtime suspend
will do nothing except for increasing dev->suspend_count.
Signed-off-by: Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
---
drivers/net/usb/usbnet.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index f06cf9b..9bfa775 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1508,6 +1508,7 @@ int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
spin_lock_irq(&dev->txq.lock);
/* don't autosuspend while transmitting */
if (dev->txq.qlen && PMSG_IS_AUTO(message)) {
+ dev->suspend_count--;
spin_unlock_irq(&dev->txq.lock);
return -EBUSY;
} else {
--
1.7.9.5
--
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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH -v1 3/3] usbnet: handle remote wakeup asap
[not found] ` <1340176553-32225-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2012-06-20 7:15 ` [PATCH -v1 2/3] usbnet: decrease suspend count if returning -EBUSY for runtime suspend Ming Lei
@ 2012-06-20 7:15 ` Ming Lei
2012-06-20 7:46 ` Oliver Neukum
[not found] ` <1340176553-32225-4-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2012-06-23 0:34 ` [PATCH -v1 0/3] usbnet: usbnet: PM related fixes David Miller
2 siblings, 2 replies; 11+ messages in thread
From: Ming Lei @ 2012-06-20 7:15 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman
Cc: Oliver Neukum, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA, Ming Lei
If usbnet is resumed by remote wakeup, generally there are
some packets comming to be handled, so allocate and submit
rx URBs in usbnet_resume to avoid delays introduced by tasklet.
Otherwise, usbnet may have been runtime suspended before the
usbnet_bh is executed to schedule Rx URBs.
Without the patch, usbnet can't recieve any packets from peer
in runtime suspend state if runtime PM is enabled and
autosuspend_delay is set as zero.
Signed-off-by: Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
---
drivers/net/usb/usbnet.c | 42 ++++++++++++++++++++++++++----------------
1 file changed, 26 insertions(+), 16 deletions(-)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 9bfa775..a89d6c5 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1201,6 +1201,21 @@ deferred:
}
EXPORT_SYMBOL_GPL(usbnet_start_xmit);
+static void rx_alloc_submit(struct usbnet *dev, gfp_t flags)
+{
+ struct urb *urb;
+ int i;
+
+ /* don't refill the queue all at once */
+ for (i = 0; i < 10 && dev->rxq.qlen < RX_QLEN(dev); i++) {
+ urb = usb_alloc_urb(0, flags);
+ if (urb != NULL) {
+ if (rx_submit(dev, urb, flags) == -ENOLINK)
+ return;
+ }
+ }
+}
+
/*-------------------------------------------------------------------------*/
// tasklet (work deferred from completions, in_irq) or timer
@@ -1240,26 +1255,14 @@ static void usbnet_bh (unsigned long param)
!timer_pending (&dev->delay) &&
!test_bit (EVENT_RX_HALT, &dev->flags)) {
int temp = dev->rxq.qlen;
- int qlen = RX_QLEN (dev);
-
- if (temp < qlen) {
- struct urb *urb;
- int i;
-
- // don't refill the queue all at once
- for (i = 0; i < 10 && dev->rxq.qlen < qlen; i++) {
- urb = usb_alloc_urb (0, GFP_ATOMIC);
- if (urb != NULL) {
- if (rx_submit (dev, urb, GFP_ATOMIC) ==
- -ENOLINK)
- return;
- }
- }
+
+ if (temp < RX_QLEN(dev)) {
+ rx_alloc_submit(dev, GFP_ATOMIC);
if (temp != dev->rxq.qlen)
netif_dbg(dev, link, dev->net,
"rxqlen %d --> %d\n",
temp, dev->rxq.qlen);
- if (dev->rxq.qlen < qlen)
+ if (dev->rxq.qlen < RX_QLEN(dev))
tasklet_schedule (&dev->bh);
}
if (dev->txq.qlen < TX_QLEN (dev))
@@ -1565,6 +1568,13 @@ int usbnet_resume (struct usb_interface *intf)
spin_unlock_irq(&dev->txq.lock);
if (test_bit(EVENT_DEV_OPEN, &dev->flags)) {
+ /* handle remote wakeup ASAP */
+ if (!dev->wait &&
+ netif_device_present(dev->net) &&
+ !timer_pending(&dev->delay) &&
+ !test_bit(EVENT_RX_HALT, &dev->flags))
+ rx_alloc_submit(dev, GFP_KERNEL);
+
if (!(dev->txq.qlen >= TX_QLEN(dev)))
netif_tx_wake_all_queues(dev->net);
tasklet_schedule (&dev->bh);
--
1.7.9.5
--
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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH -v1 1/3] usbnet: clear OPEN flag in failure path
2012-06-20 7:15 ` [PATCH -v1 1/3] usbnet: clear OPEN flag in failure path Ming Lei
@ 2012-06-20 7:44 ` Oliver Neukum
0 siblings, 0 replies; 11+ messages in thread
From: Oliver Neukum @ 2012-06-20 7:44 UTC (permalink / raw)
To: Ming Lei; +Cc: David S. Miller, Greg Kroah-Hartman, netdev, linux-usb
Am Mittwoch, 20. Juni 2012, 09:15:51 schrieb Ming Lei:
> Without clearing OPEN flag in failure path, runtime or system resume
> may submit interrupt/rx URB and start tx queue mistakenly on a
> interface in DOWN state.
>
> Signed-off-by: Ming Lei <ming.lei@canonical.com>
Acked-by: Oliver Neukum <oneukum@suse.de>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH -v1 2/3] usbnet: decrease suspend count if returning -EBUSY for runtime suspend
[not found] ` <1340176553-32225-3-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
@ 2012-06-20 7:45 ` Oliver Neukum
0 siblings, 0 replies; 11+ messages in thread
From: Oliver Neukum @ 2012-06-20 7:45 UTC (permalink / raw)
To: Ming Lei
Cc: David S. Miller, Greg Kroah-Hartman,
netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA
Am Mittwoch, 20. Juni 2012, 09:15:52 schrieb Ming Lei:
> This patch decreases dev->suspend_count in the -EBUSY failure path
> of usbnet_suspend. Without the change, the later runtime suspend
> will do nothing except for increasing dev->suspend_count.
>
> Signed-off-by: Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
Acked-by: Oliver Neukum <oneukum-l3A5Bk7waGM@public.gmane.org>
--
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH -v1 3/3] usbnet: handle remote wakeup asap
2012-06-20 7:15 ` [PATCH -v1 3/3] usbnet: handle remote wakeup asap Ming Lei
@ 2012-06-20 7:46 ` Oliver Neukum
[not found] ` <1340176553-32225-4-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
1 sibling, 0 replies; 11+ messages in thread
From: Oliver Neukum @ 2012-06-20 7:46 UTC (permalink / raw)
To: Ming Lei; +Cc: David S. Miller, Greg Kroah-Hartman, netdev, linux-usb
Am Mittwoch, 20. Juni 2012, 09:15:53 schrieb Ming Lei:
> If usbnet is resumed by remote wakeup, generally there are
> some packets comming to be handled, so allocate and submit
> rx URBs in usbnet_resume to avoid delays introduced by tasklet.
> Otherwise, usbnet may have been runtime suspended before the
> usbnet_bh is executed to schedule Rx URBs.
>
> Without the patch, usbnet can't recieve any packets from peer
> in runtime suspend state if runtime PM is enabled and
> autosuspend_delay is set as zero.
>
> Signed-off-by: Ming Lei <ming.lei@canonical.com>
Acked-by: Oliver Neukum <oneukum@suse.de>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH -v1 0/3] usbnet: usbnet: PM related fixes
2012-06-20 7:15 [PATCH -v1 0/3] usbnet: usbnet: PM related fixes Ming Lei
2012-06-20 7:15 ` [PATCH -v1 1/3] usbnet: clear OPEN flag in failure path Ming Lei
@ 2012-06-20 7:46 ` Oliver Neukum
[not found] ` <1340176553-32225-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2 siblings, 0 replies; 11+ messages in thread
From: Oliver Neukum @ 2012-06-20 7:46 UTC (permalink / raw)
To: Ming Lei; +Cc: David S. Miller, Greg Kroah-Hartman, netdev, linux-usb
Am Mittwoch, 20. Juni 2012, 09:15:50 schrieb Ming Lei:
> Hi David,
>
> The 3 patches fix some PM related problems.
The first two patches should go into stable.
Could you send them?
Regards
Oliver
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH -v1 3/3] usbnet: handle remote wakeup asap
[not found] ` <1340176553-32225-4-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
@ 2012-06-20 11:02 ` Sergei Shtylyov
[not found] ` <4FE1ADB4.4060302-Igf4POYTYCDQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 11+ messages in thread
From: Sergei Shtylyov @ 2012-06-20 11:02 UTC (permalink / raw)
To: Ming Lei
Cc: David S. Miller, Greg Kroah-Hartman, Oliver Neukum,
netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA
Hello.
On 20-06-2012 11:15, Ming Lei wrote:
> If usbnet is resumed by remote wakeup, generally there are
> some packets comming to be handled, so allocate and submit
> rx URBs in usbnet_resume to avoid delays introduced by tasklet.
> Otherwise, usbnet may have been runtime suspended before the
> usbnet_bh is executed to schedule Rx URBs.
> Without the patch, usbnet can't recieve any packets from peer
> in runtime suspend state if runtime PM is enabled and
> autosuspend_delay is set as zero.
> Signed-off-by: Ming Lei<ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
> ---
> drivers/net/usb/usbnet.c | 42 ++++++++++++++++++++++++++----------------
> 1 file changed, 26 insertions(+), 16 deletions(-)
> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
> index 9bfa775..a89d6c5 100644
> --- a/drivers/net/usb/usbnet.c
> +++ b/drivers/net/usb/usbnet.c
> @@ -1201,6 +1201,21 @@ deferred:
> }
> EXPORT_SYMBOL_GPL(usbnet_start_xmit);
>
> +static void rx_alloc_submit(struct usbnet *dev, gfp_t flags)
> +{
> + struct urb *urb;
> + int i;
> +
> + /* don't refill the queue all at once */
> + for (i = 0; i< 10&& dev->rxq.qlen< RX_QLEN(dev); i++) {
> + urb = usb_alloc_urb(0, flags);
> + if (urb != NULL) {
> + if (rx_submit(dev, urb, flags) == -ENOLINK)
The above 2 *if* statements can be collapsed into single one.
> + return;
> + }
> + }
> +}
> +
WBR, Sergei
--
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH -v1 3/3] usbnet: handle remote wakeup asap
[not found] ` <4FE1ADB4.4060302-Igf4POYTYCDQT0dZR+AlfA@public.gmane.org>
@ 2012-06-20 11:24 ` Oliver Neukum
0 siblings, 0 replies; 11+ messages in thread
From: Oliver Neukum @ 2012-06-20 11:24 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: Ming Lei, David S. Miller, Greg Kroah-Hartman,
netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA
Am Mittwoch, 20. Juni 2012, 13:02:12 schrieb Sergei Shtylyov:
> > Without the patch, usbnet can't recieve any packets from peer
> > in runtime suspend state if runtime PM is enabled and
> > autosuspend_delay is set as zero.
>
> > Signed-off-by: Ming Lei<ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
> > ---
> > drivers/net/usb/usbnet.c | 42 ++++++++++++++++++++++++++----------------
> > 1 file changed, 26 insertions(+), 16 deletions(-)
>
> > diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
> > index 9bfa775..a89d6c5 100644
> > --- a/drivers/net/usb/usbnet.c
> > +++ b/drivers/net/usb/usbnet.c
> > @@ -1201,6 +1201,21 @@ deferred:
> > }
> > EXPORT_SYMBOL_GPL(usbnet_start_xmit);
> >
> > +static void rx_alloc_submit(struct usbnet *dev, gfp_t flags)
> > +{
> > + struct urb *urb;
> > + int i;
> > +
> > + /* don't refill the queue all at once */
> > + for (i = 0; i< 10&& dev->rxq.qlen< RX_QLEN(dev); i++) {
> > + urb = usb_alloc_urb(0, flags);
> > + if (urb != NULL) {
> > + if (rx_submit(dev, urb, flags) == -ENOLINK)
>
> The above 2 if statements can be collapsed into single one.
>
That would not improve readability.
Regards
Oliver
--
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH -v1 0/3] usbnet: usbnet: PM related fixes
[not found] ` <1340176553-32225-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2012-06-20 7:15 ` [PATCH -v1 2/3] usbnet: decrease suspend count if returning -EBUSY for runtime suspend Ming Lei
2012-06-20 7:15 ` [PATCH -v1 3/3] usbnet: handle remote wakeup asap Ming Lei
@ 2012-06-23 0:34 ` David Miller
2 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2012-06-23 0:34 UTC (permalink / raw)
To: ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw
Cc: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r, oneukum-l3A5Bk7waGM,
netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA
From: Ming Lei <ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
Date: Wed, 20 Jun 2012 15:15:50 +0800
> The 3 patches fix some PM related problems.
>
> v1:
> - one line fix in 3/3: GFP_ATOMIC -> flags in rx_alloc_submit
All applied, thank you.
--
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
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-06-23 0:34 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-20 7:15 [PATCH -v1 0/3] usbnet: usbnet: PM related fixes Ming Lei
2012-06-20 7:15 ` [PATCH -v1 1/3] usbnet: clear OPEN flag in failure path Ming Lei
2012-06-20 7:44 ` Oliver Neukum
2012-06-20 7:46 ` [PATCH -v1 0/3] usbnet: usbnet: PM related fixes Oliver Neukum
[not found] ` <1340176553-32225-1-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2012-06-20 7:15 ` [PATCH -v1 2/3] usbnet: decrease suspend count if returning -EBUSY for runtime suspend Ming Lei
[not found] ` <1340176553-32225-3-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2012-06-20 7:45 ` Oliver Neukum
2012-06-20 7:15 ` [PATCH -v1 3/3] usbnet: handle remote wakeup asap Ming Lei
2012-06-20 7:46 ` Oliver Neukum
[not found] ` <1340176553-32225-4-git-send-email-ming.lei-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2012-06-20 11:02 ` Sergei Shtylyov
[not found] ` <4FE1ADB4.4060302-Igf4POYTYCDQT0dZR+AlfA@public.gmane.org>
2012-06-20 11:24 ` Oliver Neukum
2012-06-23 0:34 ` [PATCH -v1 0/3] usbnet: usbnet: PM related fixes David Miller
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).