Subject: wrong bus_dma(9) usage in dev/ic/lsi64854.c
To: None <port-sparc@netbsd.org, port-sparc64@netbsd.org>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: port-sparc64
Date: 04/01/2001 13:20:09
I notice lsi64854.c calls some bus_dma(9) functions with wrong arguments:
 - BUS_DMA_COHERENT is specified to bus_dmamap_load() flags
 - VA is passed to bus_dmamap_sync() as offset

I think the attached diff is correct, but I don't have any Ultra
machines to test. (stream and sync are no-op on sun4c)

Is it Ok to commit this?
---
Izumi Tsutsui
tsutsui@ceres.dti.ne.jp

Index: lsi64854.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/ic/lsi64854.c,v
retrieving revision 1.15
diff -u -r1.15 lsi64854.c
--- lsi64854.c	2001/03/29 02:58:39	1.15
+++ lsi64854.c	2001/04/01 03:48:12
@@ -331,11 +331,10 @@
 		if (bus_dmamap_load(sc->sc_dmatag, sc->sc_dmamap,
 				*sc->sc_dmaaddr, sc->sc_dmasize,
 				NULL /* kernel address */,   
-		                BUS_DMA_NOWAIT | BUS_DMA_COHERENT))
+		                BUS_DMA_NOWAIT | BUS_DMA_STREAMING))
 			panic("%s: cannot allocate DVMA address",
 			      sc->sc_dev.dv_xname);
-		bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap,
-				(bus_addr_t)(u_long)sc->sc_dvmaaddr, sc->sc_dmasize,
+		bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap, 0, sc->sc_dmasize,
 				datain
 					? BUS_DMASYNC_PREREAD
 					: BUS_DMASYNC_PREWRITE);
@@ -476,8 +475,7 @@
 		trans, resid));
 
 	if (sc->sc_dmamap->dm_nsegs > 0) {
-		bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap,
-				(bus_addr_t)(u_long)sc->sc_dvmaaddr, sc->sc_dmasize,
+		bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap, 0, sc->sc_dmasize,
 				(csr & D_WRITE) != 0
 					? BUS_DMASYNC_POSTREAD
 					: BUS_DMASYNC_POSTWRITE);
@@ -580,8 +578,7 @@
 				    BUS_DMA_NOWAIT/*|BUS_DMA_COHERENT*/))
 			panic("%s: pp cannot allocate DVMA address",
 			      sc->sc_dev.dv_xname);
-		bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap,
-				(bus_addr_t)(u_long)sc->sc_dvmaaddr, sc->sc_dmasize,
+		bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap, 0, sc->sc_dmasize,
 				datain
 					? BUS_DMASYNC_PREREAD
 					: BUS_DMASYNC_PREWRITE);
@@ -666,8 +663,7 @@
 	*sc->sc_dmaaddr += trans;
 
 	if (sc->sc_dmamap->dm_nsegs > 0) {
-		bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap,
-				(bus_addr_t)(u_long)sc->sc_dvmaaddr, sc->sc_dmasize,
+		bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap, 0, sc->sc_dmasize,
 				(csr & D_WRITE) != 0
 					? BUS_DMASYNC_POSTREAD
 					: BUS_DMASYNC_POSTWRITE);