Skip to content

Commit beb1930

Browse files
IoanaCiorneidavem330
authored andcommitted
dpaa2-eth: recycle the RX buffer only after all processing done
The blamed commit added support for Rx copybreak. This meant that for certain frame sizes, a new skb was allocated and the initial data buffer was recycled. Instead of waiting to recycle the Rx buffer only after all processing was done on it (like accessing the parse results or timestamp information), the code path just went ahead and re-used the buffer right away. This sometimes lead to corrupted HW and SW annotation areas. Fix this by delaying the moment when the buffer is recycled. Fixes: 50f8269 ("dpaa2-eth: add rx copybreak support") Signed-off-by: Ioana Ciornei <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f422abe commit beb1930

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,6 @@ struct sk_buff *dpaa2_eth_alloc_skb(struct dpaa2_eth_priv *priv,
516516

517517
memcpy(skb->data, fd_vaddr + fd_offset, fd_length);
518518

519-
dpaa2_eth_recycle_buf(priv, ch, dpaa2_fd_get_addr(fd));
520-
521519
return skb;
522520
}
523521

@@ -589,6 +587,7 @@ void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
589587
struct rtnl_link_stats64 *percpu_stats;
590588
struct dpaa2_eth_drv_stats *percpu_extras;
591589
struct device *dev = priv->net_dev->dev.parent;
590+
bool recycle_rx_buf = false;
592591
void *buf_data;
593592
u32 xdp_act;
594593

@@ -618,6 +617,8 @@ void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
618617
dma_unmap_page(dev, addr, priv->rx_buf_size,
619618
DMA_BIDIRECTIONAL);
620619
skb = dpaa2_eth_build_linear_skb(ch, fd, vaddr);
620+
} else {
621+
recycle_rx_buf = true;
621622
}
622623
} else if (fd_format == dpaa2_fd_sg) {
623624
WARN_ON(priv->xdp_prog);
@@ -637,6 +638,9 @@ void dpaa2_eth_rx(struct dpaa2_eth_priv *priv,
637638
goto err_build_skb;
638639

639640
dpaa2_eth_receive_skb(priv, ch, fd, vaddr, fq, percpu_stats, skb);
641+
642+
if (recycle_rx_buf)
643+
dpaa2_eth_recycle_buf(priv, ch, dpaa2_fd_get_addr(fd));
640644
return;
641645

642646
err_build_skb:

0 commit comments

Comments
 (0)