>> I would like to read the DMA buffer while DMA is still going on. >> [...] > This is all very hardware dependent.
That doesn't really surprise me; as MI as bus_dma/bus_space tries to make device drivers, there are still some things it can't really compensate for (or can compensate for in theory, but only at a ruinous performance penalty). > Make sure you map that area with the BUS_DMA_COHERENT flag. Thank you! The manpage called it a hint, so I left it off. I've added it; I'll see if that helps anything. > Many NICs do something like this. Hmm, true; a NIC descriptor ring is not a bad example of the sort of thing I want to do: a block of memory I want to read while DMA is mutating it. >> But I'm not sure what sort of sync calls I need to make. [...] > You want to do a bus_dmamap_sync(BUS_DMASYNC_POSTREAD) [...] > In the NIC example above, you map the ring buffer with > BUS_DMA_COHERENT, fill it up and do a > bus_dmamap_sync(BUS_DMASYNC_PREREAD). When you want to read it > (usually after getting an interrupt) you do > bus_dmamap_sync(BUS_DMASYNC_POSTREAD) before doing the read. Don't you need to PREWRITE after filling it? Based on the mental models I've formed, that feels necessary. >> [...] bus_dmamem_mmap [...] > Trying to do this in userland on a machine with an I/O cache won't > work too good. That's about what I'd expect. > AFAIK amd64 disables all caches on BUS_DMAMAP_COHERENT, so the sync > operations aren't really necessary. But jumping through all these > hoops is important on other hardware. Okay. If I can make it work on amd64 I'll be content for the moment, even if I have to be horribly MD about it. It'd be nice for this to be MI, but not necessary. (The hardware is a data acquisition card which DMAs received data into host memory, but as far as I have been able to tell has no way for the host to tell how far a DMA transfer in progress has progressed. In my case, the data is strongly enough patterned I can fill the buffer with impossible values and tell how far it's gone by looking at the buffer...but that means reading the buffer.) While I don't always mind being MD, I _do_ rather like to know when and how I am. :-) /~\ The ASCII Mouse \ / Ribbon Campaign X Against HTML mo...@rodents-montreal.org / \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B