summaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/files/drivers
diff options
context:
space:
mode:
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-11-24 10:01:12 +0000
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>2010-11-24 10:01:12 +0000
commitc5233949252af88f05848e9b4075fb19822c4ee6 (patch)
treeffff59aa1914848deb2c76f7edda7b06c5a7af01 /target/linux/ramips/files/drivers
parente0af17401fe72c1459dae34aa63a2933887fefac (diff)
ramips: Don't trigger BUG_ON due to skb allocation failure
Instead just drop the rx'ed frame silently and reuse the already available buffer. Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@24122 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ramips/files/drivers')
-rw-r--r--target/linux/ramips/files/drivers/net/ramips.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/target/linux/ramips/files/drivers/net/ramips.c b/target/linux/ramips/files/drivers/net/ramips.c
index e297cbec7..e3c4f13d4 100644
--- a/target/linux/ramips/files/drivers/net/ramips.c
+++ b/target/linux/ramips/files/drivers/net/ramips.c
@@ -272,23 +272,26 @@ ramips_eth_rx_hw(unsigned long ptr)
break;
max_rx--;
- rx_skb = priv->rx_skb[rx];
- skb_put(rx_skb, RX_DMA_PLEN0(priv->rx[rx].rxd2));
- rx_skb->dev = dev;
- rx_skb->protocol = eth_type_trans(rx_skb, dev);
- rx_skb->ip_summed = CHECKSUM_NONE;
- dev->stats.rx_packets++;
- dev->stats.rx_bytes += rx_skb->len;
- netif_rx(rx_skb);
-
new_skb = netdev_alloc_skb(dev, MAX_RX_LENGTH + 2);
- priv->rx_skb[rx] = new_skb;
- BUG_ON(!new_skb);
- skb_reserve(new_skb, 2);
- priv->rx[rx].rxd1 = dma_map_single(NULL,
- new_skb->data,
- MAX_RX_LENGTH + 2,
- DMA_FROM_DEVICE);
+ /* Reuse the buffer on allocation failures */
+ if (new_skb) {
+ rx_skb = priv->rx_skb[rx];
+ skb_put(rx_skb, RX_DMA_PLEN0(priv->rx[rx].rxd2));
+ rx_skb->dev = dev;
+ rx_skb->protocol = eth_type_trans(rx_skb, dev);
+ rx_skb->ip_summed = CHECKSUM_NONE;
+ dev->stats.rx_packets++;
+ dev->stats.rx_bytes += rx_skb->len;
+ netif_rx(rx_skb);
+
+ priv->rx_skb[rx] = new_skb;
+ skb_reserve(new_skb, 2);
+ priv->rx[rx].rxd1 = dma_map_single(NULL,
+ new_skb->data,
+ MAX_RX_LENGTH + 2,
+ DMA_FROM_DEVICE);
+ }
+
priv->rx[rx].rxd2 &= ~RX_DMA_DONE;
wmb();
ramips_fe_wr(rx, RAMIPS_RX_CALC_IDX0);