linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Paul Mackerras <paulus@samba.org>,
	PowerPC email list <linuxppc-dev@lists.ozlabs.org>,
	Li Zhong <zhong@linux.vnet.ibm.com>
Subject: Re: [RFC PATCH powerpc] Fix a dma_mask issue of vio
Date: Thu, 21 Nov 2013 11:22:27 +1100	[thread overview]
Message-ID: <1384993347.26969.124.camel@pasglop> (raw)
In-Reply-To: <20131121000819.GU16735@n2100.arm.linux.org.uk>

On Thu, 2013-11-21 at 00:08 +0000, Russell King - ARM Linux wrote:
> On Thu, Nov 21, 2013 at 11:01:42AM +1100, Benjamin Herrenschmidt wrote:
> > On Wed, 2013-11-20 at 23:23 +0000, Russell King - ARM Linux wrote:
> > > Li Zong's patch works around the issue of a failing dma_set_mask(),
> > > but as I've already said elsewhere, the real fix is to get whatever
> > > created the struct device to initialise the dev->dma_mask with a
> > > bus default.
> > > 
> > > Using dma_coerce_xxx() merely makes the problem "go away" papering
> > > over the issue - it's fine to do it this way, but someone should still
> > > fix the broken code creating these devices...
> > 
> > Ok, they are created by the vio bus core, so it should be doing the
> > job here of setting the dma_mask pointer to a proper value.
> > 
> > Li, can you take care of that ? Look at other bus types we have in
> > there such as the macio bus etc...
> 
> Oh, hang on a moment, this is the "bus" code.
> 
> In which case, the question becomes: do vio devices ever need to have
> a separate streaming DMA mask from a coherent DMA mask?  If not, then
> something like the following is what's needed here, and I should've
> never have used dma_set_mask_and_coherent().

No, a single mask.

> dma_set_mask_and_coherent() (and the other dma_set_mask() functions)
> are really supposed to be used by drivers only.
> 
>  arch/powerpc/kernel/vio.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
> index e7d0c88f621a..d771778f398e 100644
> --- a/arch/powerpc/kernel/vio.c
> +++ b/arch/powerpc/kernel/vio.c
> @@ -1419,7 +1419,8 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
>  
>  		/* needed to ensure proper operation of coherent allocations
>  		 * later, in case driver doesn't set it explicitly */
> -		dma_set_mask_and_coherent(&viodev->dev, DMA_BIT_MASK(64));
> +		viodev->dev.coherent_dma_mask = DMA_BIT_MASK(64);
> +		viodev->dev.dma_mask = &viodev->dev.coherent_dma_mask;
>  	}
>  
>  	/* register with generic device framework */

Right that's exactly what I had in mind. Li, can you test this please ?

The previous "fix" using dma_coerce_mask_and_coherent() is already on
its way to Linus, so we'll rework the above patch to undo it but for
now please test.

Cheers,
Ben.

  reply	other threads:[~2013-11-21  0:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-19  8:11 [RFC PATCH powerpc] Fix a dma_mask issue of vio Li Zhong
2013-11-20  1:28 ` Benjamin Herrenschmidt
2013-11-20  2:04   ` Li Zhong
2013-11-20 23:23   ` Russell King - ARM Linux
2013-11-21  0:01     ` Benjamin Herrenschmidt
2013-11-21  0:08       ` Russell King - ARM Linux
2013-11-21  0:22         ` Benjamin Herrenschmidt [this message]
2013-11-21  1:56           ` Li Zhong
2013-11-28  9:22           ` [PATCH powerpc] Revert c6102609 and replace it with the correct fix for vio dma mask setting Li Zhong

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=1384993347.26969.124.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=linux@arm.linux.org.uk \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    --cc=zhong@linux.vnet.ibm.com \
    /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).