diff mbox

[v2,2/2] dma/imx-sdma: add wmb before enable a channel

Message ID 1325428692-11473-3-git-send-email-richard.zhao@linaro.org
State Changes Requested
Headers show

Commit Message

Richard Zhao Jan. 1, 2012, 2:38 p.m. UTC
dma_alloc_coherent memory may be bufferable. We need to add
nececcary memory barrier.

Signed-off-by: Richard Zhao <richard.zhao@linaro.org>
---
 drivers/dma/imx-sdma.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Comments

Russell King - ARM Linux Jan. 3, 2012, 5:46 p.m. UTC | #1
On Sun, Jan 01, 2012 at 10:38:12PM +0800, Richard Zhao wrote:
> dma_alloc_coherent memory may be bufferable. We need to add
> nececcary memory barrier.
> 
> Signed-off-by: Richard Zhao <richard.zhao@linaro.org>
> ---
>  drivers/dma/imx-sdma.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
> index f8e87b5..9301bff 100644
> --- a/drivers/dma/imx-sdma.c
> +++ b/drivers/dma/imx-sdma.c
> @@ -394,6 +394,7 @@ static int sdma_config_ownership(struct sdma_channel *sdmac,
>  
>  static void sdma_enable_channel(struct sdma_engine *sdma, int channel)
>  {
> +	wmb();
>  	__raw_writel(1 << channel, sdma->regs + SDMA_H_START);

Use writel().  That's what it's there for:

#ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE
#define __iowmb()               wmb()
#endif
#define writel_relaxed(v,c)     ((void)__raw_writel((__force u32) \
                                        cpu_to_le32(v),__mem_pci(c)))
#define writel(v,c)             ({ __iowmb(); writel_relaxed(v,c); })
Richard Zhao Jan. 4, 2012, 2:31 a.m. UTC | #2
On Tue, Jan 03, 2012 at 05:46:39PM +0000, Russell King - ARM Linux wrote:
> On Sun, Jan 01, 2012 at 10:38:12PM +0800, Richard Zhao wrote:
> > dma_alloc_coherent memory may be bufferable. We need to add
> > nececcary memory barrier.
> > 
> > Signed-off-by: Richard Zhao <richard.zhao@linaro.org>
> > ---
> >  drivers/dma/imx-sdma.c |    1 +
> >  1 files changed, 1 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
> > index f8e87b5..9301bff 100644
> > --- a/drivers/dma/imx-sdma.c
> > +++ b/drivers/dma/imx-sdma.c
> > @@ -394,6 +394,7 @@ static int sdma_config_ownership(struct sdma_channel *sdmac,
> >  
> >  static void sdma_enable_channel(struct sdma_engine *sdma, int channel)
> >  {
> > +	wmb();
> >  	__raw_writel(1 << channel, sdma->regs + SDMA_H_START);
> 
> Use writel().  That's what it's there for:
> 
> #ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE
> #define __iowmb()               wmb()
> #endif
> #define writel_relaxed(v,c)     ((void)__raw_writel((__force u32) \
>                                         cpu_to_le32(v),__mem_pci(c)))
> #define writel(v,c)             ({ __iowmb(); writel_relaxed(v,c); })
Why does writel always call wmb? ioremap memory needs mb too?
Isn't it supposed to be when there's prior touch of dma memory? 

Thanks
Richard
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
Richard Zhao Jan. 5, 2012, 1:56 a.m. UTC | #3
Hi Sascha,

On Wed, Jan 04, 2012 at 10:31:58AM +0800, Richard Zhao wrote:
> On Tue, Jan 03, 2012 at 05:46:39PM +0000, Russell King - ARM Linux wrote:
> > On Sun, Jan 01, 2012 at 10:38:12PM +0800, Richard Zhao wrote:
> > > dma_alloc_coherent memory may be bufferable. We need to add
> > > nececcary memory barrier.
> > > 
> > > Signed-off-by: Richard Zhao <richard.zhao@linaro.org>
> > > ---
> > >  drivers/dma/imx-sdma.c |    1 +
> > >  1 files changed, 1 insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
> > > index f8e87b5..9301bff 100644
> > > --- a/drivers/dma/imx-sdma.c
> > > +++ b/drivers/dma/imx-sdma.c
> > > @@ -394,6 +394,7 @@ static int sdma_config_ownership(struct sdma_channel *sdmac,
> > >  
> > >  static void sdma_enable_channel(struct sdma_engine *sdma, int channel)
> > >  {
> > > +	wmb();
> > >  	__raw_writel(1 << channel, sdma->regs + SDMA_H_START);
> > 
> > Use writel().  That's what it's there for:
> > 
> > #ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE
> > #define __iowmb()               wmb()
> > #endif
> > #define writel_relaxed(v,c)     ((void)__raw_writel((__force u32) \
> >                                         cpu_to_le32(v),__mem_pci(c)))
> > #define writel(v,c)             ({ __iowmb(); writel_relaxed(v,c); })
> Why does writel always call wmb? ioremap memory needs mb too?
> Isn't it supposed to be when there's prior touch of dma memory? 
What do you think?

Thanks
Richard
> 
> Thanks
> Richard
> > 
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> > 
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
diff mbox

Patch

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index f8e87b5..9301bff 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -394,6 +394,7 @@  static int sdma_config_ownership(struct sdma_channel *sdmac,
 
 static void sdma_enable_channel(struct sdma_engine *sdma, int channel)
 {
+	wmb();
 	__raw_writel(1 << channel, sdma->regs + SDMA_H_START);
 }