All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dirk Behme <dirk.behme@de.bosch.com>
To: linux-renesas-soc@vger.kernel.org
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org,
	geert+renesas@glider.be, niklas.soderlund+renesas@ragnatech.se,
	laurent.pinchart+renesas@ideasonboard.com,
	Achim.Dahlhoff@de.bosch.com, dirk.behme@de.bosch.com,
	yoshihiro.shimoda.uh@renesas.com, ylhuajnu@outlook.com,
	hiroyuki.yokoyama.vx@renesas.com,
	kuninori.morimoto.gx@renesas.com, stable@vger.kernel.org
Subject: [v3,1/2] dmaengine: sh: rcar-dmac: With cyclic DMA residue 0 is valid
Date: Fri, 12 Apr 2019 07:29:13 +0200	[thread overview]
Message-ID: <20190412052914.16006-1-dirk.behme@de.bosch.com> (raw)

Having a cyclic DMA, a residue 0 is not an indication of a completed
DMA. In case of cyclic DMA make sure that dma_set_residue() is called
and with this a residue of 0 is forwarded correctly to the caller.

Fixes: 3544d2878817 ("dmaengine: rcar-dmac: use result of updated get_residue in tx_status")
Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
Signed-off-by: Achim Dahlhoff <Achim.Dahlhoff@de.bosch.com>
Signed-off-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Yao Lihua <ylhuajnu@outlook.com>
Cc: <stable@vger.kernel.org> # v4.8+
---
Note: Patch done against mainline v5.0

Changes in v2: None

Changes in v3: Move reading rchan into the spin lock protection.

 drivers/dma/sh/rcar-dmac.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 2b4f25698169..54810ffd95e2 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -1368,6 +1368,7 @@ static enum dma_status rcar_dmac_tx_status(struct dma_chan *chan,
 	enum dma_status status;
 	unsigned long flags;
 	unsigned int residue;
+	bool cyclic;
 
 	status = dma_cookie_status(chan, cookie, txstate);
 	if (status == DMA_COMPLETE || !txstate)
@@ -1375,10 +1376,11 @@ static enum dma_status rcar_dmac_tx_status(struct dma_chan *chan,
 
 	spin_lock_irqsave(&rchan->lock, flags);
 	residue = rcar_dmac_chan_get_residue(rchan, cookie);
+	cyclic = rchan->desc.running ? rchan->desc.running->cyclic : false;
 	spin_unlock_irqrestore(&rchan->lock, flags);
 
 	/* if there's no residue, the cookie is complete */
-	if (!residue)
+	if (!residue && !cyclic)
 		return DMA_COMPLETE;
 
 	dma_set_residue(txstate, residue);

WARNING: multiple messages have this Message-ID (diff)
From: Dirk Behme <dirk.behme@de.bosch.com>
To: <linux-renesas-soc@vger.kernel.org>
Cc: <dmaengine@vger.kernel.org>, <vkoul@kernel.org>,
	<geert+renesas@glider.be>,
	<niklas.soderlund+renesas@ragnatech.se>,
	<laurent.pinchart+renesas@ideasonboard.com>,
	<Achim.Dahlhoff@de.bosch.com>, <dirk.behme@de.bosch.com>,
	<yoshihiro.shimoda.uh@renesas.com>, <ylhuajnu@outlook.com>,
	<hiroyuki.yokoyama.vx@renesas.com>,
	<kuninori.morimoto.gx@renesas.com>, <stable@vger.kernel.org>
Subject: [PATCH v3 1/2] dmaengine: sh: rcar-dmac: With cyclic DMA residue 0 is valid
Date: Fri, 12 Apr 2019 07:29:13 +0200	[thread overview]
Message-ID: <20190412052914.16006-1-dirk.behme@de.bosch.com> (raw)
Message-ID: <20190412052913.-nEhjuuVwfbAt7P9gc4igklrTnfujMZr43tk_XSk81c@z> (raw)

Having a cyclic DMA, a residue 0 is not an indication of a completed
DMA. In case of cyclic DMA make sure that dma_set_residue() is called
and with this a residue of 0 is forwarded correctly to the caller.

Fixes: 3544d2878817 ("dmaengine: rcar-dmac: use result of updated get_residue in tx_status")
Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
Signed-off-by: Achim Dahlhoff <Achim.Dahlhoff@de.bosch.com>
Signed-off-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Yao Lihua <ylhuajnu@outlook.com>
Cc: <stable@vger.kernel.org> # v4.8+
---
Note: Patch done against mainline v5.0

Changes in v2: None

Changes in v3: Move reading rchan into the spin lock protection.

 drivers/dma/sh/rcar-dmac.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 2b4f25698169..54810ffd95e2 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -1368,6 +1368,7 @@ static enum dma_status rcar_dmac_tx_status(struct dma_chan *chan,
 	enum dma_status status;
 	unsigned long flags;
 	unsigned int residue;
+	bool cyclic;
 
 	status = dma_cookie_status(chan, cookie, txstate);
 	if (status == DMA_COMPLETE || !txstate)
@@ -1375,10 +1376,11 @@ static enum dma_status rcar_dmac_tx_status(struct dma_chan *chan,
 
 	spin_lock_irqsave(&rchan->lock, flags);
 	residue = rcar_dmac_chan_get_residue(rchan, cookie);
+	cyclic = rchan->desc.running ? rchan->desc.running->cyclic : false;
 	spin_unlock_irqrestore(&rchan->lock, flags);
 
 	/* if there's no residue, the cookie is complete */
-	if (!residue)
+	if (!residue && !cyclic)
 		return DMA_COMPLETE;
 
 	dma_set_residue(txstate, residue);
-- 
2.20.0


             reply	other threads:[~2019-04-12  5:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-12  5:29 Dirk Behme [this message]
2019-04-12  5:29 ` [PATCH v3 1/2] dmaengine: sh: rcar-dmac: With cyclic DMA residue 0 is valid Dirk Behme
2019-04-12  5:29 [v3,2/2] dmaengine: sh: rcar-dmac: Fix glitch in dmaengine_tx_status Dirk Behme
2019-04-12  5:29 ` [PATCH v3 2/2] " Dirk Behme
2019-04-12  8:33 [v3,1/2] dmaengine: sh: rcar-dmac: With cyclic DMA residue 0 is valid Yoshihiro Shimoda
2019-04-12  8:33 ` [PATCH v3 1/2] " Yoshihiro Shimoda
2019-04-12  8:52 [v3,2/2] dmaengine: sh: rcar-dmac: Fix glitch in dmaengine_tx_status Yoshihiro Shimoda
2019-04-12  8:52 ` [PATCH v3 2/2] " Yoshihiro Shimoda
2019-04-12  9:54 [v3,1/2] dmaengine: sh: rcar-dmac: With cyclic DMA residue 0 is valid Laurent Pinchart
2019-04-12  9:54 ` [PATCH v3 1/2] " Laurent Pinchart
2019-04-23  5:15 [v3,1/2] " Vinod Koul
2019-04-23  5:15 ` [PATCH v3 1/2] " 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=20190412052914.16006-1-dirk.behme@de.bosch.com \
    --to=dirk.behme@de.bosch.com \
    --cc=Achim.Dahlhoff@de.bosch.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=hiroyuki.yokoyama.vx@renesas.com \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=stable@vger.kernel.org \
    --cc=vkoul@kernel.org \
    --cc=ylhuajnu@outlook.com \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.