LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v1] dma: imx-sdma: switch to dynamic context mode after script loaded
@ 2015-01-13  5:09 Robin Gong
  2015-01-20  7:16 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Robin Gong @ 2015-01-13  5:09 UTC (permalink / raw)
  To: vinod.koul, dan.j.williams; +Cc: s.hauer, dmaengine, linux-kernel

Below comments got from Page4724 of Reference Manual of i.mx6q:
http://cache.freescale.com/files/32bit/doc/ref_manual/IMX6DQRM.pdf

--"Static context mode should be used for the first channel called
after reset to ensure that the all context RAM for that channel is
initialized during the context SAVE phase when the channel is
done or yields. Subsequent calls to the same channel or
different channels may use any of the dynamic context modes.
This will ensure that all context locations for the bootload
channel are initialized, and prevent undefined values in context
RAM from being loaded during the context restore if the
channel is re-started later"

Unfortunately, the rule was broken by commit(5b28aa319bba96987316425a1131813d87cbab35)
.This patch just take them back.

Signed-off-by: Robin Gong <b38343@freescale.com>
---
 drivers/dma/imx-sdma.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index d0df198..510e463 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -1323,6 +1323,10 @@ static void sdma_load_firmware(const struct firmware *fw, void *context)
 	sdma_load_script(sdma, ram_code,
 			header->ram_code_size,
 			addr->ram_code_start_addr);
+
+	/* Set bits of CONFIG register with given context switching mode */
+	writel_relaxed(SDMA_H_CONFIG_CSM, sdma->regs + SDMA_H_CONFIG);
+
 	clk_disable(sdma->clk_ipg);
 	clk_disable(sdma->clk_ahb);
 
@@ -1401,9 +1405,6 @@ static int sdma_init(struct sdma_engine *sdma)
 
 	writel_relaxed(ccb_phys, sdma->regs + SDMA_H_C0PTR);
 
-	/* Set bits of CONFIG register with given context switching mode */
-	writel_relaxed(SDMA_H_CONFIG_CSM, sdma->regs + SDMA_H_CONFIG);
-
 	/* Initializes channel's priorities */
 	sdma_set_channel_priority(&sdma->channel[0], 7);
 
-- 
1.9.1


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

* Re: [PATCH v1] dma: imx-sdma: switch to dynamic context mode after script loaded
  2015-01-13  5:09 [PATCH v1] dma: imx-sdma: switch to dynamic context mode after script loaded Robin Gong
@ 2015-01-20  7:16 ` Sascha Hauer
  2015-01-22  3:32   ` Robin Gong
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2015-01-20  7:16 UTC (permalink / raw)
  To: Robin Gong; +Cc: vinod.koul, dan.j.williams, dmaengine, linux-kernel

On Tue, Jan 13, 2015 at 01:09:17PM +0800, Robin Gong wrote:
> Below comments got from Page4724 of Reference Manual of i.mx6q:
> http://cache.freescale.com/files/32bit/doc/ref_manual/IMX6DQRM.pdf
> 
> --"Static context mode should be used for the first channel called
> after reset to ensure that the all context RAM for that channel is
> initialized during the context SAVE phase when the channel is
> done or yields. Subsequent calls to the same channel or
> different channels may use any of the dynamic context modes.
> This will ensure that all context locations for the bootload
> channel are initialized, and prevent undefined values in context
> RAM from being loaded during the context restore if the
> channel is re-started later"
> 
> Unfortunately, the rule was broken by commit(5b28aa319bba96987316425a1131813d87cbab35)
> .This patch just take them back.
> 
> Signed-off-by: Robin Gong <b38343@freescale.com>
> ---
>  drivers/dma/imx-sdma.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
> index d0df198..510e463 100644
> --- a/drivers/dma/imx-sdma.c
> +++ b/drivers/dma/imx-sdma.c
> @@ -1323,6 +1323,10 @@ static void sdma_load_firmware(const struct firmware *fw, void *context)
>  	sdma_load_script(sdma, ram_code,
>  			header->ram_code_size,
>  			addr->ram_code_start_addr);
> +
> +	/* Set bits of CONFIG register with given context switching mode */
> +	writel_relaxed(SDMA_H_CONFIG_CSM, sdma->regs + SDMA_H_CONFIG);
> +

You move the CONFIG register initialization to a place which may never
be called. Look at the top of sdma_load_firmware:

	if (!fw) {
		dev_info(sdma->dev, "external firmware not found, using ROM firmware\n");
		/* In this case we just use the ROM firmware. */
		return;
	}

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* Re: [PATCH v1] dma: imx-sdma: switch to dynamic context mode after script loaded
  2015-01-20  7:16 ` Sascha Hauer
@ 2015-01-22  3:32   ` Robin Gong
  0 siblings, 0 replies; 3+ messages in thread
From: Robin Gong @ 2015-01-22  3:32 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: vinod.koul, dan.j.williams, dmaengine, linux-kernel

On Tue, Jan 20, 2015 at 08:16:14AM +0100, Sascha Hauer wrote:
> On Tue, Jan 13, 2015 at 01:09:17PM +0800, Robin Gong wrote:
> > Below comments got from Page4724 of Reference Manual of i.mx6q:
> > http://cache.freescale.com/files/32bit/doc/ref_manual/IMX6DQRM.pdf
> > 
> > --"Static context mode should be used for the first channel called
> > after reset to ensure that the all context RAM for that channel is
> > initialized during the context SAVE phase when the channel is
> > done or yields. Subsequent calls to the same channel or
> > different channels may use any of the dynamic context modes.
> > This will ensure that all context locations for the bootload
> > channel are initialized, and prevent undefined values in context
> > RAM from being loaded during the context restore if the
> > channel is re-started later"
> > 
> > Unfortunately, the rule was broken by commit(5b28aa319bba96987316425a1131813d87cbab35)
> > .This patch just take them back.
> > 
> > Signed-off-by: Robin Gong <b38343@freescale.com>
> > ---
> >  drivers/dma/imx-sdma.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
> > index d0df198..510e463 100644
> > --- a/drivers/dma/imx-sdma.c
> > +++ b/drivers/dma/imx-sdma.c
> > @@ -1323,6 +1323,10 @@ static void sdma_load_firmware(const struct firmware *fw, void *context)
> >  	sdma_load_script(sdma, ram_code,
> >  			header->ram_code_size,
> >  			addr->ram_code_start_addr);
> > +
> > +	/* Set bits of CONFIG register with given context switching mode */
> > +	writel_relaxed(SDMA_H_CONFIG_CSM, sdma->regs + SDMA_H_CONFIG);
> > +
> 
> You move the CONFIG register initialization to a place which may never
> be called. Look at the top of sdma_load_firmware:
> 
> 	if (!fw) {
> 		dev_info(sdma->dev, "external firmware not found, using ROM firmware\n");
> 		/* In this case we just use the ROM firmware. */
> 		return;
> 	}
> 
> Sascha
>
Yes. I'll move it into sdma_run_channel0.
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

end of thread, other threads:[~2015-01-22  3:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-13  5:09 [PATCH v1] dma: imx-sdma: switch to dynamic context mode after script loaded Robin Gong
2015-01-20  7:16 ` Sascha Hauer
2015-01-22  3:32   ` Robin Gong

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