diff options
author | Chanho Park <chanho61.park@samsung.com> | 2013-08-09 07:11:33 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2013-08-13 08:09:45 -0400 |
commit | 52a9d179109c50b1a5077cc2a653295fa131f0d0 (patch) | |
tree | b439173b06832025c8ee80471c90e0832336f359 /drivers/dma/pl330.c | |
parent | 2a76689bcaecf35391e6ddc8a00c09c79d6d5857 (diff) |
dma: pl330: split off common code to give back descriptors
This patch adds __pl330_giveback_descs which give back descriptors when fails
allocating descriptors. It requires to eliminate duplication for
pl330_prep_dma_sg which will be added later.
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
Acked-by : Jassi Brar <jassisinghbrar@gmail.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma/pl330.c')
-rw-r--r-- | drivers/dma/pl330.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index d8c10449fb42..facd23afaceb 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c | |||
@@ -2814,6 +2814,28 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, | |||
2814 | return &desc->txd; | 2814 | return &desc->txd; |
2815 | } | 2815 | } |
2816 | 2816 | ||
2817 | static void __pl330_giveback_desc(struct dma_pl330_dmac *pdmac, | ||
2818 | struct dma_pl330_desc *first) | ||
2819 | { | ||
2820 | unsigned long flags; | ||
2821 | struct dma_pl330_desc *desc; | ||
2822 | |||
2823 | if (!first) | ||
2824 | return; | ||
2825 | |||
2826 | spin_lock_irqsave(&pdmac->pool_lock, flags); | ||
2827 | |||
2828 | while (!list_empty(&first->node)) { | ||
2829 | desc = list_entry(first->node.next, | ||
2830 | struct dma_pl330_desc, node); | ||
2831 | list_move_tail(&desc->node, &pdmac->desc_pool); | ||
2832 | } | ||
2833 | |||
2834 | list_move_tail(&first->node, &pdmac->desc_pool); | ||
2835 | |||
2836 | spin_unlock_irqrestore(&pdmac->pool_lock, flags); | ||
2837 | } | ||
2838 | |||
2817 | static struct dma_async_tx_descriptor * | 2839 | static struct dma_async_tx_descriptor * |
2818 | pl330_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, | 2840 | pl330_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, |
2819 | unsigned int sg_len, enum dma_transfer_direction direction, | 2841 | unsigned int sg_len, enum dma_transfer_direction direction, |
@@ -2822,7 +2844,6 @@ pl330_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, | |||
2822 | struct dma_pl330_desc *first, *desc = NULL; | 2844 | struct dma_pl330_desc *first, *desc = NULL; |
2823 | struct dma_pl330_chan *pch = to_pchan(chan); | 2845 | struct dma_pl330_chan *pch = to_pchan(chan); |
2824 | struct scatterlist *sg; | 2846 | struct scatterlist *sg; |
2825 | unsigned long flags; | ||
2826 | int i; | 2847 | int i; |
2827 | dma_addr_t addr; | 2848 | dma_addr_t addr; |
2828 | 2849 | ||
@@ -2842,20 +2863,7 @@ pl330_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, | |||
2842 | dev_err(pch->dmac->pif.dev, | 2863 | dev_err(pch->dmac->pif.dev, |
2843 | "%s:%d Unable to fetch desc\n", | 2864 | "%s:%d Unable to fetch desc\n", |
2844 | __func__, __LINE__); | 2865 | __func__, __LINE__); |
2845 | if (!first) | 2866 | __pl330_giveback_desc(pdmac, first); |
2846 | return NULL; | ||
2847 | |||
2848 | spin_lock_irqsave(&pdmac->pool_lock, flags); | ||
2849 | |||
2850 | while (!list_empty(&first->node)) { | ||
2851 | desc = list_entry(first->node.next, | ||
2852 | struct dma_pl330_desc, node); | ||
2853 | list_move_tail(&desc->node, &pdmac->desc_pool); | ||
2854 | } | ||
2855 | |||
2856 | list_move_tail(&first->node, &pdmac->desc_pool); | ||
2857 | |||
2858 | spin_unlock_irqrestore(&pdmac->pool_lock, flags); | ||
2859 | 2867 | ||
2860 | return NULL; | 2868 | return NULL; |
2861 | } | 2869 | } |