linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linaro.org>
To: dan.j.williams@intel.com, vkoul@kernel.org, eric.long@unisoc.com
Cc: broonie@kernel.org, baolin.wang@linaro.org,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RESEND PATCH 2/7] dmaengine: sprd: Get transfer residue depending on the transfer direction
Date: Tue,  6 Nov 2018 13:01:32 +0800	[thread overview]
Message-ID: <2968b6dce6864608b97391e5b86ee3c47e3fb8e6.1541480353.git.baolin.wang@linaro.org> (raw)
In-Reply-To: <cover.1541480353.git.baolin.wang@linaro.org>
In-Reply-To: <cover.1541480353.git.baolin.wang@linaro.org>

From: Eric Long <eric.long@spreadtrum.com>

Add one field to save the transfer direction for struct sprd_dma_desc,
which is used to get correct transfer residue depending on the transfer
direction.

[Baolin Wang adds one field to present the transfer direction]
Signed-off-by: Eric Long <eric.long@spreadtrum.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 drivers/dma/sprd-dma.c |   21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
index c226dc93..4f3587b 100644
--- a/drivers/dma/sprd-dma.c
+++ b/drivers/dma/sprd-dma.c
@@ -159,6 +159,7 @@ struct sprd_dma_chn_hw {
 struct sprd_dma_desc {
 	struct virt_dma_desc	vd;
 	struct sprd_dma_chn_hw	chn_hw;
+	enum dma_transfer_direction dir;
 };
 
 /* dma channel description */
@@ -331,6 +332,17 @@ static void sprd_dma_stop_and_disable(struct sprd_dma_chn *schan)
 	sprd_dma_disable_chn(schan);
 }
 
+static unsigned long sprd_dma_get_src_addr(struct sprd_dma_chn *schan)
+{
+	unsigned long addr, addr_high;
+
+	addr = readl(schan->chn_base + SPRD_DMA_CHN_SRC_ADDR);
+	addr_high = readl(schan->chn_base + SPRD_DMA_CHN_WARP_PTR) &
+		    SPRD_DMA_HIGH_ADDR_MASK;
+
+	return addr | (addr_high << SPRD_DMA_HIGH_ADDR_OFFSET);
+}
+
 static unsigned long sprd_dma_get_dst_addr(struct sprd_dma_chn *schan)
 {
 	unsigned long addr, addr_high;
@@ -534,7 +546,12 @@ static enum dma_status sprd_dma_tx_status(struct dma_chan *chan,
 		else
 			pos = 0;
 	} else if (schan->cur_desc && schan->cur_desc->vd.tx.cookie == cookie) {
-		pos = sprd_dma_get_dst_addr(schan);
+		struct sprd_dma_desc *sdesc = to_sprd_dma_desc(vd);
+
+		if (sdesc->dir == DMA_DEV_TO_MEM)
+			pos = sprd_dma_get_dst_addr(schan);
+		else
+			pos = sprd_dma_get_src_addr(schan);
 	} else {
 		pos = 0;
 	}
@@ -804,6 +821,8 @@ static int sprd_dma_fill_linklist_desc(struct dma_chan *chan,
 	if (!sdesc)
 		return NULL;
 
+	sdesc->dir = dir;
+
 	for_each_sg(sgl, sg, sglen, i) {
 		len = sg_dma_len(sg);
 
-- 
1.7.9.5


  parent reply	other threads:[~2018-11-06  5:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-06  5:01 [RESEND PATCH 0/7] Add some fixes and new feature for SPRD DMA Baolin Wang
2018-11-06  5:01 ` [RESEND PATCH 1/7] dmaengine: sprd: Remove direction usage from struct dma_slave_config Baolin Wang
2018-11-06  5:01 ` Baolin Wang [this message]
2018-11-06  5:01 ` [RESEND PATCH 3/7] dmaengine: sprd: Fix the last link-list configuration Baolin Wang
2018-11-06  5:01 ` [RESEND PATCH 4/7] dmaengine: sprd: Set cur_desc as NULL when free or terminate one dma channel Baolin Wang
2018-11-06  5:01 ` [RESEND PATCH 5/7] dmaengine: sprd: Support DMA link-list cyclic callback Baolin Wang
2018-11-06  5:01 ` [RESEND PATCH 6/7] dmaengine: sprd: Support DMA 2-stage transfer mode Baolin Wang
2018-11-06  5:01 ` [RESEND PATCH 7/7] dmaengine: sprd: Add me as one of the module authors Baolin Wang
2018-11-26  6:49 ` [RESEND PATCH 0/7] Add some fixes and new feature for SPRD DMA Baolin Wang
2018-12-05  8:57 ` Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2968b6dce6864608b97391e5b86ee3c47e3fb8e6.1541480353.git.baolin.wang@linaro.org \
    --to=baolin.wang@linaro.org \
    --cc=broonie@kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=eric.long@unisoc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).