Subject: Re: wrong bus_dma(9) usage in dev/ic/lsi64854.c
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
From: Jason R Thorpe <thorpej@zembu.com>
List: port-sparc
Date: 03/31/2001 23:08:45
On Sun, Apr 01, 2001 at 01:20:09PM +0900, Izumi Tsutsui wrote:

 >  - 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)

You should not use STREAMING -- STREAMING is the "opposite" of
STREAMING.

 > 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);

-- 
        -- Jason R. Thorpe <thorpej@zembu.com>