net: ag71xx: Unmap TX DMA buffers on completion
Subsystems (3)
PATCH 1/1 net: ag71xx: Unmap TX DMA buffers on completion
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 <[email protected]>
--- drivers/net/ethernet/atheros/ag71xx.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/atheros/ag71xx.c +7 -0
@@ -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;
Signature · 1 line
2.54.0
Jakub Kicinski
maintainerQuoted 5 lines · 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..
Signature · 1 line
pw-bot: reject