Subject: Re: bus_dmamap_sync() in ti(4) or the lack thereof
To: None <tnn+nbsd@nygren.pp.se>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: tech-kern
Date: 03/03/2007 06:50:18
tnn+nbsd@nygren.pp.se wrote:

> For what it's worth, this patch fixes the problems I had.

PREREAD sync calls are required after new mbufs are allocated,
not where dmamaps are reused, I think.

On POSTREAD sync ops, you can use cur_rx->ti_len for sync length
to avoid unneeded (possible) cache flush ops (or copy from
bounce buffer) for small packets.

BTW, we should also have more TI_CD*SYNC() and TI_CE*SYNC()
calls where DMA descriptor is accessed.

> I'm not sure what to do about the jumbo case, because it uses a single
> dmamap for all descriptors.

With a quick glance, ti(4) allocates its own buffer and uses
MEXTADD(9) for jumbo frames so we don't have to call
bus_dmamap_load() and bus_dmamap_unload() for each xfers,
though bus_dmamap_sync() ops are required like this
(probably we should have some proper macro):
---
	bus_dmamap_sync(sc->sc_dmat, sc->jumbo_dmamap,
	    mtod(m_new, char *) - (char *)sc->ti_cdata.ti_jumbo_buf,
	    TI_JLEN, BUS_DMASYNC_PREREAD);
---
Izumi Tsutsui