- From: David Schleef <ds_at_schleef.org>
- Date: Thu, 14 Nov 2002 15:51:08 -0800
On Thu, Nov 14, 2002 at 07:13:16PM +0100, Frank Mori Hess wrote: > We got dma analog output (and input) working with the NI 611x cards, but I've > hit two issues with output dma. How to munge output data that is being dma'd > directly from the buffer, and how to reliably detect underruns? > It seems to me the best way to munge the output data would be for the driver > to provide the comedi module with a munging function it can apply when moving > data from user space to async->prealloc_buf. This wouldn't work for > memory-mapped output though. It would be ok for mmap, too, since the application still needs to update the buffer pointers. The munging can be done there, and is probably most appropriate, since that's when the data will be in the CPU cache. > To catch underruns without race conditions, it seems we would need to do the > same kind of thing, where the comedi module would need to be able to poll the > driver to find out how much it has read, and this would need to happen right > after moving data from user space to async->prealloc_buf. Again, this > wouldn't work for memory-mapped output. The buffering code should be able to handle this, I think. It just requires careful management of who owns which part of the buffer. The reader (i.e., the driver/DMA engine) will own most of it on average. Accurately handling overruns, that is, making sure that no incorrect sample is output, is difficult. I don't care too much about that right now. To do that properly would require playing with the link structures during DMA, unlinking buffer pages that aren't allocated to the driver. I think that checking in the link completion interrupt that there hasn't been an overrun is sufficient. Or even checking that the next page/link is full of good samples -- which would be 90% as good as the link unlinking method. I think. dave...
Received on 2002-11-14Z23:51:08