From: Ming Lei <tom.leiming@gmail.com>
To: Karel Gardas <karel.gardas@centrum.cz>
Cc: linux-kernel@vger.kernel.org,
linux-usb <linux-usb@vger.kernel.org>,
Network Development <netdev@vger.kernel.org>
Subject: Re: ETH over USB: NFS state (seeking ARM platform for NFS-based builds)
Date: Sun, 5 Jun 2011 13:13:28 +0800 [thread overview]
Message-ID: <BANLkTin3KKoa4A3xie7J0QaBcvr-NYPrbQ@mail.gmail.com> (raw)
In-Reply-To: <4DEA5D78.5030402@centrum.cz>
Hi,
2011/6/5 Karel Gardas <karel.gardas@centrum.cz>:
> Hello,
>
> while searching for ARMv7/NEON platform for my own hacking I've found this
> interesting issue:
>
> [ 2945.114135] cc1: page allocation failure. order:3, mode:0x4020
Maybe the patch below can fix the issue, please try it:
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 9ab439d..f16e448 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -324,12 +324,20 @@ static int rx_submit (struct usbnet *dev, struct
urb *urb, gfp_t flags)
unsigned long lockflags;
size_t size = dev->rx_urb_size;
- if ((skb = alloc_skb (size + NET_IP_ALIGN, flags)) == NULL) {
- netif_dbg(dev, rx_err, dev->net, "no rx skb\n");
+ if (atomic_read(&dev->rx_skb_on_fly) > MAX_RX_SKB_ON_FLY &&
+ flags == GFP_ATOMIC) {
+ netif_dbg(dev, rx_err, dev->net, "too many rx skbs on the fly\n");
+fail_rx_memory:
usbnet_defer_kevent (dev, EVENT_RX_MEMORY);
usb_free_urb (urb);
return -ENOMEM;
}
+
+ if ((skb = alloc_skb (size + NET_IP_ALIGN, flags)) == NULL) {
+ netif_dbg(dev, rx_err, dev->net, "no rx skb\n");
+ goto fail_rx_memory;
+ }
+ atomic_inc(&dev->rx_skb_on_fly);
skb_reserve (skb, NET_IP_ALIGN);
entry = (struct skb_data *) skb->cb;
@@ -375,6 +383,7 @@ static int rx_submit (struct usbnet *dev, struct
urb *urb, gfp_t flags)
}
spin_unlock_irqrestore (&dev->rxq.lock, lockflags);
if (retval) {
+ atomic_dec(&dev->rx_skb_on_fly);
dev_kfree_skb_any (skb);
usb_free_urb (urb);
}
@@ -1177,8 +1186,9 @@ static void usbnet_bh (unsigned long param)
entry->state = rx_cleanup;
rx_process (dev, skb);
continue;
- case tx_done:
case rx_cleanup:
+ atomic_dec(&dev->rx_skb_on_fly);
+ case tx_done:
usb_free_urb (entry->urb);
dev_kfree_skb (skb);
continue;
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 605b0aa..1dace0d 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -33,6 +33,8 @@ struct usbnet {
wait_queue_head_t *wait;
struct mutex phy_mutex;
unsigned char suspend_count;
+ atomic_t rx_skb_on_fly;
+# define MAX_RX_SKB_ON_FLY 2048
/* i/o info: pipes etc */
unsigned in, out;
thanks,
--
Ming Lei
prev parent reply other threads:[~2011-06-05 5:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-04 16:29 ETH over USB: NFS state (seeking ARM platform for NFS-based builds) Karel Gardas
2011-06-05 5:13 ` Ming Lei [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BANLkTin3KKoa4A3xie7J0QaBcvr-NYPrbQ@mail.gmail.com \
--to=tom.leiming@gmail.com \
--cc=karel.gardas@centrum.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).