diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2012-05-14 10:17:20 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2012-07-01 09:15:23 -0400 |
commit | 571fa74034701391b1be2ad193f684acfdeb75d1 (patch) | |
tree | b19b5fac263f5c23a053ac7db41d11ce634afb6b /drivers | |
parent | fe045874aaf4480386c65baf1acae82af4c5e21f (diff) |
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 <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/dma/virt-dma.c | 19 | ||||
-rw-r--r-- | drivers/dma/virt-dma.h | 14 |
2 files changed, 29 insertions, 4 deletions
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); | |||
59 | static void vchan_complete(unsigned long arg) | 59 | static void vchan_complete(unsigned long arg) |
60 | { | 60 | { |
61 | struct virt_dma_chan *vc = (struct virt_dma_chan *)arg; | 61 | struct virt_dma_chan *vc = (struct virt_dma_chan *)arg; |
62 | struct virt_dma_desc *vd; | ||
63 | dma_async_tx_callback cb = NULL; | ||
64 | void *cb_data = NULL; | ||
62 | LIST_HEAD(head); | 65 | LIST_HEAD(head); |
63 | 66 | ||
64 | spin_lock_irq(&vc->lock); | 67 | spin_lock_irq(&vc->lock); |
65 | list_splice_tail_init(&vc->desc_completed, &head); | 68 | list_splice_tail_init(&vc->desc_completed, &head); |
69 | vd = vc->cyclic; | ||
70 | if (vd) { | ||
71 | vc->cyclic = NULL; | ||
72 | cb = vd->tx.callback; | ||
73 | cb_data = vd->tx.callback_param; | ||
74 | } | ||
66 | spin_unlock_irq(&vc->lock); | 75 | spin_unlock_irq(&vc->lock); |
67 | 76 | ||
77 | if (cb) | ||
78 | cb(cb_data); | ||
79 | |||
68 | while (!list_empty(&head)) { | 80 | while (!list_empty(&head)) { |
69 | struct virt_dma_desc *vd = list_first_entry(&head, | 81 | vd = list_first_entry(&head, struct virt_dma_desc, node); |
70 | struct virt_dma_desc, node); | 82 | cb = vd->tx.callback; |
71 | dma_async_tx_callback cb = vd->tx.callback; | 83 | cb_data = vd->tx.callback_param; |
72 | void *cb_data = vd->tx.callback_param; | ||
73 | 84 | ||
74 | list_del(&vd->node); | 85 | list_del(&vd->node); |
75 | 86 | ||
diff --git a/drivers/dma/virt-dma.h b/drivers/dma/virt-dma.h index 44ec57e7e419..85c19d63f9fb 100644 --- a/drivers/dma/virt-dma.h +++ b/drivers/dma/virt-dma.h | |||
@@ -32,6 +32,8 @@ struct virt_dma_chan { | |||
32 | struct list_head desc_submitted; | 32 | struct list_head desc_submitted; |
33 | struct list_head desc_issued; | 33 | struct list_head desc_issued; |
34 | struct list_head desc_completed; | 34 | struct list_head desc_completed; |
35 | |||
36 | struct virt_dma_desc *cyclic; | ||
35 | }; | 37 | }; |
36 | 38 | ||
37 | static inline struct virt_dma_chan *to_virt_chan(struct dma_chan *chan) | 39 | static inline struct virt_dma_chan *to_virt_chan(struct dma_chan *chan) |
@@ -92,6 +94,18 @@ static inline void vchan_cookie_complete(struct virt_dma_desc *vd) | |||
92 | } | 94 | } |
93 | 95 | ||
94 | /** | 96 | /** |
97 | * vchan_cyclic_callback - report the completion of a period | ||
98 | * vd: virtual descriptor | ||
99 | */ | ||
100 | static inline void vchan_cyclic_callback(struct virt_dma_desc *vd) | ||
101 | { | ||
102 | struct virt_dma_chan *vc = to_virt_chan(vd->tx.chan); | ||
103 | |||
104 | vc->cyclic = vd; | ||
105 | tasklet_schedule(&vc->task); | ||
106 | } | ||
107 | |||
108 | /** | ||
95 | * vchan_next_desc - peek at the next descriptor to be processed | 109 | * vchan_next_desc - peek at the next descriptor to be processed |
96 | * vc: virtual channel to obtain descriptor from | 110 | * vc: virtual channel to obtain descriptor from |
97 | * | 111 | * |