tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Am I using bus_dma right?
On Wed, Apr 22, 2020 at 05:53:46PM -0400, Mouse wrote:
> s = splhigh()
> while (fewer than n samples copied)
> DMASYNC_POSTREAD for sample at offset o
That should be PREREAD (to make sure the dma'd data is visible for the
cpu)
> read sample at offset o
and teh POSTREAD should be here
> if value is "impossible", break
missig PREWRITE here
> set sample at offset o to "impossible" value
> DMASYNC_PREWRITE for sample at offset o
and this should be POSTWRITE
> store sample in buffer[]
> splx(s)
> uiomove from buffer[]
> if we found an "impossible" value, break;
See the example in the -current man page:
An example of using bus_dmamap_sync(), involving multiple read-
write use of a single mapping might look like this:
bus_dmamap_load(...);
while (not done) {
/* invalidate soon-to-be-stale cache blocks */
bus_dmamap_sync(..., BUS_DMASYNC_PREREAD);
[ do read DMA ]
/* copy from bounce */
bus_dmamap_sync(..., BUS_DMASYNC_POSTREAD);
/* read data now in driver-provided buffer */
[ computation ]
/* data to be written now in driver-provided buffer */
/* flush write buffers and writeback, copy to bounce */
bus_dmamap_sync(..., BUS_DMASYNC_PREWRITE);
[ do write DMA ]
/* probably a no-op, but provided for consistency */
bus_dmamap_sync(..., BUS_DMASYNC_POSTWRITE);
}
bus_dmamap_unload(...);
I always have to look up the direction, but READ is when CPU reads data
provided by the device.
Martin
Home |
Main Index |
Thread Index |
Old Index