dmaengine: qcom: bam_dma: Fix completed descriptors count
authorSricharan R <sricharan@codeaurora.org>
Fri, 28 Jun 2019 12:09:46 +0000 (17:39 +0530)
committerVinod Koul <vkoul@kernel.org>
Fri, 5 Jul 2019 07:48:27 +0000 (13:18 +0530)
One space is left unused in circular FIFO to differentiate
'full' and 'empty' cases. So take that in to account while
counting for the descriptors completed.

Fixes the issue reported here,
https://lkml.org/lkml/2019/6/18/669

Cc: stable@vger.kernel.org
Reported-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/qcom/bam_dma.c

index 4b43844f6af53f57037a4ba32b2eaadb4f78784a..8e90a405939df4989d69d001efc803515ca1515a 100644 (file)
@@ -799,6 +799,9 @@ static u32 process_channel_irqs(struct bam_device *bdev)
                /* Number of bytes available to read */
                avail = CIRC_CNT(offset, bchan->head, MAX_DESCRIPTORS + 1);
 
+               if (offset < bchan->head)
+                       avail--;
+
                list_for_each_entry_safe(async_desc, tmp,
                                         &bchan->desc_list, desc_node) {
                        /* Not enough data to read */