Skip to content

Commit d974730

Browse files
committed
Merge branch 'net-lantiq_xrx200-fix-errors-under-memory-pressure'
Aleksander Jan Bajkowski says: ==================== net: lantiq_xrx200: fix errors under memory pressure This series fixes issues that can occur in the driver under memory pressure. Situations when the system cannot allocate memory are rare, so the mentioned bugs have been fixed recently. The patches have been tested on a BT Home router with the Lantiq xRX200 chipset. Changelog: v3: - removed netdev_err() log from the first patch v2: - the second patch has been changed, so that under memory pressure situation the driver will not receive packets indefinitely regardless of the NAPI budget, - the third patch has been added. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents a3a57bf + c9c3b17 commit d974730

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/net/ethernet/lantiq_xrx200.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ static int xrx200_alloc_buf(struct xrx200_chan *ch, void *(*alloc)(unsigned int
193193

194194
ch->rx_buff[ch->dma.desc] = alloc(priv->rx_skb_size);
195195
if (!ch->rx_buff[ch->dma.desc]) {
196+
ch->rx_buff[ch->dma.desc] = buf;
196197
ret = -ENOMEM;
197198
goto skip;
198199
}
@@ -239,6 +240,12 @@ static int xrx200_hw_receive(struct xrx200_chan *ch)
239240
}
240241

241242
skb = build_skb(buf, priv->rx_skb_size);
243+
if (!skb) {
244+
skb_free_frag(buf);
245+
net_dev->stats.rx_dropped++;
246+
return -ENOMEM;
247+
}
248+
242249
skb_reserve(skb, NET_SKB_PAD);
243250
skb_put(skb, len);
244251

@@ -288,7 +295,7 @@ static int xrx200_poll_rx(struct napi_struct *napi, int budget)
288295
if (ret == XRX200_DMA_PACKET_IN_PROGRESS)
289296
continue;
290297
if (ret != XRX200_DMA_PACKET_COMPLETE)
291-
return ret;
298+
break;
292299
rx++;
293300
} else {
294301
break;

0 commit comments

Comments
 (0)