All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Residue patches for rcar-dmac from renesas-drivers
@ 2016-06-15 11:13 Niklas Söderlund
  2016-06-15 11:13 ` [PATCH 1/4] dma: rcar-dma: use result of updated get_residue in tx_status Niklas Söderlund
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Niklas Söderlund @ 2016-06-15 11:13 UTC (permalink / raw)
  To: dmaengine, linux-renesas-soc
  Cc: vinod.koul, geert+renesas, laurent.pinchart+renesas, mfarooq,
	Niklas Söderlund

Hi all,

I have looked over the DMA residue branches in renesas-drivers tree
(topic/rcar-dmac-hamza-v3 and topic/rcar-dmac-residue-v1) hoping to 
bring them to upstream. The original author for the bulk of the patches 
Hamza Farooq have not shown any activity since autumn 2015.

In this cover letter I talk about all the patches in the above branches 
but for obvious reasons only patches I think should be forwarded to 
upstream are included in the series. All patches are based ontop of 
v4.7-rc1 and are tested on Koelsch using Geerts sertest tool to generate 
DMA traffic. The highest baud I could get to work at was 921600 bps.  
>From reading the original mail threads my conclusion is that this is 
good enough since all errors reported by Hamza Farooq where related to 
the serial sh-sci driver.

* Patches from topic/rcar-dmac-hamza-v3

- dma: rcar-dma: add wait after stopping dma engine
    In a perfect world one should check that RCAR_DMACHCR_DE is read 
    back as 0 after it have been cleared. The documentation clearly 
    states that one should do so.

    In the real world the worst case time for this register to be 
    cleared as Morimoto-san checked with HW is 700us. Laurent later 
    pointed out this is too long to busy loop over since this is done
    from both interrupt context and user context with a spinlock hold.

    Also in the real world the rcar-dmac driver WARN_ON_ONCE() that 
    RCAR_DMACHCR_DE is not set before it attempts to start an transferee 
    in rcar_dmac_chan_start_xfer(). So if this ever becomes a problem we 
    will know about it. At least I have never seen this warning while 
    using DMA. Whit this in mind I have not tried to implement a fix for 
    this and I think the original patch can be dropped.

- dma: rcar-dma: Added dma_pause operation to rcar_dma driver
    This patch adds support for device pause operation, but not the 
    resume operation. As pointed out in the original mail thread the 
    pausing must not destroy any already started transaction which it do 
    in its current form according to its author.

    Since the feature is incomplete and the use case never documented I 
    propose we drop this patch and if we can find the use case create a 
    separate task to add pause/resume functionality to the driver later.

- dma: rcar-dma: check if complete DMA packet received but not processed
    This patch is already addressed by Laruent in the original maling 
    thread:

    "I don't think this will work. In particular rcar_dmac_tx_status() 
    can be called with a cookie corresponding to a transfer not yet 
    scheduled. A pending transfer complete interrupt doesn't mean that 
    that cookie is complete.

    Furthermore I'm not sure this will really improve performances. The 
    dma_cookie_status() call below just compares cookie values, I don't 
    expect it to be much slower than a register read."

    I can see no reason to disagree with Laruent here and I propose this 
    patch is dropped.

- dma: rcar-dma: use result of updated get_residue in tx_status
    Patch is IMHO good but needs a explanation in commit message to 
    address the questions raised in the original mail thread. I have 
    added en explanation and included the original patch.

- dma: rcar-dma: warn if transfer cannot start as TE = 1
    Patch is a bit oddly implemented and uses new functionality from 
    patch 'dma: rcar-dma: add wait after stopping dma engine' above. I 
    do however think the patch have merit. One should make sure 
    according to the documentation that RCAR_DMACHCR_TE is not set 
    before starting a transfer. I have reworked the check and proposed a 
    different solution.

- dma: rcar-dma: Fixed active descriptor initializing
    Patch is clearly a bugfix and looks good. Laurent had a good comment 
    in the original mail thread about how it can be made differently by 
    reworking rcar_dmac_free_chan_resources() to call 
    rcar_dmac_chan_reinit() which would correctly set 
    rchan->desc.running to NULL.

    I have tried to implement this but failed. In my attempts to 
    implement Laurents proposal which I thought would be trivial the 
    kernel locks-up after a while with 'rcu_sched self-detected stall on 
    CPU'. And I'm not smart enough to figure out why so I have kept the 
    original patch so the bug fix part can be merged since that in 
    itself is good.

* Patch from topic/rcar-dmac-residue-v1

- dmaengine: rcar-dmac: Fix residue reporting for pending descriptors
    Patch is good AFIK. There where one report on the maling list by 
    Hamza Farooq that state he saw lots of warnings coming from the 
    WARN() introduced in this patch. I have run lots of testes using 
    Geers nice sertest tool and have not once seen the warning once. The 
    patch is included in this series.

Laurent Pinchart (1):
  dmaengine: rcar-dmac: Fix residue reporting for pending descriptors

Muhammad Hamza Farooq (2):
  dma: rcar-dma: use result of updated get_residue in tx_status
  dma: rcar-dma: Fixed active descriptor initializing

Niklas Söderlund (1):
  dmaengine: rcar-dmac: warn if transfer cannot start as TE = 1

 drivers/dma/sh/rcar-dmac.c | 40 +++++++++++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)

-- 
2.8.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/4] dma: rcar-dma: use result of updated get_residue in tx_status
  2016-06-15 11:13 [PATCH 0/4] Residue patches for rcar-dmac from renesas-drivers Niklas Söderlund
@ 2016-06-15 11:13 ` Niklas Söderlund
  2016-06-15 22:19   ` Laurent Pinchart
  2016-06-15 11:13 ` [PATCH 2/4] dmaengine: rcar-dmac: warn if transfer cannot start as TE = 1 Niklas Söderlund
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Niklas Söderlund @ 2016-06-15 11:13 UTC (permalink / raw)
  To: dmaengine, linux-renesas-soc
  Cc: vinod.koul, geert+renesas, laurent.pinchart+renesas, mfarooq,
	Niklas Söderlund

From: Muhammad Hamza Farooq <mfarooq@visteon.com>

The hardware might have complete the transfer but the interrupt handler
might not have had a chance to run. If rcar_dmac_chan_get_residue()
which reads HW registers finds that there is no residue return
DMA_COMPLETE.

Signed-off-by: Muhammad Hamza Farooq <mfarooq@visteon.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
[Niklas: add explanation in commit message]
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/dma/sh/rcar-dmac.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index dfb1792..791a064 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -1202,6 +1202,10 @@ static enum dma_status rcar_dmac_tx_status(struct dma_chan *chan,
 	residue = rcar_dmac_chan_get_residue(rchan, cookie);
 	spin_unlock_irqrestore(&rchan->lock, flags);
 
+	/* if there's no residue, the cookie is complete */
+	if (!residue)
+		return DMA_COMPLETE;
+
 	dma_set_residue(txstate, residue);
 
 	return status;
-- 
2.8.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/4] dmaengine: rcar-dmac: warn if transfer cannot start as TE = 1
  2016-06-15 11:13 [PATCH 0/4] Residue patches for rcar-dmac from renesas-drivers Niklas Söderlund
  2016-06-15 11:13 ` [PATCH 1/4] dma: rcar-dma: use result of updated get_residue in tx_status Niklas Söderlund
@ 2016-06-15 11:13 ` Niklas Söderlund
  2016-06-15 22:20   ` Laurent Pinchart
  2016-06-15 11:13 ` [PATCH 3/4] dma: rcar-dma: Fixed active descriptor initializing Niklas Söderlund
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Niklas Söderlund @ 2016-06-15 11:13 UTC (permalink / raw)
  To: dmaengine, linux-renesas-soc
  Cc: vinod.koul, geert+renesas, laurent.pinchart+renesas, mfarooq,
	Niklas Söderlund

The documentation states one should make sure both DE and TE are cleared
before starting a transaction. This patch extends the current warning to
look at both DE and TE.

Based on previous work from Muhammad Hamza Farooq.

Suggested-by: Muhammad Hamza Farooq <mfarooq@visteon.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/dma/sh/rcar-dmac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 791a064..7f26576 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -311,7 +311,7 @@ static bool rcar_dmac_chan_is_busy(struct rcar_dmac_chan *chan)
 {
 	u32 chcr = rcar_dmac_chan_read(chan, RCAR_DMACHCR);
 
-	return (chcr & (RCAR_DMACHCR_DE | RCAR_DMACHCR_TE)) == RCAR_DMACHCR_DE;
+	return !!(chcr & (RCAR_DMACHCR_DE | RCAR_DMACHCR_TE));
 }
 
 static void rcar_dmac_chan_start_xfer(struct rcar_dmac_chan *chan)
-- 
2.8.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] dma: rcar-dma: Fixed active descriptor initializing
  2016-06-15 11:13 [PATCH 0/4] Residue patches for rcar-dmac from renesas-drivers Niklas Söderlund
  2016-06-15 11:13 ` [PATCH 1/4] dma: rcar-dma: use result of updated get_residue in tx_status Niklas Söderlund
  2016-06-15 11:13 ` [PATCH 2/4] dmaengine: rcar-dmac: warn if transfer cannot start as TE = 1 Niklas Söderlund
@ 2016-06-15 11:13 ` Niklas Söderlund
  2016-06-15 22:30   ` Laurent Pinchart
  2016-06-15 11:13 ` [PATCH 4/4] dmaengine: rcar-dmac: Fix residue reporting for pending descriptors Niklas Söderlund
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Niklas Söderlund @ 2016-06-15 11:13 UTC (permalink / raw)
  To: dmaengine, linux-renesas-soc
  Cc: vinod.koul, geert+renesas, laurent.pinchart+renesas, mfarooq,
	Niklas Söderlund

From: Muhammad Hamza Farooq <mfarooq@visteon.com>

Running descriptor pointer is set to NULL upon freeing resources. Other-
wise, rcar_dmac_issue_pending might not start new transfers

Signed-off-by: Muhammad Hamza Farooq <mfarooq@visteon.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/dma/sh/rcar-dmac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 7f26576..59951fb 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -990,6 +990,8 @@ static void rcar_dmac_free_chan_resources(struct dma_chan *chan)
 	list_splice_init(&rchan->desc.done, &list);
 	list_splice_init(&rchan->desc.wait, &list);
 
+	rchan->desc.running = NULL;
+
 	list_for_each_entry(desc, &list, node)
 		rcar_dmac_realloc_hwdesc(rchan, desc, 0);
 
-- 
2.8.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/4] dmaengine: rcar-dmac: Fix residue reporting for pending descriptors
  2016-06-15 11:13 [PATCH 0/4] Residue patches for rcar-dmac from renesas-drivers Niklas Söderlund
                   ` (2 preceding siblings ...)
  2016-06-15 11:13 ` [PATCH 3/4] dma: rcar-dma: Fixed active descriptor initializing Niklas Söderlund
@ 2016-06-15 11:13 ` Niklas Söderlund
  2016-06-15 22:26   ` Laurent Pinchart
  2016-06-15 13:45 ` [PATCH 0/4] Residue patches for rcar-dmac from renesas-drivers Ramesh Shanmugasundaram
  2016-06-28 14:36 ` Vinod Koul
  5 siblings, 1 reply; 11+ messages in thread
From: Niklas Söderlund @ 2016-06-15 11:13 UTC (permalink / raw)
  To: dmaengine, linux-renesas-soc
  Cc: vinod.koul, geert+renesas, laurent.pinchart+renesas, mfarooq,
	Niklas Söderlund

From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Cookies corresponding to pending transfers have a residue value equal to
the full size of the corresponding descriptor. The driver miscomputes
that and uses the size of the active descriptor instead. Fix it.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
[geert: Also check desc.active list]
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/dma/sh/rcar-dmac.c | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 59951fb..86aef28 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -1145,19 +1145,47 @@ static unsigned int rcar_dmac_chan_get_residue(struct rcar_dmac_chan *chan,
 	struct rcar_dmac_desc *desc = chan->desc.running;
 	struct rcar_dmac_xfer_chunk *running = NULL;
 	struct rcar_dmac_xfer_chunk *chunk;
+	enum dma_status status;
 	unsigned int residue = 0;
 	unsigned int dptr = 0;
 
 	if (!desc)
 		return 0;
 
+
+	/*
+	 * If the cookie corresponds to a descriptor that has been completed
+	 * there is no residue. The same check has already been performed by the
+	 * caller but without holding the channel lock, so the descriptor could
+	 * now be complete.
+	 */
+	status = dma_cookie_status(&chan->chan, cookie, NULL);
+	if (status == DMA_COMPLETE)
+		return 0;
+
 	/*
 	 * If the cookie doesn't correspond to the currently running transfer
 	 * then the descriptor hasn't been processed yet, and the residue is
 	 * equal to the full descriptor size.
 	 */
-	if (cookie != desc->async_tx.cookie)
-		return desc->size;
+	if (cookie != desc->async_tx.cookie) {
+		list_for_each_entry(desc, &chan->desc.pending, node) {
+			if (cookie == desc->async_tx.cookie)
+				return desc->size;
+		}
+		list_for_each_entry(desc, &chan->desc.active, node) {
+			if (cookie == desc->async_tx.cookie)
+				return desc->size;
+		}
+
+		/*
+		 * No descriptor found for the cookie, there's thus no residue.
+		 * This shouldn't happen if the calling driver passes a correct
+		 * cookie value.
+		 */
+		WARN(1, "No descriptor for cookie!");
+		return 0;
+	}
 
 	/*
 	 * In descriptor mode the descriptor running pointer is not maintained
-- 
2.8.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* RE: [PATCH 0/4] Residue patches for rcar-dmac from renesas-drivers
  2016-06-15 11:13 [PATCH 0/4] Residue patches for rcar-dmac from renesas-drivers Niklas Söderlund
                   ` (3 preceding siblings ...)
  2016-06-15 11:13 ` [PATCH 4/4] dmaengine: rcar-dmac: Fix residue reporting for pending descriptors Niklas Söderlund
@ 2016-06-15 13:45 ` Ramesh Shanmugasundaram
  2016-06-28 14:36 ` Vinod Koul
  5 siblings, 0 replies; 11+ messages in thread
From: Ramesh Shanmugasundaram @ 2016-06-15 13:45 UTC (permalink / raw)
  To: Niklas Söderlund, dmaengine, linux-renesas-soc
  Cc: vinod.koul, geert+renesas, laurent.pinchart+renesas, mfarooq

Hi Niklas,

Thanks for the explanation.

> Subject: [PATCH 0/4] Residue patches for rcar-dmac from renesas-drivers
> 
> Hi all,
> 
> I have looked over the DMA residue branches in renesas-drivers tree
> (topic/rcar-dmac-hamza-v3 and topic/rcar-dmac-residue-v1) hoping to bring
> them to upstream. The original author for the bulk of the patches Hamza
> Farooq have not shown any activity since autumn 2015.
> 
> In this cover letter I talk about all the patches in the above branches
> but for obvious reasons only patches I think should be forwarded to
> upstream are included in the series. All patches are based ontop of
> v4.7-rc1 and are tested on Koelsch using Geerts sertest tool to generate
> DMA traffic. The highest baud I could get to work at was 921600 bps.
> From reading the original mail threads my conclusion is that this is good
> enough since all errors reported by Hamza Farooq where related to the
> serial sh-sci driver.
> 
> * Patches from topic/rcar-dmac-hamza-v3
> 
> - dma: rcar-dma: add wait after stopping dma engine
>     In a perfect world one should check that RCAR_DMACHCR_DE is read
>     back as 0 after it have been cleared. The documentation clearly
>     states that one should do so.
> 
>     In the real world the worst case time for this register to be
>     cleared as Morimoto-san checked with HW is 700us. Laurent later
>     pointed out this is too long to busy loop over since this is done
>     from both interrupt context and user context with a spinlock hold.
> 
>     Also in the real world the rcar-dmac driver WARN_ON_ONCE() that
>     RCAR_DMACHCR_DE is not set before it attempts to start an transferee
>     in rcar_dmac_chan_start_xfer(). So if this ever becomes a problem we
>     will know about it. At least I have never seen this warning while
>     using DMA. Whit this in mind I have not tried to implement a fix for
>     this and I think the original patch can be dropped.

As you mentioned, we cannot busy loop for longer but I think this patch was still useful with a check & WARN_ON print when it fails. It tries to comes close to the dmaengine_terminate_sync api description & it can add to the rcar_dmac_chan_start_xfer() check you already implemented.

I hit this case once when I used four SYS-DMAC channels in parallel with DRIF doing cyclic DMA under full load & ethernet traffic (r8a7795 SoC).

---<snip>---
[  375.108441] WARNING: CPU: 3 PID: 2074 at /home/ramesh/tmp/renesas-drivers-2/renesas-drivers/drivers/dma/sh/rcar-dmac.c:773 rcar_dmac_chan_halt+0xa4/0xd4
[  375.122083] Modules linked in: rcar_drif

[  375.127512] CPU: 3 PID: 2074 Comm: drif-capture-es Not tainted 4.6.0-rc1+ #21
[  375.134641] Hardware name: Renesas Salvator-X board based on r8a7795 (DT)
[  375.141424] task: ffffffc039320c80 ti: ffffffc038b7c000 task.ti: ffffffc038b7c000
[  375.148903] PC is at rcar_dmac_chan_halt+0xa4/0xd4
[  375.153689] LR is at rcar_dmac_chan_halt+0x8c/0xd4
[  375.158474] pc : [<ffffff8008471194>] lr : [<ffffff800847117c>] pstate: 600001c5
[  375.165862] sp : ffffffc038b7fcd0
[  375.169169] x29: ffffffc038b7fcd0 x28: ffffffc038b7c000 
[  375.174489] x27: ffffff80088ac000 x26: 000000000000001d 
[  375.179809] x25: ffffffc0371d4018 x24: 0000000000000000 
[  375.185127] x23: 0000000000000000 x22: ffffff8008b533d8 
[  375.190446] x21: ffffffc038f72118 x20: ffffff8008e551b0 
[  375.195765] x19: 0000000000000000 x18: 0000000000000001 
[  375.201084] x17: 0000007f8c4b5400 x16: ffffff8008215900 
[  375.206402] x15: 0000007f8c3f9c94 x14: 0000007f8c56e000 
[  375.211720] x13: 0000007f8c408828 x12: ffffffffffffffff 
[  375.217039] x11: 0000007fd7967560 x10: 0000000000000870 
[  375.222357] x9 : ffffffc038b7c000 x8 : ffffffc039321550 
[  375.227676] x7 : 0000000000000001 x6 : ffffffc038f720f8 
[  375.232994] x5 : ffffffc0381fa010 x4 : ffffffc0381fafd8 
[  375.238312] x3 : 0000000000000000 x2 : ffffff8008b53000 
[  375.243630] x1 : 000000000000000c x0 : 0000000000000000 

[  375.250433] ---[ end trace df725ea508513372 ]---
---<snip>---

Thanks,
Ramesh

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] dma: rcar-dma: use result of updated get_residue in tx_status
  2016-06-15 11:13 ` [PATCH 1/4] dma: rcar-dma: use result of updated get_residue in tx_status Niklas Söderlund
@ 2016-06-15 22:19   ` Laurent Pinchart
  0 siblings, 0 replies; 11+ messages in thread
From: Laurent Pinchart @ 2016-06-15 22:19 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: dmaengine, linux-renesas-soc, vinod.koul, geert+renesas,
	laurent.pinchart+renesas, mfarooq

Hi Niklas,

Thank you for the patch.

On Wednesday 15 Jun 2016 13:13:05 Niklas S�derlund wrote:
> From: Muhammad Hamza Farooq <mfarooq@visteon.com>
> 
> The hardware might have complete the transfer but the interrupt handler
> might not have had a chance to run. If rcar_dmac_chan_get_residue()
> which reads HW registers finds that there is no residue return
> DMA_COMPLETE.
> 
> Signed-off-by: Muhammad Hamza Farooq <mfarooq@visteon.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> [Niklas: add explanation in commit message]
> Signed-off-by: Niklas S�derlund <niklas.soderlund+renesas@ragnatech.se>

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/dma/sh/rcar-dmac.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
> index dfb1792..791a064 100644
> --- a/drivers/dma/sh/rcar-dmac.c
> +++ b/drivers/dma/sh/rcar-dmac.c
> @@ -1202,6 +1202,10 @@ static enum dma_status rcar_dmac_tx_status(struct
> dma_chan *chan, residue = rcar_dmac_chan_get_residue(rchan, cookie);
>  	spin_unlock_irqrestore(&rchan->lock, flags);
> 
> +	/* if there's no residue, the cookie is complete */
> +	if (!residue)
> +		return DMA_COMPLETE;
> +
>  	dma_set_residue(txstate, residue);
> 
>  	return status;

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] dmaengine: rcar-dmac: warn if transfer cannot start as TE = 1
  2016-06-15 11:13 ` [PATCH 2/4] dmaengine: rcar-dmac: warn if transfer cannot start as TE = 1 Niklas Söderlund
@ 2016-06-15 22:20   ` Laurent Pinchart
  0 siblings, 0 replies; 11+ messages in thread
From: Laurent Pinchart @ 2016-06-15 22:20 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: dmaengine, linux-renesas-soc, vinod.koul, geert+renesas,
	laurent.pinchart+renesas, mfarooq

Hi Niklas,

Thank you for the patch.

On Wednesday 15 Jun 2016 13:13:06 Niklas S�derlund wrote:
> The documentation states one should make sure both DE and TE are cleared
> before starting a transaction. This patch extends the current warning to
> look at both DE and TE.
> 
> Based on previous work from Muhammad Hamza Farooq.
> 
> Suggested-by: Muhammad Hamza Farooq <mfarooq@visteon.com>
> Signed-off-by: Niklas S�derlund <niklas.soderlund+renesas@ragnatech.se>

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/dma/sh/rcar-dmac.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
> index 791a064..7f26576 100644
> --- a/drivers/dma/sh/rcar-dmac.c
> +++ b/drivers/dma/sh/rcar-dmac.c
> @@ -311,7 +311,7 @@ static bool rcar_dmac_chan_is_busy(struct rcar_dmac_chan
> *chan) {
>  	u32 chcr = rcar_dmac_chan_read(chan, RCAR_DMACHCR);
> 
> -	return (chcr & (RCAR_DMACHCR_DE | RCAR_DMACHCR_TE)) == RCAR_DMACHCR_DE;
> +	return !!(chcr & (RCAR_DMACHCR_DE | RCAR_DMACHCR_TE));
>  }
> 
>  static void rcar_dmac_chan_start_xfer(struct rcar_dmac_chan *chan)

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/4] dmaengine: rcar-dmac: Fix residue reporting for pending descriptors
  2016-06-15 11:13 ` [PATCH 4/4] dmaengine: rcar-dmac: Fix residue reporting for pending descriptors Niklas Söderlund
@ 2016-06-15 22:26   ` Laurent Pinchart
  0 siblings, 0 replies; 11+ messages in thread
From: Laurent Pinchart @ 2016-06-15 22:26 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: dmaengine, linux-renesas-soc, vinod.koul, geert+renesas,
	laurent.pinchart+renesas, mfarooq

Hi Niklas,

Thank you for the patch.

On Wednesday 15 Jun 2016 13:13:08 Niklas S�derlund wrote:
> From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> 
> Cookies corresponding to pending transfers have a residue value equal to
> the full size of the corresponding descriptor. The driver miscomputes
> that and uses the size of the active descriptor instead. Fix it.
> 
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> [geert: Also check desc.active list]
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Niklas S�derlund <niklas.soderlund+renesas@ragnatech.se>
> ---
>  drivers/dma/sh/rcar-dmac.c | 32 ++++++++++++++++++++++++++++++--
>  1 file changed, 30 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
> index 59951fb..86aef28 100644
> --- a/drivers/dma/sh/rcar-dmac.c
> +++ b/drivers/dma/sh/rcar-dmac.c
> @@ -1145,19 +1145,47 @@ static unsigned int
> rcar_dmac_chan_get_residue(struct rcar_dmac_chan *chan, struct
> rcar_dmac_desc *desc = chan->desc.running;
>  	struct rcar_dmac_xfer_chunk *running = NULL;
>  	struct rcar_dmac_xfer_chunk *chunk;
> +	enum dma_status status;
>  	unsigned int residue = 0;
>  	unsigned int dptr = 0;
> 
>  	if (!desc)
>  		return 0;
> 
> +

One blank line is enough.

Apart from that your change to my patch looks good, thank you for fixing it.

> +	/*
> +	 * If the cookie corresponds to a descriptor that has been completed
> +	 * there is no residue. The same check has already been performed by the
> +	 * caller but without holding the channel lock, so the descriptor could
> +	 * now be complete.
> +	 */
> +	status = dma_cookie_status(&chan->chan, cookie, NULL);
> +	if (status == DMA_COMPLETE)
> +		return 0;
> +
>  	/*
>  	 * If the cookie doesn't correspond to the currently running transfer
>  	 * then the descriptor hasn't been processed yet, and the residue is
>  	 * equal to the full descriptor size.
>  	 */
> -	if (cookie != desc->async_tx.cookie)
> -		return desc->size;
> +	if (cookie != desc->async_tx.cookie) {
> +		list_for_each_entry(desc, &chan->desc.pending, node) {
> +			if (cookie == desc->async_tx.cookie)
> +				return desc->size;
> +		}
> +		list_for_each_entry(desc, &chan->desc.active, node) {
> +			if (cookie == desc->async_tx.cookie)
> +				return desc->size;
> +		}
> +
> +		/*
> +		 * No descriptor found for the cookie, there's thus no residue.
> +		 * This shouldn't happen if the calling driver passes a correct
> +		 * cookie value.
> +		 */
> +		WARN(1, "No descriptor for cookie!");
> +		return 0;
> +	}
> 
>  	/*
>  	 * In descriptor mode the descriptor running pointer is not maintained

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] dma: rcar-dma: Fixed active descriptor initializing
  2016-06-15 11:13 ` [PATCH 3/4] dma: rcar-dma: Fixed active descriptor initializing Niklas Söderlund
@ 2016-06-15 22:30   ` Laurent Pinchart
  0 siblings, 0 replies; 11+ messages in thread
From: Laurent Pinchart @ 2016-06-15 22:30 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: dmaengine, linux-renesas-soc, vinod.koul, geert+renesas,
	laurent.pinchart+renesas, mfarooq

Hi Niklas,

Thank you for the patch.

On Wednesday 15 Jun 2016 13:13:07 Niklas S�derlund wrote:
> From: Muhammad Hamza Farooq <mfarooq@visteon.com>
> 
> Running descriptor pointer is set to NULL upon freeing resources. Other-
> wise, rcar_dmac_issue_pending might not start new transfers
> 
> Signed-off-by: Muhammad Hamza Farooq <mfarooq@visteon.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Niklas S�derlund <niklas.soderlund+renesas@ragnatech.se>

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/dma/sh/rcar-dmac.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
> index 7f26576..59951fb 100644
> --- a/drivers/dma/sh/rcar-dmac.c
> +++ b/drivers/dma/sh/rcar-dmac.c
> @@ -990,6 +990,8 @@ static void rcar_dmac_free_chan_resources(struct
> dma_chan *chan) list_splice_init(&rchan->desc.done, &list);
>  	list_splice_init(&rchan->desc.wait, &list);
> 
> +	rchan->desc.running = NULL;
> +
>  	list_for_each_entry(desc, &list, node)
>  		rcar_dmac_realloc_hwdesc(rchan, desc, 0);

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/4] Residue patches for rcar-dmac from renesas-drivers
  2016-06-15 11:13 [PATCH 0/4] Residue patches for rcar-dmac from renesas-drivers Niklas Söderlund
                   ` (4 preceding siblings ...)
  2016-06-15 13:45 ` [PATCH 0/4] Residue patches for rcar-dmac from renesas-drivers Ramesh Shanmugasundaram
@ 2016-06-28 14:36 ` Vinod Koul
  5 siblings, 0 replies; 11+ messages in thread
From: Vinod Koul @ 2016-06-28 14:36 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: dmaengine, linux-renesas-soc, geert+renesas,
	laurent.pinchart+renesas, mfarooq

On Wed, Jun 15, 2016 at 01:13:04PM +0200, Niklas S�derlund wrote:
> Hi all,
> 
> Laurent Pinchart (1):
>   dmaengine: rcar-dmac: Fix residue reporting for pending descriptors
> 
> Muhammad Hamza Farooq (2):
>   dma: rcar-dma: use result of updated get_residue in tx_status
>   dma: rcar-dma: Fixed active descriptor initializing
> 
> Niklas S�derlund (1):
>   dmaengine: rcar-dmac: warn if transfer cannot start as TE = 1

At least maintain consistency in patch title, 2 are dma and two dmaengine.
Correct one is latter..

> 
>  drivers/dma/sh/rcar-dmac.c | 40 +++++++++++++++++++++++++++++++++++++---
>  1 file changed, 37 insertions(+), 3 deletions(-)
> 
> -- 
> 2.8.3
> 

-- 
~Vinod

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-06-28 14:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-15 11:13 [PATCH 0/4] Residue patches for rcar-dmac from renesas-drivers Niklas Söderlund
2016-06-15 11:13 ` [PATCH 1/4] dma: rcar-dma: use result of updated get_residue in tx_status Niklas Söderlund
2016-06-15 22:19   ` Laurent Pinchart
2016-06-15 11:13 ` [PATCH 2/4] dmaengine: rcar-dmac: warn if transfer cannot start as TE = 1 Niklas Söderlund
2016-06-15 22:20   ` Laurent Pinchart
2016-06-15 11:13 ` [PATCH 3/4] dma: rcar-dma: Fixed active descriptor initializing Niklas Söderlund
2016-06-15 22:30   ` Laurent Pinchart
2016-06-15 11:13 ` [PATCH 4/4] dmaengine: rcar-dmac: Fix residue reporting for pending descriptors Niklas Söderlund
2016-06-15 22:26   ` Laurent Pinchart
2016-06-15 13:45 ` [PATCH 0/4] Residue patches for rcar-dmac from renesas-drivers Ramesh Shanmugasundaram
2016-06-28 14:36 ` Vinod Koul

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.