drivers/net/ethernet/atheros/ag71xx.c | 7 +++++++ 1 file changed, 7 insertions(+)
Store the DMA address used for each transmitted skb and unmap it when
the skb is completed or cleaned from the TX ring.
This keeps the streaming DMA mapping lifetime paired with the skb
lifetime on both normal completion and shutdown cleanup paths.
Assisted-by: Codex:GPT-5.5
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/net/ethernet/atheros/ag71xx.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c
index ac4eadb9190a..50136d6ccda6 100644
--- a/drivers/net/ethernet/atheros/ag71xx.c
+++ b/drivers/net/ethernet/atheros/ag71xx.c
@@ -305,6 +305,7 @@ struct ag71xx_buf {
union {
struct {
struct sk_buff *skb;
+ dma_addr_t dma_addr;
unsigned int len;
} tx;
struct {
@@ -805,6 +806,8 @@ static int ag71xx_tx_packets(struct ag71xx *ag, bool flush, int budget)
if (!skb)
continue;
+ dma_unmap_single(&ag->pdev->dev, ring->buf[i].tx.dma_addr,
+ ring->buf[i].tx.len, DMA_TO_DEVICE);
napi_consume_skb(skb, budget);
ring->buf[i].tx.skb = NULL;
@@ -1133,6 +1136,9 @@ static void ag71xx_ring_tx_clean(struct ag71xx *ag)
}
if (ring->buf[i].tx.skb) {
+ dma_unmap_single(&ag->pdev->dev,
+ ring->buf[i].tx.dma_addr,
+ ring->buf[i].tx.len, DMA_TO_DEVICE);
bytes_compl += ring->buf[i].tx.len;
pkts_compl++;
dev_kfree_skb_any(ring->buf[i].tx.skb);
@@ -1531,6 +1537,7 @@ static netdev_tx_t ag71xx_hard_start_xmit(struct sk_buff *skb,
goto err_drop_unmap;
i = (ring->curr + n - 1) & ring_mask;
+ ring->buf[i].tx.dma_addr = dma_addr;
ring->buf[i].tx.len = skb->len;
ring->buf[i].tx.skb = skb;
--
2.54.0
On Sun, 17 May 2026 14:43:02 -0700 Rosen Penev wrote: > Store the DMA address used for each transmitted skb and unmap it when > the skb is completed or cleaned from the TX ring. > > This keeps the streaming DMA mapping lifetime paired with the skb > lifetime on both normal completion and shutdown cleanup paths. This must obviously not matter on the platforms where this driver is used, otherwise we'd run out of memory in no time.. -- pw-bot: reject
© 2016 - 2026 Red Hat, Inc.