All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] dma: sh: rcar-dmac: Add dma_pause operation
@ 2018-07-02  9:21 Yoshihiro Shimoda
  2018-07-09 17:25 ` Vinod
  2018-07-10 15:21 ` Vinod
  0 siblings, 2 replies; 8+ messages in thread
From: Yoshihiro Shimoda @ 2018-07-02  9:21 UTC (permalink / raw)
  To: vinod.koul; +Cc: dmaengine, linux-renesas-soc, Yoshihiro Shimoda

This patch set is based on the lasest slave-dma / next branch.

This issue can be reproduced by the following commands on r8a7795
Salvator-XS with the fixed patch [1] and Windows Teraterm :) :
 # stty 921600
 (Change Teraterm baud rate)
 # cat > rx.txt
 (Send 5MiB file by Teraterm.)
 # cmp <somewhere the 5MiB file> rx.txt
 output "differ: byte NNNNN, line MMM"

[1] https://patchwork.kernel.org/patch/10500775/

Yoshihiro Shimoda (2):
  dma: sh: rcar-dmac: add a new function to clear CHCR.DE with barrier
  dma: sh: rcar-dmac: Add dma_pause operation

 drivers/dma/sh/rcar-dmac.c | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

-- 
1.9.1

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

* [1/2] dma: sh: rcar-dmac: add a new function to clear CHCR.DE with barrier
  2018-07-02  9:21 [PATCH 0/2] dma: sh: rcar-dmac: Add dma_pause operation Yoshihiro Shimoda
@ 2018-07-02  9:21 ` Yoshihiro Shimoda
  2018-07-10 15:21 ` Vinod
  1 sibling, 0 replies; 8+ messages in thread
From: Yoshihiro Shimoda @ 2018-07-02  9:21 UTC (permalink / raw)
  To: vinod.koul; +Cc: dmaengine, linux-renesas-soc, Yoshihiro Shimoda

This patch adds a new function rcar_dmac_clear_chcr_de() to simplify
adding pause function later.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/dma/sh/rcar-dmac.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 279c930..afd8c7b 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -762,18 +762,25 @@ static void rcar_dmac_chcr_de_barrier(struct rcar_dmac_chan *chan)
 	dev_err(chan->chan.device->dev, "CHCR DE check error\n");
 }
 
-static void rcar_dmac_sync_tcr(struct rcar_dmac_chan *chan)
+static void rcar_dmac_clear_chcr_de(struct rcar_dmac_chan *chan)
 {
 	u32 chcr = rcar_dmac_chan_read(chan, RCAR_DMACHCR);
 
-	if (!(chcr & RCAR_DMACHCR_DE))
-		return;
-
 	/* set DE=0 and flush remaining data */
 	rcar_dmac_chan_write(chan, RCAR_DMACHCR, (chcr & ~RCAR_DMACHCR_DE));
 
 	/* make sure all remaining data was flushed */
 	rcar_dmac_chcr_de_barrier(chan);
+}
+
+static void rcar_dmac_sync_tcr(struct rcar_dmac_chan *chan)
+{
+	u32 chcr = rcar_dmac_chan_read(chan, RCAR_DMACHCR);
+
+	if (!(chcr & RCAR_DMACHCR_DE))
+		return;
+
+	rcar_dmac_clear_chcr_de(chan);
 
 	/* back DE */
 	rcar_dmac_chan_write(chan, RCAR_DMACHCR, chcr);

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

* [PATCH 1/2] dma: sh: rcar-dmac: add a new function to clear CHCR.DE with barrier
@ 2018-07-02  9:21 ` Yoshihiro Shimoda
  0 siblings, 0 replies; 8+ messages in thread
From: Yoshihiro Shimoda @ 2018-07-02  9:21 UTC (permalink / raw)
  To: vinod.koul; +Cc: dmaengine, linux-renesas-soc, Yoshihiro Shimoda

This patch adds a new function rcar_dmac_clear_chcr_de() to simplify
adding pause function later.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/dma/sh/rcar-dmac.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 279c930..afd8c7b 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -762,18 +762,25 @@ static void rcar_dmac_chcr_de_barrier(struct rcar_dmac_chan *chan)
 	dev_err(chan->chan.device->dev, "CHCR DE check error\n");
 }
 
-static void rcar_dmac_sync_tcr(struct rcar_dmac_chan *chan)
+static void rcar_dmac_clear_chcr_de(struct rcar_dmac_chan *chan)
 {
 	u32 chcr = rcar_dmac_chan_read(chan, RCAR_DMACHCR);
 
-	if (!(chcr & RCAR_DMACHCR_DE))
-		return;
-
 	/* set DE=0 and flush remaining data */
 	rcar_dmac_chan_write(chan, RCAR_DMACHCR, (chcr & ~RCAR_DMACHCR_DE));
 
 	/* make sure all remaining data was flushed */
 	rcar_dmac_chcr_de_barrier(chan);
+}
+
+static void rcar_dmac_sync_tcr(struct rcar_dmac_chan *chan)
+{
+	u32 chcr = rcar_dmac_chan_read(chan, RCAR_DMACHCR);
+
+	if (!(chcr & RCAR_DMACHCR_DE))
+		return;
+
+	rcar_dmac_clear_chcr_de(chan);
 
 	/* back DE */
 	rcar_dmac_chan_write(chan, RCAR_DMACHCR, chcr);
-- 
1.9.1

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

* [2/2] dma: sh: rcar-dmac: Add dma_pause operation
  2018-07-02  9:21 [PATCH 0/2] dma: sh: rcar-dmac: Add dma_pause operation Yoshihiro Shimoda
@ 2018-07-02  9:21 ` Yoshihiro Shimoda
  2018-07-10 15:21 ` Vinod
  1 sibling, 0 replies; 8+ messages in thread
From: Yoshihiro Shimoda @ 2018-07-02  9:21 UTC (permalink / raw)
  To: vinod.koul; +Cc: dmaengine, linux-renesas-soc, Yoshihiro Shimoda

This patch adds dma_pause operation. This patch is based on
Muhammad Hamza Farooq's patch.

After this patch applied, an issue that the sh-sci driver with
high baud rate might cause data lost disappeared because the DMAC
is possible to transmit between [1] and [2] below, and then
the residue of [1] is not true:

In rx_timer_fn() of the sh-sci.c:
	dmaengine_pause();
	...
	dmaengine_tx_status();		/* [1] */
	...
	dmaengine_terminate_all()	/* [2] */

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/dma/sh/rcar-dmac.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index afd8c7b..285967b 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -836,6 +836,17 @@ static void rcar_dmac_stop_all_chan(struct rcar_dmac *dmac)
 	}
 }
 
+static int rcar_dmac_chan_pause(struct dma_chan *chan)
+{
+	unsigned long flags;
+	struct rcar_dmac_chan *rchan = to_rcar_dmac_chan(chan);
+
+	spin_lock_irqsave(&rchan->lock, flags);
+	rcar_dmac_clear_chcr_de(rchan);
+	spin_unlock_irqrestore(&rchan->lock, flags);
+
+	return 0;
+}
 
 /* -----------------------------------------------------------------------------
  * Descriptors preparation
@@ -1858,6 +1869,7 @@ static int rcar_dmac_probe(struct platform_device *pdev)
 	engine->device_prep_slave_sg		= rcar_dmac_prep_slave_sg;
 	engine->device_prep_dma_cyclic		= rcar_dmac_prep_dma_cyclic;
 	engine->device_config			= rcar_dmac_device_config;
+	engine->device_pause			= rcar_dmac_chan_pause;
 	engine->device_terminate_all		= rcar_dmac_chan_terminate_all;
 	engine->device_tx_status		= rcar_dmac_tx_status;
 	engine->device_issue_pending		= rcar_dmac_issue_pending;

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

* [PATCH 2/2] dma: sh: rcar-dmac: Add dma_pause operation
@ 2018-07-02  9:21 ` Yoshihiro Shimoda
  0 siblings, 0 replies; 8+ messages in thread
From: Yoshihiro Shimoda @ 2018-07-02  9:21 UTC (permalink / raw)
  To: vinod.koul; +Cc: dmaengine, linux-renesas-soc, Yoshihiro Shimoda

This patch adds dma_pause operation. This patch is based on
Muhammad Hamza Farooq's patch.

After this patch applied, an issue that the sh-sci driver with
high baud rate might cause data lost disappeared because the DMAC
is possible to transmit between [1] and [2] below, and then
the residue of [1] is not true:

In rx_timer_fn() of the sh-sci.c:
	dmaengine_pause();
	...
	dmaengine_tx_status();		/* [1] */
	...
	dmaengine_terminate_all()	/* [2] */

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/dma/sh/rcar-dmac.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index afd8c7b..285967b 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -836,6 +836,17 @@ static void rcar_dmac_stop_all_chan(struct rcar_dmac *dmac)
 	}
 }
 
+static int rcar_dmac_chan_pause(struct dma_chan *chan)
+{
+	unsigned long flags;
+	struct rcar_dmac_chan *rchan = to_rcar_dmac_chan(chan);
+
+	spin_lock_irqsave(&rchan->lock, flags);
+	rcar_dmac_clear_chcr_de(rchan);
+	spin_unlock_irqrestore(&rchan->lock, flags);
+
+	return 0;
+}
 
 /* -----------------------------------------------------------------------------
  * Descriptors preparation
@@ -1858,6 +1869,7 @@ static int rcar_dmac_probe(struct platform_device *pdev)
 	engine->device_prep_slave_sg		= rcar_dmac_prep_slave_sg;
 	engine->device_prep_dma_cyclic		= rcar_dmac_prep_dma_cyclic;
 	engine->device_config			= rcar_dmac_device_config;
+	engine->device_pause			= rcar_dmac_chan_pause;
 	engine->device_terminate_all		= rcar_dmac_chan_terminate_all;
 	engine->device_tx_status		= rcar_dmac_tx_status;
 	engine->device_issue_pending		= rcar_dmac_issue_pending;
-- 
1.9.1

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

* Re: [PATCH 0/2] dma: sh: rcar-dmac: Add dma_pause operation
  2018-07-02  9:21 [PATCH 0/2] dma: sh: rcar-dmac: Add dma_pause operation Yoshihiro Shimoda
@ 2018-07-09 17:25 ` Vinod
  2018-07-10 15:21 ` Vinod
  1 sibling, 0 replies; 8+ messages in thread
From: Vinod @ 2018-07-09 17:25 UTC (permalink / raw)
  To: Geert Uytterhoeven, Kuninori Morimoto
  Cc: Yoshihiro Shimoda, dmaengine, linux-renesas-soc

On 02-07-18, 18:21, Yoshihiro Shimoda wrote:
> This patch set is based on the lasest slave-dma / next branch.
> 
> This issue can be reproduced by the following commands on r8a7795
> Salvator-XS with the fixed patch [1] and Windows Teraterm :) :
>  # stty 921600
>  (Change Teraterm baud rate)
>  # cat > rx.txt
>  (Send 5MiB file by Teraterm.)
>  # cmp <somewhere the 5MiB file> rx.txt
>  output "differ: byte NNNNN, line MMM"

Looks okay to me, Acks/tested-by..?

> 
> [1] https://patchwork.kernel.org/patch/10500775/
> 
> Yoshihiro Shimoda (2):
>   dma: sh: rcar-dmac: add a new function to clear CHCR.DE with barrier
>   dma: sh: rcar-dmac: Add dma_pause operation
> 
>  drivers/dma/sh/rcar-dmac.c | 27 +++++++++++++++++++++++----
>  1 file changed, 23 insertions(+), 4 deletions(-)
> 
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe dmaengine" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
~Vinod

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

* Re: [PATCH 0/2] dma: sh: rcar-dmac: Add dma_pause operation
  2018-07-02  9:21 [PATCH 0/2] dma: sh: rcar-dmac: Add dma_pause operation Yoshihiro Shimoda
  2018-07-09 17:25 ` Vinod
@ 2018-07-10 15:21 ` Vinod
  2018-07-11  2:12   ` Yoshihiro Shimoda
  1 sibling, 1 reply; 8+ messages in thread
From: Vinod @ 2018-07-10 15:21 UTC (permalink / raw)
  To: Yoshihiro Shimoda; +Cc: dmaengine, linux-renesas-soc

On 02-07-18, 18:21, Yoshihiro Shimoda wrote:
> This patch set is based on the lasest slave-dma / next branch.
> 
> This issue can be reproduced by the following commands on r8a7795
> Salvator-XS with the fixed patch [1] and Windows Teraterm :) :
>  # stty 921600
>  (Change Teraterm baud rate)
>  # cat > rx.txt
>  (Send 5MiB file by Teraterm.)
>  # cmp <somewhere the 5MiB file> rx.txt
>  output "differ: byte NNNNN, line MMM"

This fails to apply for me. Please rebase. Also please fix the subsystem
name

-- 
~Vinod

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

* RE: [PATCH 0/2] dma: sh: rcar-dmac: Add dma_pause operation
  2018-07-10 15:21 ` Vinod
@ 2018-07-11  2:12   ` Yoshihiro Shimoda
  0 siblings, 0 replies; 8+ messages in thread
From: Yoshihiro Shimoda @ 2018-07-11  2:12 UTC (permalink / raw)
  To: Vinod; +Cc: dmaengine, linux-renesas-soc

Hi Vinod,

> From: Vinod, Sent: Wednesday, July 11, 2018 12:22 AM
> 
> On 02-07-18, 18:21, Yoshihiro Shimoda wrote:
> > This patch set is based on the lasest slave-dma / next branch.
> >
> > This issue can be reproduced by the following commands on r8a7795
> > Salvator-XS with the fixed patch [1] and Windows Teraterm :) :
> >  # stty 921600
> >  (Change Teraterm baud rate)
> >  # cat > rx.txt
> >  (Send 5MiB file by Teraterm.)
> >  # cmp <somewhere the 5MiB file> rx.txt
> >  output "differ: byte NNNNN, line MMM"
> 
> This fails to apply for me. Please rebase. Also please fix the subsystem
> name

I'm sorry for the trouble. I submitted v2 patch.

Best regards,
Yoshihiro Shimoda

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

end of thread, other threads:[~2018-07-11  2:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-02  9:21 [PATCH 0/2] dma: sh: rcar-dmac: Add dma_pause operation Yoshihiro Shimoda
2018-07-09 17:25 ` Vinod
2018-07-10 15:21 ` Vinod
2018-07-11  2:12   ` Yoshihiro Shimoda
2018-07-02  9:21 [1/2] dma: sh: rcar-dmac: add a new function to clear CHCR.DE with barrier Yoshihiro Shimoda
2018-07-02  9:21 ` [PATCH 1/2] " Yoshihiro Shimoda
2018-07-02  9:21 [2/2] dma: sh: rcar-dmac: Add dma_pause operation Yoshihiro Shimoda
2018-07-02  9:21 ` [PATCH 2/2] " Yoshihiro Shimoda

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.