git: 43cd6bbba053 - main - dwc: re-rewrite barrier part

From: Emmanuel Vadot <manu_at_FreeBSD.org>
Date: Thu, 12 Oct 2023 18:56:39 UTC
The branch main has been updated by manu:

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

commit 43cd6bbba053f02999d846ef297655ebec2d218b
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2023-10-12 18:54:52 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2023-10-12 18:56:16 +0000

    dwc: re-rewrite barrier part
    
    We need the DMA engine to have everything coherent *before* we
    set the OWN bit (the bit that tells the DMA engine that it owns
    the descriptor).
    
    Fixes:  487034648805 ("dwc: Rewrite barrier part")
    
    Reported by:    jhb
---
 sys/dev/dwc/dwc1000_dma.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/dev/dwc/dwc1000_dma.c b/sys/dev/dwc/dwc1000_dma.c
index 4f8ae088305a..c91036f5a714 100644
--- a/sys/dev/dwc/dwc1000_dma.c
+++ b/sys/dev/dwc/dwc1000_dma.c
@@ -216,8 +216,8 @@ txdesc_setup(struct dwc_softc *sc, int idx, bus_addr_t paddr,
 	sc->txdesc_ring[idx].addr1 = (uint32_t)(paddr);
 	sc->txdesc_ring[idx].desc0 = desc0;
 	sc->txdesc_ring[idx].desc1 = desc1;
-	sc->txdesc_ring[idx].desc0 |= TDESC0_OWN;
 	wmb();
+	sc->txdesc_ring[idx].desc0 |= TDESC0_OWN;
 }
 
 inline static uint32_t
@@ -236,8 +236,8 @@ rxdesc_setup(struct dwc_softc *sc, int idx, bus_addr_t paddr)
 		sc->rxdesc_ring[idx].desc1 = ERDESC1_RCH |
 		    MIN(MCLBYTES, ERDESC1_RBS1_MASK);
 
-	sc->rxdesc_ring[idx].desc0 = RDESC0_OWN;
 	wmb();
+	sc->rxdesc_ring[idx].desc0 = RDESC0_OWN;
 	return (nidx);
 }
 
@@ -522,8 +522,8 @@ dma1000_rxfinish_locked(struct dwc_softc *sc)
 
 		m = dwc_rxfinish_one(sc, desc, sc->rxbuf_map + idx);
 		if (m == NULL) {
-			desc->desc0 = RDESC0_OWN;
 			wmb();
+			desc->desc0 = RDESC0_OWN;
 		} else {
 			/* We cannot create hole in RX ring */
 			error = dma1000_setup_rxbuf(sc, idx, m);