From: Ian Abbott Date: Thu, 27 Nov 2014 11:37:18 +0000 (+0000) Subject: staging: comedi: adl_pci9118: try and avoid unnecessary DMA restart X-Git-Tag: omap-for-v3.19/fixes-rc1~73^2~60 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb4a51a1b5d5acde77f814689aa467304bd942fb;p=pandora-kernel.git staging: comedi: adl_pci9118: try and avoid unnecessary DMA restart `interrupt_pci9118_ai_dma()` is called on interrupt to transfer data from DMA buffers into the comedi async data buffer. Currently it always restarts DMA. If double buffering, it restarts DMA on the next DMA buffer before processing the current DMA buffer, otherwise it restarts DMA on the same DMA buffer after it has been processed. For single buffering we can avoid restarting the DMA transfer by checking the async event flags after the current buffer has been processed, which is easy. For double buffering, we need to know how many valid samples there are in the current buffer before it has been processed and determine whether there is enough to complete the acquisition. Call new function `valid_samples_in_act_dma_buf()` to determine the number of valid samples in the current DMA buffer, and compare that with the result of `comedi_nsamples_left()` to determine if DMA needs to be restarted. (`comedi_nsamples_left()` needs an upper bound to clamp to, so use the number of valid samples in the DMA buffer plus one for our test.) It is still possible for DMA to be restarted unnecessarily in the double buffer case if a `COMEDI_CB_OVERFLOW` event occurs while copying to the comedi async buffer, but it doesn't really matter. The ongoing DMA operation will get disabled when the subdevice's `cancel()` handler is called when the events are handled later in the interrupt service routine (as it does currently). Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- Reading git-diff-tree failed