mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] net: designware: eqos: keep virtual RX buffer address around
Date: Thu,  6 Aug 2026 15:00:03 +0200	[thread overview]
Message-ID: <20260806130003.1964184-1-s.hauer@pengutronix.de> (raw)

To free up the RX buffers in the remove and error paths we need their
virtual address. Instead of reading back the physical address back from
the descriptor ring and throwing phys_to_virt() at it, just keep the
virtual address returned from dma_alloc() around and use that directly.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/designware_eqos.c | 6 ++++--
 drivers/net/designware_eqos.h | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/designware_eqos.c b/drivers/net/designware_eqos.c
index a6e9d8677f..78e52c68b1 100644
--- a/drivers/net/designware_eqos.c
+++ b/drivers/net/designware_eqos.c
@@ -817,6 +817,8 @@ static int eqos_init_resources(struct eqos *eqos)
 	if (!p)
 		goto err_free_desc;
 
+	eqos->rx_bufs = p;
+
 	for (i = 0; i < EQOS_DESCRIPTORS_RX; i++) {
 		struct eqos_desc *rx_rf_desc = &eqos->rx_descs[i];
 		dma_addr_t dma;
@@ -836,7 +838,7 @@ static int eqos_init_resources(struct eqos *eqos)
 	return 0;
 
 err_free_rx_bufs:
-	dma_free(phys_to_virt(eqos->rx_descs[0].des0));
+	dma_free(eqos->rx_bufs);
 err_free_desc:
 	dma_free_coherent(DMA_DEVICE_BROKEN,
 			  descs, 0, EQOS_DESCRIPTORS_SIZE);
@@ -948,7 +950,7 @@ void eqos_remove(struct device *dev)
 
 	mdiobus_unregister(&eqos->miibus);
 
-	dma_free(phys_to_virt(eqos->rx_descs[0].des0));
+	dma_free(eqos->rx_bufs);
 	dma_free_coherent(DMA_DEVICE_BROKEN,
 			  eqos->tx_descs, 0, EQOS_DESCRIPTORS_SIZE);
 }
diff --git a/drivers/net/designware_eqos.h b/drivers/net/designware_eqos.h
index 9f2fc2fe6d..96b6fa71c8 100644
--- a/drivers/net/designware_eqos.h
+++ b/drivers/net/designware_eqos.h
@@ -54,6 +54,7 @@ struct eqos {
 
 	struct eqos_desc *tx_descs, *rx_descs;
 	dma_addr_t dma_rx_buf[EQOS_DESCRIPTORS_RX];
+	void *rx_bufs;
 
 	void __iomem *regs;
 	struct eqos_mac_regs __iomem *mac_regs;
-- 
2.47.3




                 reply	other threads:[~2026-08-06 13:01 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=20260806130003.1964184-1-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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