lkml.org 
[lkml]   [2020]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH] mfd: mfd-core: inherit only valid dma_masks/flags from parent
On Wed, Mar 11, 2020 at 12:09:35AM +0100, 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.
>
> There was also a thread [1] about this topic, but there seems to be no
> conclusion.
>
> [1] https://www.spinics.net/lists/linux-renesas-soc/msg31581.html
>
> drivers/mfd/mfd-core.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
> index b9eb8f40c073..5d8ea5e8e93c 100644
> --- a/drivers/mfd/mfd-core.c
> +++ b/drivers/mfd/mfd-core.c
> @@ -139,9 +139,12 @@ 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->dev.dma_parms = parent->dma_parms;
> - pdev->dev.coherent_dma_mask = parent->coherent_dma_mask;
> + if (parent->dma_mask)
> + pdev->dev.dma_mask = parent->dma_mask;
> + if (parent->dma_parms)
> + pdev->dev.dma_parms = parent->dma_parms;

Both of these are pointers, and we can't just share them. You need
to allocate storage for them and the allocate the values over.

\
 
 \ /
  Last update: 2020-03-11 07:18    [W:0.047 / U:0.412 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site