Re: [PATCH] dw_dmac: apply default dma_mask if needed

2013-02-12 Thread Andy Shevchenko
On Tue, Feb 12, 2013 at 6:16 PM, Vinod Koul  wrote:
> On Tue, Jan 29, 2013 at 05:06:24PM +0200, Andy Shevchenko wrote:
>> In some cases we got the device without dma_mask configured. We have to apply
>> the default value to avoid crashes during memory mapping.
>>
> what was this generated against, it fails to apply for me.

I've tested this against linux-next. The problem apparently in the
patch which Greg submits earlier:
7331205a "dma: Convert to devm_ioremap_resource()". If you want I
could rebase it against your next branch. I thought you'd seen that
patch already.

>
>> Signed-off-by: Andy Shevchenko 
>> ---
>>  drivers/dma/dw_dmac.c |6 ++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
>> index e8d0679..a572a1e 100644
>> --- a/drivers/dma/dw_dmac.c
>> +++ b/drivers/dma/dw_dmac.c
>> @@ -1673,6 +1673,12 @@ static int dw_probe(struct platform_device *pdev)
>>   if (IS_ERR(regs))
>>   return PTR_ERR(regs);
>>
>> + /* Apply default dma_mask if needed */
>> + if (!pdev->dev.dma_mask) {
>> + pdev->dev.dma_mask = >dev.coherent_dma_mask;
>> + pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
>> + }
>> +
>>   dw_params = dma_read_byaddr(regs, DW_PARAMS);
>>   autocfg = dw_params >> DW_PARAMS_EN & 0x1;
>>
>> --
>> 1.7.10.4
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] dw_dmac: apply default dma_mask if needed

2013-02-12 Thread Vinod Koul
On Tue, Jan 29, 2013 at 05:06:24PM +0200, Andy Shevchenko wrote:
> In some cases we got the device without dma_mask configured. We have to apply
> the default value to avoid crashes during memory mapping.
> 
what was this generated against, it fails to apply for me.

> Signed-off-by: Andy Shevchenko 
> ---
>  drivers/dma/dw_dmac.c |6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
> index e8d0679..a572a1e 100644
> --- a/drivers/dma/dw_dmac.c
> +++ b/drivers/dma/dw_dmac.c
> @@ -1673,6 +1673,12 @@ static int dw_probe(struct platform_device *pdev)
>   if (IS_ERR(regs))
>   return PTR_ERR(regs);
>  
> + /* Apply default dma_mask if needed */
> + if (!pdev->dev.dma_mask) {
> + pdev->dev.dma_mask = >dev.coherent_dma_mask;
> + pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
> + }
> +
>   dw_params = dma_read_byaddr(regs, DW_PARAMS);
>   autocfg = dw_params >> DW_PARAMS_EN & 0x1;
>  
> -- 
> 1.7.10.4
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] dw_dmac: apply default dma_mask if needed

2013-02-12 Thread Vinod Koul
On Tue, Jan 29, 2013 at 05:06:24PM +0200, Andy Shevchenko wrote:
 In some cases we got the device without dma_mask configured. We have to apply
 the default value to avoid crashes during memory mapping.
 
what was this generated against, it fails to apply for me.

 Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
 ---
  drivers/dma/dw_dmac.c |6 ++
  1 file changed, 6 insertions(+)
 
 diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
 index e8d0679..a572a1e 100644
 --- a/drivers/dma/dw_dmac.c
 +++ b/drivers/dma/dw_dmac.c
 @@ -1673,6 +1673,12 @@ static int dw_probe(struct platform_device *pdev)
   if (IS_ERR(regs))
   return PTR_ERR(regs);
  
 + /* Apply default dma_mask if needed */
 + if (!pdev-dev.dma_mask) {
 + pdev-dev.dma_mask = pdev-dev.coherent_dma_mask;
 + pdev-dev.coherent_dma_mask = DMA_BIT_MASK(32);
 + }
 +
   dw_params = dma_read_byaddr(regs, DW_PARAMS);
   autocfg = dw_params  DW_PARAMS_EN  0x1;
  
 -- 
 1.7.10.4
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] dw_dmac: apply default dma_mask if needed

2013-02-12 Thread Andy Shevchenko
On Tue, Feb 12, 2013 at 6:16 PM, Vinod Koul vinod.k...@intel.com wrote:
 On Tue, Jan 29, 2013 at 05:06:24PM +0200, Andy Shevchenko wrote:
 In some cases we got the device without dma_mask configured. We have to apply
 the default value to avoid crashes during memory mapping.

 what was this generated against, it fails to apply for me.

I've tested this against linux-next. The problem apparently in the
patch which Greg submits earlier:
7331205a dma: Convert to devm_ioremap_resource(). If you want I
could rebase it against your next branch. I thought you'd seen that
patch already.


 Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
 ---
  drivers/dma/dw_dmac.c |6 ++
  1 file changed, 6 insertions(+)

 diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
 index e8d0679..a572a1e 100644
 --- a/drivers/dma/dw_dmac.c
 +++ b/drivers/dma/dw_dmac.c
 @@ -1673,6 +1673,12 @@ static int dw_probe(struct platform_device *pdev)
   if (IS_ERR(regs))
   return PTR_ERR(regs);

 + /* Apply default dma_mask if needed */
 + if (!pdev-dev.dma_mask) {
 + pdev-dev.dma_mask = pdev-dev.coherent_dma_mask;
 + pdev-dev.coherent_dma_mask = DMA_BIT_MASK(32);
 + }
 +
   dw_params = dma_read_byaddr(regs, DW_PARAMS);
   autocfg = dw_params  DW_PARAMS_EN  0x1;

 --
 1.7.10.4

 --
 To unsubscribe from this list: send the line unsubscribe linux-kernel in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] dw_dmac: apply default dma_mask if needed

2013-01-29 Thread Viresh Kumar
On 29 January 2013 20:36, Andy Shevchenko
 wrote:
> In some cases we got the device without dma_mask configured. We have to apply
> the default value to avoid crashes during memory mapping.
>
> Signed-off-by: Andy Shevchenko 
> ---
>  drivers/dma/dw_dmac.c |6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
> index e8d0679..a572a1e 100644
> --- a/drivers/dma/dw_dmac.c
> +++ b/drivers/dma/dw_dmac.c
> @@ -1673,6 +1673,12 @@ static int dw_probe(struct platform_device *pdev)
> if (IS_ERR(regs))
> return PTR_ERR(regs);
>
> +   /* Apply default dma_mask if needed */
> +   if (!pdev->dev.dma_mask) {
> +   pdev->dev.dma_mask = >dev.coherent_dma_mask;
> +   pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
> +   }
> +
> dw_params = dma_read_byaddr(regs, DW_PARAMS);
> autocfg = dw_params >> DW_PARAMS_EN & 0x1;

Acked-by: Viresh Kumar 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] dw_dmac: apply default dma_mask if needed

2013-01-29 Thread Arnd Bergmann
On Tuesday 29 January 2013, Viresh Kumar wrote:
> Adding Arnd in cc.
> 
> On 29 January 2013 20:36, Andy Shevchenko
>  wrote:
> > In some cases we got the device without dma_mask configured. We have to 
> > apply
> > the default value to avoid crashes during memory mapping.
> >
> > Signed-off-by: Andy Shevchenko 
> > ---
> >  drivers/dma/dw_dmac.c |6 ++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
> > index e8d0679..a572a1e 100644
> > --- a/drivers/dma/dw_dmac.c
> > +++ b/drivers/dma/dw_dmac.c
> > @@ -1673,6 +1673,12 @@ static int dw_probe(struct platform_device *pdev)
> > if (IS_ERR(regs))
> > return PTR_ERR(regs);
> >
> > +   /* Apply default dma_mask if needed */
> > +   if (!pdev->dev.dma_mask) {
> > +   pdev->dev.dma_mask = >dev.coherent_dma_mask;
> > +   pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
> > +   }
> > +
> 
> Hmm... Why is it required for a DMA controller? What kind of crash do you
> get?

A valid dma mask is required for any device that is passed into dma_map_*
and other dma-mapping.h interfaces. The question is more about is
responsible for setting up the mask. Traditionally we'd do that from the
platform definition in the place where the platform_device is created,
but this now comes from the device tree, which is a bit inconsistent
with the DMA masks at the moment.

We do set the dev.coherent_dma_mask to DMA_BIT_MASK(32) for all platform
devices instatiated from DT, but I cannot find the code that sets the
dma_mask for a platform_device. For an amba_device, we set both to
the same value. Maybe Grant can remember if the difference here is
intentional, or if the dma_mask is set up elsewhere for a platform_device
coming from DT.

> @Arnd: Is this change recommended?

For all I can tell, it cannot hurt to do it this way.

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] dw_dmac: apply default dma_mask if needed

2013-01-29 Thread Viresh Kumar
Adding Arnd in cc.

On 29 January 2013 20:36, Andy Shevchenko
 wrote:
> In some cases we got the device without dma_mask configured. We have to apply
> the default value to avoid crashes during memory mapping.
>
> Signed-off-by: Andy Shevchenko 
> ---
>  drivers/dma/dw_dmac.c |6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
> index e8d0679..a572a1e 100644
> --- a/drivers/dma/dw_dmac.c
> +++ b/drivers/dma/dw_dmac.c
> @@ -1673,6 +1673,12 @@ static int dw_probe(struct platform_device *pdev)
> if (IS_ERR(regs))
> return PTR_ERR(regs);
>
> +   /* Apply default dma_mask if needed */
> +   if (!pdev->dev.dma_mask) {
> +   pdev->dev.dma_mask = >dev.coherent_dma_mask;
> +   pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
> +   }
> +

Hmm... Why is it required for a DMA controller? What kind of crash do you
get?

@Arnd: Is this change recommended?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] dw_dmac: apply default dma_mask if needed

2013-01-29 Thread Viresh Kumar
Adding Arnd in cc.

On 29 January 2013 20:36, Andy Shevchenko
andriy.shevche...@linux.intel.com wrote:
 In some cases we got the device without dma_mask configured. We have to apply
 the default value to avoid crashes during memory mapping.

 Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
 ---
  drivers/dma/dw_dmac.c |6 ++
  1 file changed, 6 insertions(+)

 diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
 index e8d0679..a572a1e 100644
 --- a/drivers/dma/dw_dmac.c
 +++ b/drivers/dma/dw_dmac.c
 @@ -1673,6 +1673,12 @@ static int dw_probe(struct platform_device *pdev)
 if (IS_ERR(regs))
 return PTR_ERR(regs);

 +   /* Apply default dma_mask if needed */
 +   if (!pdev-dev.dma_mask) {
 +   pdev-dev.dma_mask = pdev-dev.coherent_dma_mask;
 +   pdev-dev.coherent_dma_mask = DMA_BIT_MASK(32);
 +   }
 +

Hmm... Why is it required for a DMA controller? What kind of crash do you
get?

@Arnd: Is this change recommended?
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] dw_dmac: apply default dma_mask if needed

2013-01-29 Thread Arnd Bergmann
On Tuesday 29 January 2013, Viresh Kumar wrote:
 Adding Arnd in cc.
 
 On 29 January 2013 20:36, Andy Shevchenko
 andriy.shevche...@linux.intel.com wrote:
  In some cases we got the device without dma_mask configured. We have to 
  apply
  the default value to avoid crashes during memory mapping.
 
  Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
  ---
   drivers/dma/dw_dmac.c |6 ++
   1 file changed, 6 insertions(+)
 
  diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
  index e8d0679..a572a1e 100644
  --- a/drivers/dma/dw_dmac.c
  +++ b/drivers/dma/dw_dmac.c
  @@ -1673,6 +1673,12 @@ static int dw_probe(struct platform_device *pdev)
  if (IS_ERR(regs))
  return PTR_ERR(regs);
 
  +   /* Apply default dma_mask if needed */
  +   if (!pdev-dev.dma_mask) {
  +   pdev-dev.dma_mask = pdev-dev.coherent_dma_mask;
  +   pdev-dev.coherent_dma_mask = DMA_BIT_MASK(32);
  +   }
  +
 
 Hmm... Why is it required for a DMA controller? What kind of crash do you
 get?

A valid dma mask is required for any device that is passed into dma_map_*
and other dma-mapping.h interfaces. The question is more about is
responsible for setting up the mask. Traditionally we'd do that from the
platform definition in the place where the platform_device is created,
but this now comes from the device tree, which is a bit inconsistent
with the DMA masks at the moment.

We do set the dev.coherent_dma_mask to DMA_BIT_MASK(32) for all platform
devices instatiated from DT, but I cannot find the code that sets the
dma_mask for a platform_device. For an amba_device, we set both to
the same value. Maybe Grant can remember if the difference here is
intentional, or if the dma_mask is set up elsewhere for a platform_device
coming from DT.

 @Arnd: Is this change recommended?

For all I can tell, it cannot hurt to do it this way.

Arnd
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] dw_dmac: apply default dma_mask if needed

2013-01-29 Thread Viresh Kumar
On 29 January 2013 20:36, Andy Shevchenko
andriy.shevche...@linux.intel.com wrote:
 In some cases we got the device without dma_mask configured. We have to apply
 the default value to avoid crashes during memory mapping.

 Signed-off-by: Andy Shevchenko andriy.shevche...@linux.intel.com
 ---
  drivers/dma/dw_dmac.c |6 ++
  1 file changed, 6 insertions(+)

 diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
 index e8d0679..a572a1e 100644
 --- a/drivers/dma/dw_dmac.c
 +++ b/drivers/dma/dw_dmac.c
 @@ -1673,6 +1673,12 @@ static int dw_probe(struct platform_device *pdev)
 if (IS_ERR(regs))
 return PTR_ERR(regs);

 +   /* Apply default dma_mask if needed */
 +   if (!pdev-dev.dma_mask) {
 +   pdev-dev.dma_mask = pdev-dev.coherent_dma_mask;
 +   pdev-dev.coherent_dma_mask = DMA_BIT_MASK(32);
 +   }
 +
 dw_params = dma_read_byaddr(regs, DW_PARAMS);
 autocfg = dw_params  DW_PARAMS_EN  0x1;

Acked-by: Viresh Kumar viresh.ku...@linaro.org
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/