mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michael Walle <michael@walle.cc>
To: Robin Murphy <robin.murphy@arm.com>
Cc: linux-kernel@vger.kernel.org, Lee Jones <lee.jones@linaro.org>,
	Christoph Hellwig <hch@lst.de>, Rob Herring <robh@kernel.org>,
	Russell King <linux@armlinux.org.uk>
Subject: Re: [RFC PATCH] mfd: mfd-core: inherit only valid dma_masks/flags from parent
Date: Wed, 11 Mar 2020 14:10:04 +0100	[thread overview]
Message-ID: <68db76c663170817c223fcf779a92d28@walle.cc> (raw)
In-Reply-To: <5f167c37-566f-bd62-b0fd-fdb7925c5afd@arm.com>

Am 2020-03-11 12:25, schrieb Robin Murphy:
> On 2020-03-10 11:09 pm, Michael Walle wrote:
>> Only copy the dma_masks and flags from the parent device, if the 
>> parent
>> has a valid dma_mask/flags. Commit cdfee5623290 ("driver core:
>> initialize a default DMA mask for platform device") initialize the DMA
>> masks of a platform device. But if the parent doesn't have a dma_mask
>> set, for example if it's an I2C device, the dma_mask of the child
>> platform device will be set to zero again. Which leads to many "DMA 
>> mask
>> not set" warnings, if the MFD cell has the of_compatible property set.
>> 
>> [    1.877937] sl28cpld-pwm sl28cpld-pwm: DMA mask not set
>> [    1.883282] sl28cpld-pwm sl28cpld-pwm.0: DMA mask not set
>> [    1.888795] sl28cpld-gpio sl28cpld-gpio: DMA mask not set
>> 
>> Thus a MFD child should just inherit valid dma_masks and keep the
>> platform default otherwise.
>> 
>> Cc: Christoph Hellwig <hch@lst.de>
>> Cc: Rob Herring <robh@kernel.org>
>> Cc: Robin Murphy <robin.murphy@arm.com>
>> Cc: Russell King <linux@armlinux.org.uk>
>> Signed-off-by: Michael Walle <michael@walle.cc>
>> ---
>> 
>> Hi,
>> 
>> I don't know if that is the correct way of handling things. Maybe I'm
>> also doing something wrong in my driver, I had a look at other I2C MFD
>> drivers but couldn't find a clue why they shouldn't have the same
>> problem.
> 
> The underlying issue is that about 99% of MFD children should not be
> going through dma_configure() at all because their parent 'real'
> device is not on a DMA-capable bus, but as they are platform devices
> we are forced to give them the benefit of the doubt. For DT systems
> the only vaguely-reasonable heuristic to distinguish between
> "platform" meaning "SoC memory-mapped device" and "platform" meaning
> "random crap made up by Linux" is whether the device has a populated
> OF node, but MFD's trick of hanging the parent device's OF node onto
> its synthesised children kicks a hole right through even that.

Thanks for the explanation.

> Modulo any other concerns with the existing code, does the change
> below make things work the way you want? It's still a bit of a bodge,
> but short of invasive large-scale changes with bus types I don't see a
> way to do the 'right' thing :/
> 
> Robin.
> 
> ----->8-----
> diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
> index f5a73af60dd4..1e4a6e8bd630 100644
> --- a/drivers/mfd/mfd-core.c
> +++ b/drivers/mfd/mfd-core.c
> @@ -138,7 +138,7 @@ static int mfd_add_device(struct device *parent, 
> int id,
> 
>  	pdev->dev.parent = parent;
>  	pdev->dev.type = &mfd_dev_type;
> -	pdev->dev.dma_mask = parent->dma_mask;
> +	pdev->dma_mask = parent->dma_mask ? *parent->dma_mask : 0;

That works.

-michael

>  	pdev->dev.dma_parms = parent->dma_parms;
>  	pdev->dev.coherent_dma_mask = parent->coherent_dma_mask;

      reply	other threads:[~2020-03-11 13:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-10 23:09 Michael Walle
2020-03-11  6:18 ` Christoph Hellwig
2020-03-11  7:59   ` Michael Walle
2020-03-11 11:25 ` Robin Murphy
2020-03-11 13:10   ` Michael Walle [this message]

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=68db76c663170817c223fcf779a92d28@walle.cc \
    --to=michael@walle.cc \
    --cc=hch@lst.de \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=robh@kernel.org \
    --cc=robin.murphy@arm.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

all inboxes | Powered by JetHome®