dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] dmaengine: pl330: Make sure the debug is idle before doing DMAGO
@ 2020-06-04  1:36 Sugar Zhang
  2020-06-24  7:41 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: Sugar Zhang @ 2020-06-04  1:36 UTC (permalink / raw)
  To: Vinod Koul; +Cc: Sugar Zhang, Dan Williams, dmaengine, linux-kernel

According to the datasheet of pl330:

Example 2-1 Using DMAGO with the debug instruction registers

1. Create a program for the DMA channel
2. Store the program in a region of system memory
3. Poll the DBGSTATUS Register to ensure that the debug is idle
4. Write to the DBGINST0 Register
5. Write to the DBGINST1 Register
6. Write zero to the DBGCMD Register

so, we should make sure the debug is idle before step 4/5/6, not
only step 6. if not, there maybe a risk that fail to write DBGINST0/1.

Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
---

 drivers/dma/pl330.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 88b884c..6a158ee 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -885,6 +885,12 @@ static inline void _execute_DBGINSN(struct pl330_thread *thrd,
 	void __iomem *regs = thrd->dmac->base;
 	u32 val;
 
+	/* If timed out due to halted state-machine */
+	if (_until_dmac_idle(thrd)) {
+		dev_err(thrd->dmac->ddma.dev, "DMAC halted!\n");
+		return;
+	}
+
 	val = (insn[0] << 16) | (insn[1] << 24);
 	if (!as_manager) {
 		val |= (1 << 0);
@@ -895,12 +901,6 @@ static inline void _execute_DBGINSN(struct pl330_thread *thrd,
 	val = le32_to_cpu(*((__le32 *)&insn[2]));
 	writel(val, regs + DBGINST1);
 
-	/* If timed out due to halted state-machine */
-	if (_until_dmac_idle(thrd)) {
-		dev_err(thrd->dmac->ddma.dev, "DMAC halted!\n");
-		return;
-	}
-
 	/* Get going */
 	writel(0, regs + DBGCMD);
 }
-- 
2.7.4




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

* Re: [PATCH v1] dmaengine: pl330: Make sure the debug is idle before doing DMAGO
  2020-06-04  1:36 [PATCH v1] dmaengine: pl330: Make sure the debug is idle before doing DMAGO Sugar Zhang
@ 2020-06-24  7:41 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2020-06-24  7:41 UTC (permalink / raw)
  To: Sugar Zhang; +Cc: Dan Williams, dmaengine, linux-kernel

On 04-06-20, 09:36, Sugar Zhang wrote:
> According to the datasheet of pl330:
> 
> Example 2-1 Using DMAGO with the debug instruction registers
> 
> 1. Create a program for the DMA channel
> 2. Store the program in a region of system memory
> 3. Poll the DBGSTATUS Register to ensure that the debug is idle
> 4. Write to the DBGINST0 Register
> 5. Write to the DBGINST1 Register
> 6. Write zero to the DBGCMD Register
> 
> so, we should make sure the debug is idle before step 4/5/6, not
> only step 6. if not, there maybe a risk that fail to write DBGINST0/1.

Applied, thanks

> 
> Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
> ---
> 
>  drivers/dma/pl330.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
> index 88b884c..6a158ee 100644
> --- a/drivers/dma/pl330.c
> +++ b/drivers/dma/pl330.c
> @@ -885,6 +885,12 @@ static inline void _execute_DBGINSN(struct pl330_thread *thrd,
>  	void __iomem *regs = thrd->dmac->base;
>  	u32 val;
>  
> +	/* If timed out due to halted state-machine */
> +	if (_until_dmac_idle(thrd)) {
> +		dev_err(thrd->dmac->ddma.dev, "DMAC halted!\n");
> +		return;
> +	}
> +
>  	val = (insn[0] << 16) | (insn[1] << 24);
>  	if (!as_manager) {
>  		val |= (1 << 0);
> @@ -895,12 +901,6 @@ static inline void _execute_DBGINSN(struct pl330_thread *thrd,
>  	val = le32_to_cpu(*((__le32 *)&insn[2]));
>  	writel(val, regs + DBGINST1);
>  
> -	/* If timed out due to halted state-machine */
> -	if (_until_dmac_idle(thrd)) {
> -		dev_err(thrd->dmac->ddma.dev, "DMAC halted!\n");
> -		return;
> -	}
> -
>  	/* Get going */
>  	writel(0, regs + DBGCMD);
>  }
> -- 
> 2.7.4
> 
> 

-- 
~Vinod

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

end of thread, other threads:[~2020-06-24  7:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-04  1:36 [PATCH v1] dmaengine: pl330: Make sure the debug is idle before doing DMAGO Sugar Zhang
2020-06-24  7:41 ` Vinod Koul

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).