From 571fa74034701391b1be2ad193f684acfdeb75d1 Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 14 May 2012 15:17:20 +0100 Subject: dmaengine: virt-dma: add support for cyclic DMA periodic callbacks Add support for cyclic DMA's periodic callbacks. Drivers are expected to call vchan_cyclic_callback() when a period has completed, which will schedule the tasklet to make the callback into the driver. As callbacks are made from tasklet context, it is important to realise that we don't guarantee a callback for each completed period, but for N completed periods where N may be greater than one. Tested-by: Linus Walleij Signed-off-by: Russell King --- drivers/dma/virt-dma.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'drivers/dma/virt-dma.c') diff --git a/drivers/dma/virt-dma.c b/drivers/dma/virt-dma.c index a8054fc40cef..6f80432a3f0a 100644 --- a/drivers/dma/virt-dma.c +++ b/drivers/dma/virt-dma.c @@ -59,17 +59,28 @@ EXPORT_SYMBOL_GPL(vchan_find_desc); static void vchan_complete(unsigned long arg) { struct virt_dma_chan *vc = (struct virt_dma_chan *)arg; + struct virt_dma_desc *vd; + dma_async_tx_callback cb = NULL; + void *cb_data = NULL; LIST_HEAD(head); spin_lock_irq(&vc->lock); list_splice_tail_init(&vc->desc_completed, &head); + vd = vc->cyclic; + if (vd) { + vc->cyclic = NULL; + cb = vd->tx.callback; + cb_data = vd->tx.callback_param; + } spin_unlock_irq(&vc->lock); + if (cb) + cb(cb_data); + while (!list_empty(&head)) { - struct virt_dma_desc *vd = list_first_entry(&head, - struct virt_dma_desc, node); - dma_async_tx_callback cb = vd->tx.callback; - void *cb_data = vd->tx.callback_param; + vd = list_first_entry(&head, struct virt_dma_desc, node); + cb = vd->tx.callback; + cb_data = vd->tx.callback_param; list_del(&vd->node); -- cgit 1.4.1