From: Rosen Penev <rosenp@gmail.com>
To: netdev@vger.kernel.org
Cc: Chris Snook <chris.snook@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH net-next] net: ag71xx: Unmap TX DMA buffers on completion
Date: Sun, 17 May 2026 14:43:02 -0700 [thread overview]
Message-ID: <20260517214302.1450433-1-rosenp@gmail.com> (raw)
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
reply other threads:[~2026-05-17 21:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260517214302.1450433-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=chris.snook@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox