From patchwork Fri Jun 28 12:09:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sricharan Ramabadhran X-Patchwork-Id: 11022131 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 30B0C924 for ; Fri, 28 Jun 2019 12:10:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2428A287E5 for ; Fri, 28 Jun 2019 12:10:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 182F6287F2; Fri, 28 Jun 2019 12:10:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14BFA287E5 for ; Fri, 28 Jun 2019 12:10:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726781AbfF1MKM (ORCPT ); Fri, 28 Jun 2019 08:10:12 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:50168 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726564AbfF1MKM (ORCPT ); Fri, 28 Jun 2019 08:10:12 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 310D3606E1; Fri, 28 Jun 2019 12:10:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1561723811; bh=IM0ROSdcJWhLOg7FCXzXiT+dphADA/BQMxzLdqyE4gI=; h=From:To:Cc:Subject:Date:From; b=Ribzsnv2aF/9i/B7bXu+14xOkRG10YQkY/ldJhblqja/UFtmbf8PxWaFppHZ59Muu ATWN4CBESNwU/qixtNHpbm0mMNQgeOBrNIQNag/O8jGXvYq5XcXRnimbDN8mcanOI6 LDveRWrq/0h9TYl82ETex+srUu6BRznEy1+wfUCQ= Received: from srichara-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sricharan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id AB0066070D; Fri, 28 Jun 2019 12:10:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1561723810; bh=IM0ROSdcJWhLOg7FCXzXiT+dphADA/BQMxzLdqyE4gI=; h=From:To:Cc:Subject:Date:From; b=D3YzX8aS3Ume7ylmpcOIg+TFPBPZGvS0u0pfcfUXLozP0OADlZ8tV4oiMaTs3S/HU Na4/YK31FQW/aElURBQk5puXU5CP797RLEMb+5kHlf2f+EKnUnkb3+QkVyYazjT9Cn 0K+e05vjGcXa1ypvY9OUeapTSy/E/0LCds1QPcCY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org AB0066070D Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sricharan@codeaurora.org From: Sricharan R To: agross@kernel.org, david.brown@linaro.org, dan.j.williams@intel.com, vkoul@kernel.org, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, srinivas.kandagatla@linaro.org Cc: stable@vger.kernel.org, sricharan@codeaurora.org Subject: [PATCH] dmaengine: qcom: bam_dma: Fix completed descriptors count Date: Fri, 28 Jun 2019 17:39:46 +0530 Message-Id: <1561723786-22500-1-git-send-email-sricharan@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Sricharan R Tested-by: Srinivas Kandagatla --- drivers/dma/qcom/bam_dma.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c index 4b43844..8e90a40 100644 --- a/drivers/dma/qcom/bam_dma.c +++ b/drivers/dma/qcom/bam_dma.c @@ -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 */