Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next] net: ag71xx: Unmap TX DMA buffers on completion
@ 2026-05-17 21:43 Rosen Penev
  2026-05-20 23:59 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-05-17 21:43 UTC (permalink / raw)
  To: netdev
  Cc: Chris Snook, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, open list

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] net: ag71xx: Unmap TX DMA buffers on completion
  2026-05-17 21:43 [PATCH net-next] net: ag71xx: Unmap TX DMA buffers on completion Rosen Penev
@ 2026-05-20 23:59 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2026-05-20 23:59 UTC (permalink / raw)
  To: Rosen Penev
  Cc: netdev, Chris Snook, Andrew Lunn, David S. Miller, Eric Dumazet,
	Paolo Abeni, open list

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-20 23:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-17 21:43 [PATCH net-next] net: ag71xx: Unmap TX DMA buffers on completion Rosen Penev
2026-05-20 23:59 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox