aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2016-03-18 08:26:33 -0400
committerVinod Koul <vinod.koul@intel.com>2016-04-04 12:41:43 -0400
commita197f3c7d48c0c1f45076ea47533a76ba9b1a959 (patch)
tree15a03b790467c8d417e5bfe6714d686b0122d1c9
parent080edf75d337d35faa6fc3df99342b10d2848d16 (diff)
dmaengine: hsu: correct residue calculation of active descriptor
The commit f0579c8ceaf1 ("dmaengine: hsu: speed up residue calculation") speeded up calculation of the queued descriptor but broke the initial residue value for active descriptor. In accordance with documentation the hardware descriptor is updated each time DMA transfered some bytes. It means we have to calculate a sum of lengths of non-submitted hardware descriptors and whatever current values in the hardware. Do this straightforward. Fixes: f0579c8ceaf1 ("dmaengine: hsu: speed up residue calculation") Cc: stable@vger.kernel.org Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-rw-r--r--drivers/dma/hsu/hsu.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/dma/hsu/hsu.c b/drivers/dma/hsu/hsu.c
index c7643e022578..b3b212146620 100644
--- a/drivers/dma/hsu/hsu.c
+++ b/drivers/dma/hsu/hsu.c
@@ -254,10 +254,13 @@ static void hsu_dma_issue_pending(struct dma_chan *chan)
254static size_t hsu_dma_active_desc_size(struct hsu_dma_chan *hsuc) 254static size_t hsu_dma_active_desc_size(struct hsu_dma_chan *hsuc)
255{ 255{
256 struct hsu_dma_desc *desc = hsuc->desc; 256 struct hsu_dma_desc *desc = hsuc->desc;
257 size_t bytes = desc->length; 257 size_t bytes = 0;
258 int i; 258 int i;
259 259
260 i = desc->active % HSU_DMA_CHAN_NR_DESC; 260 for (i = desc->active; i < desc->nents; i++)
261 bytes += desc->sg[i].len;
262
263 i = HSU_DMA_CHAN_NR_DESC - 1;
261 do { 264 do {
262 bytes += hsu_chan_readl(hsuc, HSU_CH_DxTSR(i)); 265 bytes += hsu_chan_readl(hsuc, HSU_CH_DxTSR(i));
263 } while (--i >= 0); 266 } while (--i >= 0);