aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>2018-09-29 13:17:57 -0400
committerVinod Koul <vkoul@kernel.org>2018-11-11 05:33:09 -0500
commit91b438286ef227b5a9148156896175c8e386c6b2 (patch)
tree50ea610233cbaf27343a015514b8761e50941489
parent651022382c7f8da46cb4872a545ee1da6d097d2a (diff)
dmaengine: xilinx_dma: Refactor axidma channel allocation
In axidma alloc_chan_resources merge BD and cyclic BD allocation. Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Vinod Koul <vkoul@kernel.org>
-rw-r--r--drivers/dma/xilinx/xilinx_dma.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
index c12442312595..06d1632ff1a2 100644
--- a/drivers/dma/xilinx/xilinx_dma.c
+++ b/drivers/dma/xilinx/xilinx_dma.c
@@ -887,6 +887,24 @@ static int xilinx_dma_alloc_chan_resources(struct dma_chan *dchan)
887 chan->id); 887 chan->id);
888 return -ENOMEM; 888 return -ENOMEM;
889 } 889 }
890 /*
891 * For cyclic DMA mode we need to program the tail Descriptor
892 * register with a value which is not a part of the BD chain
893 * so allocating a desc segment during channel allocation for
894 * programming tail descriptor.
895 */
896 chan->cyclic_seg_v = dma_zalloc_coherent(chan->dev,
897 sizeof(*chan->cyclic_seg_v),
898 &chan->cyclic_seg_p, GFP_KERNEL);
899 if (!chan->cyclic_seg_v) {
900 dev_err(chan->dev,
901 "unable to allocate desc segment for cyclic DMA\n");
902 dma_free_coherent(chan->dev, sizeof(*chan->seg_v) *
903 XILINX_DMA_NUM_DESCS, chan->seg_v,
904 chan->seg_p);
905 return -ENOMEM;
906 }
907 chan->cyclic_seg_v->phys = chan->cyclic_seg_p;
890 908
891 for (i = 0; i < XILINX_DMA_NUM_DESCS; i++) { 909 for (i = 0; i < XILINX_DMA_NUM_DESCS; i++) {
892 chan->seg_v[i].hw.next_desc = 910 chan->seg_v[i].hw.next_desc =
@@ -922,24 +940,6 @@ static int xilinx_dma_alloc_chan_resources(struct dma_chan *dchan)
922 return -ENOMEM; 940 return -ENOMEM;
923 } 941 }
924 942
925 if (chan->xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) {
926 /*
927 * For cyclic DMA mode we need to program the tail Descriptor
928 * register with a value which is not a part of the BD chain
929 * so allocating a desc segment during channel allocation for
930 * programming tail descriptor.
931 */
932 chan->cyclic_seg_v = dma_zalloc_coherent(chan->dev,
933 sizeof(*chan->cyclic_seg_v),
934 &chan->cyclic_seg_p, GFP_KERNEL);
935 if (!chan->cyclic_seg_v) {
936 dev_err(chan->dev,
937 "unable to allocate desc segment for cyclic DMA\n");
938 return -ENOMEM;
939 }
940 chan->cyclic_seg_v->phys = chan->cyclic_seg_p;
941 }
942
943 dma_cookie_init(dchan); 943 dma_cookie_init(dchan);
944 944
945 if (chan->xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) { 945 if (chan->xdev->dma_config->dmatype == XDMA_TYPE_AXIDMA) {