linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd.bergmann@linaro.org>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Vinod Koul <vinod.koul@intel.com>,
	linux-kernel@vger.kernel.org,
	"spear-devel" <spear-devel@list.st.com>,
	Grant Likely <grant.likely@secretlab.ca>
Subject: Re: [PATCH] dw_dmac: apply default dma_mask if needed
Date: Tue, 29 Jan 2013 16:12:58 +0000	[thread overview]
Message-ID: <201301291612.58501.arnd.bergmann@linaro.org> (raw)
In-Reply-To: <CAKohpo=upCjze53v5STZJUz5OSrRqBU+mU3Q-C9BL18sXYAs5Q@mail.gmail.com>

On Tuesday 29 January 2013, Viresh Kumar wrote:
> Adding Arnd in cc.
> 
> On 29 January 2013 20:36, Andy Shevchenko
> <andriy.shevchenko@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.shevchenko@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

  reply	other threads:[~2013-01-29 16:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-29 15:06 [PATCH] dw_dmac: apply default dma_mask if needed Andy Shevchenko
2013-01-29 15:23 ` Viresh Kumar
2013-01-29 16:12   ` Arnd Bergmann [this message]
2013-01-30  2:06 ` Viresh Kumar
2013-02-12 16:16 ` Vinod Koul
2013-02-12 16:53   ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201301291612.58501.arnd.bergmann@linaro.org \
    --to=arnd.bergmann@linaro.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=spear-devel@list.st.com \
    --cc=vinod.koul@intel.com \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).