* [PATCH] usbnet: rx_submit() should return an error code.
@ 2010-08-09 22:37 Elly Jones
2010-08-10 7:18 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Elly Jones @ 2010-08-09 22:37 UTC (permalink / raw)
To: Oliver Neukum
Cc: Alan Stern, David Miller, netdev-u79uwXL29TY76Z2rM5mHXA, USB list,
Jason Glasgow
This patch makes rx_submit() return an error code, and makes some call sites
that care check the return value. This is important because it lets us properly
handle cases where the device isn't ready to handle URB submissions (e.g., when
it is autosuspended under some drivers); previously, we would attempt and fail
to submit URBs and reschedule ourselves to try and fail again. This patch is
against Linus's 2.6 repo commit 45d7f32c7a43cbb9592886d38190e379e2eb2226.
Signed-Off-By: Elizabeth Jones <ellyjones-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
---
drivers/net/usb/usbnet.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 3b03794..82a992a 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(usbnet_defer_kevent);
static void rx_complete (struct urb *urb);
-static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
+static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
{
struct sk_buff *skb;
struct skb_data *entry;
@@ -327,7 +327,7 @@ static void rx_submit (struct usbnet *dev, struct
urb *urb, gfp_t flags)
netif_dbg(dev, rx_err, dev->net, "no rx skb\n");
usbnet_defer_kevent (dev, EVENT_RX_MEMORY);
usb_free_urb (urb);
- return;
+ return -ENOMEM;
}
skb_reserve (skb, NET_IP_ALIGN);
@@ -357,6 +357,9 @@ static void rx_submit (struct usbnet *dev, struct
urb *urb, gfp_t flags)
netif_dbg(dev, ifdown, dev->net, "device gone\n");
netif_device_detach (dev->net);
break;
+ case -EHOSTUNREACH:
+ retval = -ENOLINK;
+ break;
default:
netif_dbg(dev, rx_err, dev->net,
"rx submit, %d\n", retval);
@@ -374,6 +377,7 @@ static void rx_submit (struct usbnet *dev, struct
urb *urb, gfp_t flags)
dev_kfree_skb_any (skb);
usb_free_urb (urb);
}
+ return retval;
}
@@ -912,6 +916,7 @@ fail_halt:
/* tasklet could resubmit itself forever if memory is tight */
if (test_bit (EVENT_RX_MEMORY, &dev->flags)) {
struct urb *urb = NULL;
+ int resched = 1;
if (netif_running (dev->net))
urb = usb_alloc_urb (0, GFP_KERNEL);
@@ -922,10 +927,12 @@ fail_halt:
status = usb_autopm_get_interface(dev->intf);
if (status < 0)
goto fail_lowmem;
- rx_submit (dev, urb, GFP_KERNEL);
+ if (rx_submit (dev, urb, GFP_KERNEL) == -ENOLINK)
+ resched = 0;
usb_autopm_put_interface(dev->intf);
fail_lowmem:
- tasklet_schedule (&dev->bh);
+ if (resched)
+ tasklet_schedule (&dev->bh);
}
}
@@ -1176,7 +1183,9 @@ static void usbnet_bh (unsigned long param)
for (i = 0; i < 10 && dev->rxq.qlen < qlen; i++) {
urb = usb_alloc_urb (0, GFP_ATOMIC);
if (urb != NULL)
- rx_submit (dev, urb, GFP_ATOMIC);
+ if (rx_submit (dev, urb, GFP_ATOMIC)
+ == -ENOLINK)
+ return;
}
if (temp != dev->rxq.qlen)
netif_dbg(dev, link, dev->net,
--
1.7.1
--
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] 4+ messages in thread
* Re: [PATCH] usbnet: rx_submit() should return an error code.
2010-08-09 22:37 [PATCH] usbnet: rx_submit() should return an error code Elly Jones
@ 2010-08-10 7:18 ` David Miller
[not found] ` <20100810.001855.179947437.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2010-08-10 7:18 UTC (permalink / raw)
To: ellyjones; +Cc: oneukum, stern, netdev, linux-usb, jglasgow
From: Elly Jones <ellyjones@google.com>
Date: Mon, 9 Aug 2010 18:37:50 -0400
> This patch makes rx_submit() return an error code, and makes some call sites
> that care check the return value. This is important because it lets us properly
> handle cases where the device isn't ready to handle URB submissions (e.g., when
> it is autosuspended under some drivers); previously, we would attempt and fail
> to submit URBs and reschedule ourselves to try and fail again. This patch is
> against Linus's 2.6 repo commit 45d7f32c7a43cbb9592886d38190e379e2eb2226.
>
> Signed-Off-By: Elizabeth Jones <ellyjones@google.com>
What gets kevent() running again to run the rx_submit() calls when the
device comes back from being suspended?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] usbnet: rx_submit() should return an error code.
[not found] ` <20100810.001855.179947437.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
@ 2010-08-10 7:42 ` Oliver Neukum
2010-08-10 8:41 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Oliver Neukum @ 2010-08-10 7:42 UTC (permalink / raw)
To: David Miller
Cc: ellyjones-hpIqsD4AKlfQT0dZR+AlfA,
stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz,
netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA,
jglasgow-hpIqsD4AKlfQT0dZR+AlfA
Am Dienstag, 10. August 2010, 09:18:55 schrieb David Miller:
> From: Elly Jones <ellyjones-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
> Date: Mon, 9 Aug 2010 18:37:50 -0400
>
> > This patch makes rx_submit() return an error code, and makes some call sites
> > that care check the return value. This is important because it lets us properly
> > handle cases where the device isn't ready to handle URB submissions (e.g., when
> > it is autosuspended under some drivers); previously, we would attempt and fail
> > to submit URBs and reschedule ourselves to try and fail again. This patch is
> > against Linus's 2.6 repo commit 45d7f32c7a43cbb9592886d38190e379e2eb2226.
> >
> > Signed-Off-By: Elizabeth Jones <ellyjones-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
>
> What gets kevent() running again to run the rx_submit() calls when the
> device comes back from being suspended?
>
usbnet_resume() schedules usbnet_bh() which will take care of that.
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] 4+ messages in thread
* Re: [PATCH] usbnet: rx_submit() should return an error code.
2010-08-10 7:42 ` Oliver Neukum
@ 2010-08-10 8:41 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2010-08-10 8:41 UTC (permalink / raw)
To: oneukum; +Cc: ellyjones, stern, netdev, linux-usb, jglasgow
From: Oliver Neukum <oneukum@suse.de>
Date: Tue, 10 Aug 2010 09:42:05 +0200
> Am Dienstag, 10. August 2010, 09:18:55 schrieb David Miller:
>> From: Elly Jones <ellyjones@google.com>
>> Date: Mon, 9 Aug 2010 18:37:50 -0400
>>
>> > This patch makes rx_submit() return an error code, and makes some call sites
>> > that care check the return value. This is important because it lets us properly
>> > handle cases where the device isn't ready to handle URB submissions (e.g., when
>> > it is autosuspended under some drivers); previously, we would attempt and fail
>> > to submit URBs and reschedule ourselves to try and fail again. This patch is
>> > against Linus's 2.6 repo commit 45d7f32c7a43cbb9592886d38190e379e2eb2226.
>> >
>> > Signed-Off-By: Elizabeth Jones <ellyjones@google.com>
>>
>> What gets kevent() running again to run the rx_submit() calls when the
>> device comes back from being suspended?
>>
>
> usbnet_resume() schedules usbnet_bh() which will take care of that.
That makes sense, I've applied Elizabeth's patch.
But Elizabeth, your patch was severely corrupted by your email client.
Long lines were split up into two, etc. This corrupts the patch and
makes it unusable for us. Please make sure that you have fixed your
email client setup for the next patch you submit.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-08-10 8:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-09 22:37 [PATCH] usbnet: rx_submit() should return an error code Elly Jones
2010-08-10 7:18 ` David Miller
[not found] ` <20100810.001855.179947437.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2010-08-10 7:42 ` Oliver Neukum
2010-08-10 8:41 ` 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).