git: f0a7dd770312 - main - dwc: Setup desc addresses in the dma init function.

From: Emmanuel Vadot <manu_at_FreeBSD.org>
Date: Thu, 05 Oct 2023 15:35:09 UTC
The branch main has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=f0a7dd7703124af42da3705bb11e785c0eb9f0c4

commit f0a7dd7703124af42da3705bb11e785c0eb9f0c4
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2023-10-03 16:46:56 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2023-10-05 15:34:40 +0000

    dwc: Setup desc addresses in the dma init function.
---
 sys/dev/dwc/dwc1000_dma.c | 11 +++++++++++
 sys/dev/dwc/if_dwc.c      | 11 -----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/sys/dev/dwc/dwc1000_dma.c b/sys/dev/dwc/dwc1000_dma.c
index 3d95c9d8e764..cdfd24afd574 100644
--- a/sys/dev/dwc/dwc1000_dma.c
+++ b/sys/dev/dwc/dwc1000_dma.c
@@ -605,10 +605,18 @@ int
 dma1000_init(struct dwc_softc *sc)
 {
 	struct mbuf *m;
+	uint32_t reg;
 	int error;
 	int nidx;
 	int idx;
 
+	/*
+	 * DMA must be stop while changing descriptor list addresses.
+	 */
+	reg = READ4(sc, OPERATION_MODE);
+	reg &= ~(MODE_ST | MODE_SR);
+	WRITE4(sc, OPERATION_MODE, reg);
+
 	/*
 	 * Set up TX descriptor ring, descriptors, and dma maps.
 	 */
@@ -684,6 +692,8 @@ dma1000_init(struct dwc_softc *sc)
 	for (idx = 0; idx < TX_DESC_COUNT; idx++)
 		dwc_setup_txdesc(sc, idx, 0, 0, 0, false, false);
 
+	WRITE4(sc, TX_DESCR_LIST_ADDR, sc->txdesc_ring_paddr);
+
 	/*
 	 * Set up RX descriptor ring, descriptors, dma maps, and mbufs.
 	 */
@@ -758,6 +768,7 @@ dma1000_init(struct dwc_softc *sc)
 			goto out;
 		}
 	}
+	WRITE4(sc, RX_DESCR_LIST_ADDR, sc->rxdesc_ring_paddr);
 
 out:
 	if (error != 0)
diff --git a/sys/dev/dwc/if_dwc.c b/sys/dev/dwc/if_dwc.c
index 896e2f2205a0..0df99a7c205c 100644
--- a/sys/dev/dwc/if_dwc.c
+++ b/sys/dev/dwc/if_dwc.c
@@ -610,22 +610,11 @@ dwc_attach(device_t dev)
 
 	WRITE4(sc, BUS_MODE, reg);
 
-	/*
-	 * DMA must be stop while changing descriptor list addresses.
-	 */
-	reg = READ4(sc, OPERATION_MODE);
-	reg &= ~(MODE_ST | MODE_SR);
-	WRITE4(sc, OPERATION_MODE, reg);
-
 	if (dma1000_init(sc)) {
 		bus_release_resources(dev, dwc_spec, sc->res);
 		return (ENXIO);
 	}
 
-	/* Setup addresses */
-	WRITE4(sc, RX_DESCR_LIST_ADDR, sc->rxdesc_ring_paddr);
-	WRITE4(sc, TX_DESCR_LIST_ADDR, sc->txdesc_ring_paddr);
-
 	mtx_init(&sc->mtx, device_get_nameunit(sc->dev),
 	    MTX_NETWORK_LOCK, MTX_DEF);