Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine: sprd: Fix the DMA link-list configuration

For the Spreadtrum DMA link-list mode, when the DMA engine got a slave
hardware request, which will trigger the DMA engine to load the DMA
configuration from the link-list memory automatically. But before the
slave hardware request, the slave will get an incorrect residue due
to the first node used to trigger the link-list was configured as the
last source address and destination address.

Thus we should make sure the first node was configured the start source
address and destination address, which can fix this issue.

Fixes: 4ac695464763 ("dmaengine: sprd: Support DMA link-list mode")
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Link: https://lore.kernel.org/r/77868edb7aff9d5cb12ac3af8827ef2e244441a6.1567150471.git.baolin.wang@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Baolin Wang and committed by
Vinod Koul
689379c2 962411b0

+8 -2
+8 -2
drivers/dma/sprd-dma.c
··· 908 908 struct sprd_dma_chn *schan = to_sprd_dma_chan(chan); 909 909 struct dma_slave_config *slave_cfg = &schan->slave_cfg; 910 910 dma_addr_t src = 0, dst = 0; 911 + dma_addr_t start_src = 0, start_dst = 0; 911 912 struct sprd_dma_desc *sdesc; 912 913 struct scatterlist *sg; 913 914 u32 len = 0; ··· 955 954 dst = sg_dma_address(sg); 956 955 } 957 956 957 + if (!i) { 958 + start_src = src; 959 + start_dst = dst; 960 + } 961 + 958 962 /* 959 963 * The link-list mode needs at least 2 link-list 960 964 * configurations. If there is only one sg, it doesn't ··· 976 970 } 977 971 } 978 972 979 - ret = sprd_dma_fill_desc(chan, &sdesc->chn_hw, 0, 0, src, dst, len, 980 - dir, flags, slave_cfg); 973 + ret = sprd_dma_fill_desc(chan, &sdesc->chn_hw, 0, 0, start_src, 974 + start_dst, len, dir, flags, slave_cfg); 981 975 if (ret) { 982 976 kfree(sdesc); 983 977 return NULL;