linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2 04/11] of/fdt: add early_init_dt_get_dma_zone_size()
       [not found] ` <20190820145821.27214-5-nsaenzjulienne@suse.de>
@ 2019-08-20 17:14   ` Rob Herring
  0 siblings, 0 replies; 15+ messages in thread
From: Rob Herring @ 2019-08-20 17:14 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: Catalin Marinas, Christoph Hellwig, Stefan Wahren, Marc Zyngier,
	Robin Murphy,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	devicetree, open list:GENERIC INCLUDE/ASM HEADER FILES,
	Linux IOMMU, linux-mm, linux-riscv, Frank Rowand, phill,
	Florian Fainelli, Will Deacon, linux-kernel, Eric Anholt,
	Matthias Brugger,
	moderated list:BROADCOM BCM2835 ARM ARCHITECTURE, Andrew Morton,
	Marek Szyprowski

On Tue, Aug 20, 2019 at 9:58 AM Nicolas Saenz Julienne
<nsaenzjulienne@suse.de> wrote:
>
> Some devices might have weird DMA addressing limitations that only apply
> to a subset of the available peripherals. For example the Raspberry Pi 4
> has two interconnects, one able to address the whole lower 4G memory
> area and another one limited to the lower 1G.
>
> Being an uncommon situation we simply hardcode the device wide DMA
> addressable memory size conditionally to the machine compatible name and
> set 'dma_zone_size' accordingly.
>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>
> ---
>
> Changes in v2:
> - New approach to getting dma_zone_size, instead of parsing the dts we
>   hardcode it conditionally to the machine compatible name.
>
>  drivers/of/fdt.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 06ffbd39d9af..f756e8c05a77 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -27,6 +27,7 @@
>
>  #include <asm/setup.h>  /* for COMMAND_LINE_SIZE */
>  #include <asm/page.h>
> +#include <asm/dma.h>   /* for dma_zone_size */
>
>  #include "of_private.h"
>
> @@ -1195,6 +1196,12 @@ void __init early_init_dt_scan_nodes(void)
>         of_scan_flat_dt(early_init_dt_scan_memory, NULL);
>  }
>
> +void __init early_init_dt_get_dma_zone_size(void)

static

With that,

Reviewed-by: Rob Herring <robh@kernel.org>

> +{
> +       if (of_fdt_machine_is_compatible("brcm,bcm2711"))
> +               dma_zone_size = 0x3c000000;
> +}
> +
>  bool __init early_init_dt_scan(void *params)
>  {
>         bool status;
> @@ -1204,6 +1211,7 @@ bool __init early_init_dt_scan(void *params)
>                 return false;
>
>         early_init_dt_scan_nodes();
> +       early_init_dt_get_dma_zone_size();
>         return true;
>  }
>
> --
> 2.22.0
>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 03/11] of/fdt: add of_fdt_machine_is_compatible function
       [not found] ` <20190820145821.27214-4-nsaenzjulienne@suse.de>
@ 2019-08-20 17:16   ` Rob Herring
  2019-08-20 17:27     ` Nicolas Saenz Julienne
  0 siblings, 1 reply; 15+ messages in thread
From: Rob Herring @ 2019-08-20 17:16 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: Catalin Marinas, Christoph Hellwig, Stefan Wahren, Marc Zyngier,
	Robin Murphy,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	devicetree, open list:GENERIC INCLUDE/ASM HEADER FILES,
	Linux IOMMU, linux-mm, linux-riscv, Frank Rowand, phill,
	Florian Fainelli, Will Deacon, linux-kernel, Eric Anholt,
	Matthias Brugger,
	moderated list:BROADCOM BCM2835 ARM ARCHITECTURE, Andrew Morton,
	Marek Szyprowski

On Tue, Aug 20, 2019 at 9:58 AM Nicolas Saenz Julienne
<nsaenzjulienne@suse.de> wrote:
>
> Provides the same functionality as of_machine_is_compatible.
>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> ---
>
> Changes in v2: None
>
>  drivers/of/fdt.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 9cdf14b9aaab..06ffbd39d9af 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -802,6 +802,13 @@ const char * __init of_flat_dt_get_machine_name(void)
>         return name;
>  }
>
> +static const int __init of_fdt_machine_is_compatible(char *name)

No point in const return (though name could possibly be const), and
the return could be bool instead.

With that,

Reviewed-by: Rob Herring <robh@kernel.org>

> +{
> +       unsigned long dt_root = of_get_flat_dt_root();
> +
> +       return of_flat_dt_is_compatible(dt_root, name);
> +}
> +
>  /**
>   * of_flat_dt_match_machine - Iterate match tables to find matching machine.
>   *
> --
> 2.22.0
>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 03/11] of/fdt: add of_fdt_machine_is_compatible function
  2019-08-20 17:16   ` [PATCH v2 03/11] of/fdt: add of_fdt_machine_is_compatible function Rob Herring
@ 2019-08-20 17:27     ` Nicolas Saenz Julienne
  0 siblings, 0 replies; 15+ messages in thread
From: Nicolas Saenz Julienne @ 2019-08-20 17:27 UTC (permalink / raw)
  To: Rob Herring
  Cc: open list:GENERIC INCLUDE/ASM HEADER FILES, devicetree,
	moderated list:BROADCOM BCM2835 ARM ARCHITECTURE,
	Florian Fainelli, Andrew Morton, Frank Rowand, Eric Anholt,
	Marc Zyngier, Catalin Marinas, Will Deacon, linux-kernel,
	linux-mm, Linux IOMMU, Matthias Brugger, Stefan Wahren,
	linux-riscv, Marek Szyprowski, Robin Murphy, Christoph Hellwig,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE, phill

[-- Attachment #1: Type: text/plain, Size: 1094 bytes --]

Hi Rob,
thanks for the rewiew.

On Tue, 2019-08-20 at 12:16 -0500, Rob Herring wrote:
> On Tue, Aug 20, 2019 at 9:58 AM Nicolas Saenz Julienne
> <nsaenzjulienne@suse.de> wrote:
> > Provides the same functionality as of_machine_is_compatible.
> > 
> > Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> > ---
> > 
> > Changes in v2: None
> > 
> >  drivers/of/fdt.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> > index 9cdf14b9aaab..06ffbd39d9af 100644
> > --- a/drivers/of/fdt.c
> > +++ b/drivers/of/fdt.c
> > @@ -802,6 +802,13 @@ const char * __init of_flat_dt_get_machine_name(void)
> >         return name;
> >  }
> > 
> > +static const int __init of_fdt_machine_is_compatible(char *name)
> 
> No point in const return (though name could possibly be const), and
> the return could be bool instead.

Sorry, I completely missed that const, shouldn't have been there to begin with.

I'll add a const to the name argument and return a bool on the next version.

Regards,
Nicolas



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 09/11] dma-direct: turn ARCH_ZONE_DMA_BITS into a variable
       [not found] ` <20190820145821.27214-10-nsaenzjulienne@suse.de>
@ 2019-08-26  7:05   ` Christoph Hellwig
  2019-08-26 11:33   ` Michael Ellerman
  1 sibling, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2019-08-26  7:05 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: catalin.marinas, hch, wahrenst, marc.zyngier, robh+dt,
	Robin Murphy, linux-arm-kernel, devicetree, linux-arch, iommu,
	linux-mm, linux-riscv, Marek Szyprowski, phill, f.fainelli, will,
	linux-kernel, eric, mbrugger, linux-rpi-kernel, akpm,
	frowand.list, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Heiko Carstens, Vasily Gorbik,
	Christian Borntraeger, linuxppc-dev, linux-s390

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 10/11] arm64: edit zone_dma_bits to fine tune dma-direct min mask
       [not found] ` <20190820145821.27214-11-nsaenzjulienne@suse.de>
@ 2019-08-26  7:06   ` Christoph Hellwig
  2019-08-26 11:08     ` Nicolas Saenz Julienne
  0 siblings, 1 reply; 15+ messages in thread
From: Christoph Hellwig @ 2019-08-26  7:06 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: catalin.marinas, hch, wahrenst, marc.zyngier, robh+dt,
	Robin Murphy, linux-arm-kernel, devicetree, linux-arch, iommu,
	linux-mm, linux-riscv, linux-kernel, phill, f.fainelli, will,
	eric, mbrugger, linux-rpi-kernel, akpm, frowand.list,
	m.szyprowski

On Tue, Aug 20, 2019 at 04:58:18PM +0200, Nicolas Saenz Julienne wrote:
> -	if (IS_ENABLED(CONFIG_ZONE_DMA))
> +	if (IS_ENABLED(CONFIG_ZONE_DMA)) {
>  		arm64_dma_phys_limit = max_zone_dma_phys();
> +		zone_dma_bits = ilog2((arm64_dma_phys_limit - 1) & GENMASK_ULL(31, 0)) + 1;

This adds a way too long line.  I also find the use of GENMASK_ULL
horribly obsfucating, but I know that opinion is't shared by everyone.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 11/11] mm: refresh ZONE_DMA and ZONE_DMA32 comments in 'enum zone_type'
       [not found] ` <20190820145821.27214-12-nsaenzjulienne@suse.de>
@ 2019-08-26  7:07   ` Christoph Hellwig
  0 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2019-08-26  7:07 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: catalin.marinas, hch, wahrenst, marc.zyngier, robh+dt,
	Robin Murphy, linux-arm-kernel, devicetree, linux-arch, iommu,
	linux-mm, linux-riscv, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	phill, f.fainelli, will, linux-kernel, eric, mbrugger,
	linux-rpi-kernel, akpm, frowand.list, m.szyprowski

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 01/11] asm-generic: add dma_zone_size
       [not found] ` <20190820145821.27214-2-nsaenzjulienne@suse.de>
@ 2019-08-26  7:09   ` Christoph Hellwig
  2019-08-26 13:46     ` Nicolas Saenz Julienne
  0 siblings, 1 reply; 15+ messages in thread
From: Christoph Hellwig @ 2019-08-26  7:09 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: catalin.marinas, hch, wahrenst, marc.zyngier, robh+dt,
	Robin Murphy, linux-arm-kernel, devicetree, linux-arch, iommu,
	linux-mm, linux-riscv, Arnd Bergmann, phill, f.fainelli, will,
	linux-kernel, eric, mbrugger, linux-rpi-kernel, akpm,
	frowand.list, m.szyprowski

On Tue, Aug 20, 2019 at 04:58:09PM +0200, Nicolas Saenz Julienne wrote:
> Some architectures have platform specific DMA addressing limitations.
> This will allow for hardware description code to provide the constraints
> in a generic manner, so as for arch code to properly setup it's memory
> zones and DMA mask.

I know this just spreads the arm code, but I still kinda hate it.

MAX_DMA_ADDRESS is such an oddly defined concepts.  We have the mm
code that uses it to start allocating after the dma zones, but
I think that would better be done using a function returning
1 << max(zone_dma_bits, 32) or so.  Then we have about a handful
of drivers using it that all seem rather bogus, and one of which
I think are usable on arm64.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 10/11] arm64: edit zone_dma_bits to fine tune dma-direct min mask
  2019-08-26  7:06   ` [PATCH v2 10/11] arm64: edit zone_dma_bits to fine tune dma-direct min mask Christoph Hellwig
@ 2019-08-26 11:08     ` Nicolas Saenz Julienne
  2019-08-27  7:03       ` Petr Tesarik
  0 siblings, 1 reply; 15+ messages in thread
From: Nicolas Saenz Julienne @ 2019-08-26 11:08 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: catalin.marinas, wahrenst, marc.zyngier, robh+dt, Robin Murphy,
	linux-arm-kernel, devicetree, linux-arch, iommu, linux-mm,
	linux-riscv, linux-kernel, phill, f.fainelli, will, eric,
	mbrugger, linux-rpi-kernel, akpm, frowand.list, m.szyprowski

[-- Attachment #1: Type: text/plain, Size: 821 bytes --]

On Mon, 2019-08-26 at 09:06 +0200, Christoph Hellwig wrote:
> On Tue, Aug 20, 2019 at 04:58:18PM +0200, Nicolas Saenz Julienne wrote:
> > -	if (IS_ENABLED(CONFIG_ZONE_DMA))
> > +	if (IS_ENABLED(CONFIG_ZONE_DMA)) {
> >  		arm64_dma_phys_limit = max_zone_dma_phys();
> > +		zone_dma_bits = ilog2((arm64_dma_phys_limit - 1) &
> > GENMASK_ULL(31, 0)) + 1;
>
Hi Christoph,
thanks for the rewiews.

> This adds a way too long line.

I know, I couldn't find a way to split the operation without making it even
harder to read. I'll find a solution.

> I also find the use of GENMASK_ULL
> horribly obsfucating, but I know that opinion is't shared by everyone.

Don't have any preference so I'll happily change it. Any suggestions? Using the
explicit 0xffffffffULL seems hard to read, how about SZ_4GB - 1?


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 09/11] dma-direct: turn ARCH_ZONE_DMA_BITS into a variable
       [not found] ` <20190820145821.27214-10-nsaenzjulienne@suse.de>
  2019-08-26  7:05   ` [PATCH v2 09/11] dma-direct: turn ARCH_ZONE_DMA_BITS into a variable Christoph Hellwig
@ 2019-08-26 11:33   ` Michael Ellerman
  1 sibling, 0 replies; 15+ messages in thread
From: Michael Ellerman @ 2019-08-26 11:33 UTC (permalink / raw)
  To: Nicolas Saenz Julienne, catalin.marinas, hch, wahrenst,
	marc.zyngier, robh+dt, Robin Murphy, linux-arm-kernel,
	devicetree, linux-arch, iommu, linux-mm, linux-riscv,
	Marek Szyprowski
  Cc: f.fainelli, will, nsaenzjulienne, linux-kernel, eric, mbrugger,
	linux-rpi-kernel, akpm, frowand.list, Benjamin Herrenschmidt,
	Paul Mackerras, Heiko Carstens, Vasily Gorbik,
	Christian Borntraeger, linuxppc-dev, linux-s390

Nicolas Saenz Julienne <nsaenzjulienne@suse.de> writes:
> diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
> index 0d52f57fca04..73668a21ae78 100644
> --- a/arch/powerpc/include/asm/page.h
> +++ b/arch/powerpc/include/asm/page.h
> @@ -319,13 +319,4 @@ struct vm_area_struct;
>  #endif /* __ASSEMBLY__ */
>  #include <asm/slice.h>
>  
> -/*
> - * Allow 30-bit DMA for very limited Broadcom wifi chips on many powerbooks.

This comment got lost.

> diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
> index 9191a66b3bc5..2a69f87585df 100644
> --- a/arch/powerpc/mm/mem.c
> +++ b/arch/powerpc/mm/mem.c
> @@ -237,9 +238,14 @@ void __init paging_init(void)
>  	printk(KERN_DEBUG "Memory hole size: %ldMB\n",
>  	       (long int)((top_of_ram - total_ram) >> 20));
>  
> +	if (IS_ENABLED(CONFIG_PPC32))

Can you please propagate it here?

> +		zone_dma_bits = 30;
> +	else
> +		zone_dma_bits = 31;
> +

cheers


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 01/11] asm-generic: add dma_zone_size
  2019-08-26  7:09   ` [PATCH v2 01/11] asm-generic: add dma_zone_size Christoph Hellwig
@ 2019-08-26 13:46     ` Nicolas Saenz Julienne
  2019-08-28  9:44       ` Nicolas Saenz Julienne
  2019-08-30 14:45       ` Catalin Marinas
  0 siblings, 2 replies; 15+ messages in thread
From: Nicolas Saenz Julienne @ 2019-08-26 13:46 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: catalin.marinas, eric, linux-riscv, frowand.list, m.szyprowski,
	linux-arch, f.fainelli, will, devicetree, Arnd Bergmann,
	marc.zyngier, robh+dt, linux-rpi-kernel, linux-arm-kernel, phill,
	mbrugger, linux-mm, linux-kernel, iommu, wahrenst, akpm,
	Robin Murphy

[-- Attachment #1: Type: text/plain, Size: 1724 bytes --]

On Mon, 2019-08-26 at 09:09 +0200, Christoph Hellwig wrote:
> On Tue, Aug 20, 2019 at 04:58:09PM +0200, Nicolas Saenz Julienne wrote:
> > Some architectures have platform specific DMA addressing limitations.
> > This will allow for hardware description code to provide the constraints
> > in a generic manner, so as for arch code to properly setup it's memory
> > zones and DMA mask.
> 
> I know this just spreads the arm code, but I still kinda hate it.

Rob's main concern was finding a way to pass the constraint from HW definition
to arch without widening fdt's architecture specific function surface. I'd say
it's fair to argue that having a generic mechanism makes sense as it'll now
traverse multiple archs and subsystems.

I get adding globals like this is not very appealing, yet I went with it as it
was the easier to integrate with arm's code. Any alternative suggestions?

> MAX_DMA_ADDRESS is such an oddly defined concepts.  We have the mm
> code that uses it to start allocating after the dma zones, but
> I think that would better be done using a function returning
> 1 << max(zone_dma_bits, 32) or so.  Then we have about a handful
> of drivers using it that all seem rather bogus, and one of which
> I think are usable on arm64.

Is it safe to assume DMA limitations will always be a power of 2? I ask as RPi4
kinda isn't: ZONE_DMA is 0x3c000000 bytes big, I'm approximating the zone mask
to 30 as [0x3c000000 0x3fffffff] isn't defined as memory so it's unlikely that
we´ll encounter buffers there. But I don't know how it could affect mm
initialization code.

This also rules out 'zone_dma_bits' as a mechanism to pass ZONE_DMA's size from
HW definition code to arch's.


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 10/11] arm64: edit zone_dma_bits to fine tune dma-direct min mask
  2019-08-26 11:08     ` Nicolas Saenz Julienne
@ 2019-08-27  7:03       ` Petr Tesarik
  0 siblings, 0 replies; 15+ messages in thread
From: Petr Tesarik @ 2019-08-27  7:03 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: Christoph Hellwig, linux-arch, devicetree, linux-rpi-kernel,
	f.fainelli, will, eric, marc.zyngier, catalin.marinas,
	frowand.list, linux-kernel, linux-mm, iommu, robh+dt, wahrenst,
	mbrugger, linux-riscv, m.szyprowski, Robin Murphy, akpm,
	linux-arm-kernel, phill

[-- Attachment #1: Type: text/plain, Size: 820 bytes --]

On Mon, 26 Aug 2019 13:08:50 +0200
Nicolas Saenz Julienne <nsaenzjulienne@suse.de> wrote:

> On Mon, 2019-08-26 at 09:06 +0200, Christoph Hellwig wrote:
> > On Tue, Aug 20, 2019 at 04:58:18PM +0200, Nicolas Saenz Julienne wrote:  
> > > -	if (IS_ENABLED(CONFIG_ZONE_DMA))
> > > +	if (IS_ENABLED(CONFIG_ZONE_DMA)) {
> > >  		arm64_dma_phys_limit = max_zone_dma_phys();
> > > +		zone_dma_bits = ilog2((arm64_dma_phys_limit - 1) &
> > > GENMASK_ULL(31, 0)) + 1;  
> >  
> Hi Christoph,
> thanks for the rewiews.
> 
> > This adds a way too long line.  
> 
> I know, I couldn't find a way to split the operation without making it even
> harder to read. I'll find a solution.

If all else fails, move the code to an inline function and call it e.g.
phys_limit_to_dma_bits().

Just my two cents,
Petr T

[-- Attachment #2: Digitální podpis OpenPGP --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 01/11] asm-generic: add dma_zone_size
  2019-08-26 13:46     ` Nicolas Saenz Julienne
@ 2019-08-28  9:44       ` Nicolas Saenz Julienne
  2019-08-30 14:45       ` Catalin Marinas
  1 sibling, 0 replies; 15+ messages in thread
From: Nicolas Saenz Julienne @ 2019-08-28  9:44 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: catalin.marinas, linux-mm, linux-riscv, will, m.szyprowski,
	linux-arch, f.fainelli, frowand.list, devicetree, Arnd Bergmann,
	marc.zyngier, robh+dt, linux-rpi-kernel, linux-arm-kernel, phill,
	mbrugger, eric, linux-kernel, iommu, wahrenst, akpm,
	Robin Murphy

[-- Attachment #1: Type: text/plain, Size: 2255 bytes --]

On Mon, 2019-08-26 at 15:46 +0200, Nicolas Saenz Julienne wrote:
> On Mon, 2019-08-26 at 09:09 +0200, Christoph Hellwig wrote:
> > On Tue, Aug 20, 2019 at 04:58:09PM +0200, Nicolas Saenz Julienne wrote:
> > > Some architectures have platform specific DMA addressing limitations.
> > > This will allow for hardware description code to provide the constraints
> > > in a generic manner, so as for arch code to properly setup it's memory
> > > zones and DMA mask.
> > 
> > I know this just spreads the arm code, but I still kinda hate it.
> 
> Rob's main concern was finding a way to pass the constraint from HW definition
> to arch without widening fdt's architecture specific function surface. I'd say
> it's fair to argue that having a generic mechanism makes sense as it'll now
> traverse multiple archs and subsystems.
> 
> I get adding globals like this is not very appealing, yet I went with it as it
> was the easier to integrate with arm's code. Any alternative suggestions?
> 
> > MAX_DMA_ADDRESS is such an oddly defined concepts.  We have the mm
> > code that uses it to start allocating after the dma zones, but
> > I think that would better be done using a function returning
> > 1 << max(zone_dma_bits, 32) or so.  Then we have about a handful
> > of drivers using it that all seem rather bogus, and one of which
> > I think are usable on arm64.
> 
> Is it safe to assume DMA limitations will always be a power of 2? I ask as
> RPi4
> kinda isn't: ZONE_DMA is 0x3c000000 bytes big, I'm approximating the zone mask
> to 30 as [0x3c000000 0x3fffffff] isn't defined as memory so it's unlikely that
> we´ll encounter buffers there. But I don't know how it could affect mm
> initialization code.
> 
> This also rules out 'zone_dma_bits' as a mechanism to pass ZONE_DMA's size
> from
> HW definition code to arch's.

Hi Christoph,
I gave it a thought and think this whole MAX_DMA_ADDRESS topic falls out of the
scope of the series. I agree it's something that we should get rid of, but
fixing it isn't going to affect the overall enhancement intended here.  I'd
rather focus on how are we going to pass the DMA zone data into the arch code
and fix MAX_DMA_ADDRESS on another series.

Regards,
Nicolas


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 01/11] asm-generic: add dma_zone_size
  2019-08-26 13:46     ` Nicolas Saenz Julienne
  2019-08-28  9:44       ` Nicolas Saenz Julienne
@ 2019-08-30 14:45       ` Catalin Marinas
  2019-08-30 17:24         ` Nicolas Saenz Julienne
  1 sibling, 1 reply; 15+ messages in thread
From: Catalin Marinas @ 2019-08-30 14:45 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: Christoph Hellwig, eric, linux-riscv, frowand.list, m.szyprowski,
	linux-arch, f.fainelli, will, devicetree, Arnd Bergmann,
	marc.zyngier, robh+dt, linux-rpi-kernel, linux-arm-kernel, phill,
	mbrugger, linux-mm, linux-kernel, iommu, wahrenst, akpm,
	Robin Murphy

On Mon, Aug 26, 2019 at 03:46:52PM +0200, Nicolas Saenz Julienne wrote:
> On Mon, 2019-08-26 at 09:09 +0200, Christoph Hellwig wrote:
> > On Tue, Aug 20, 2019 at 04:58:09PM +0200, Nicolas Saenz Julienne wrote:
> > > Some architectures have platform specific DMA addressing limitations.
> > > This will allow for hardware description code to provide the constraints
> > > in a generic manner, so as for arch code to properly setup it's memory
> > > zones and DMA mask.
> > 
> > I know this just spreads the arm code, but I still kinda hate it.
> 
> Rob's main concern was finding a way to pass the constraint from HW definition
> to arch without widening fdt's architecture specific function surface. I'd say
> it's fair to argue that having a generic mechanism makes sense as it'll now
> traverse multiple archs and subsystems.
> 
> I get adding globals like this is not very appealing, yet I went with it as it
> was the easier to integrate with arm's code. Any alternative suggestions?

In some discussion with Robin, since it's just RPi4 that we are aware of
having such requirement on arm64, he suggested that we have a permanent
ZONE_DMA on arm64 with a default size of 1GB. It should cover all arm64
SoCs we know of without breaking the single Image binary. The arch/arm
can use its current mach-* support.

I may like this more than the proposed early_init_dt_get_dma_zone_size()
here which checks for specific SoCs (my preferred way was to build the
mask from all buses described in DT but I hadn't realised the
complications).

-- 
Catalin


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 01/11] asm-generic: add dma_zone_size
  2019-08-30 14:45       ` Catalin Marinas
@ 2019-08-30 17:24         ` Nicolas Saenz Julienne
  2019-09-02 13:01           ` Christoph Hellwig
  0 siblings, 1 reply; 15+ messages in thread
From: Nicolas Saenz Julienne @ 2019-08-30 17:24 UTC (permalink / raw)
  To: Catalin Marinas, Christoph Hellwig
  Cc: linux-mm, linux-riscv, will, m.szyprowski, linux-arch,
	f.fainelli, frowand.list, devicetree, Arnd Bergmann,
	marc.zyngier, robh+dt, linux-rpi-kernel, linux-arm-kernel, phill,
	mbrugger, eric, linux-kernel, iommu, wahrenst, akpm,
	Robin Murphy

[-- Attachment #1: Type: text/plain, Size: 2088 bytes --]

On Fri, 2019-08-30 at 15:45 +0100, Catalin Marinas wrote:
> On Mon, Aug 26, 2019 at 03:46:52PM +0200, Nicolas Saenz Julienne wrote:
> > On Mon, 2019-08-26 at 09:09 +0200, Christoph Hellwig wrote:
> > > On Tue, Aug 20, 2019 at 04:58:09PM +0200, Nicolas Saenz Julienne wrote:
> > > > Some architectures have platform specific DMA addressing limitations.
> > > > This will allow for hardware description code to provide the constraints
> > > > in a generic manner, so as for arch code to properly setup it's memory
> > > > zones and DMA mask.
> > > 
> > > I know this just spreads the arm code, but I still kinda hate it.
> > 
> > Rob's main concern was finding a way to pass the constraint from HW
> > definition
> > to arch without widening fdt's architecture specific function surface. I'd
> > say
> > it's fair to argue that having a generic mechanism makes sense as it'll now
> > traverse multiple archs and subsystems.
> > 
> > I get adding globals like this is not very appealing, yet I went with it as
> > it
> > was the easier to integrate with arm's code. Any alternative suggestions?
> 
> In some discussion with Robin, since it's just RPi4 that we are aware of
> having such requirement on arm64, he suggested that we have a permanent
> ZONE_DMA on arm64 with a default size of 1GB. It should cover all arm64
> SoCs we know of without breaking the single Image binary. The arch/arm
> can use its current mach-* support.
> 
> I may like this more than the proposed early_init_dt_get_dma_zone_size()
> here which checks for specific SoCs (my preferred way was to build the
> mask from all buses described in DT but I hadn't realised the
> complications).

Hi Catalin, thanks for giving it a thought.

I'll be happy to implement it that way. I agree it's a good compromise.

@Christoph, do you still want the patch where I create 'zone_dma_bits'? With a
hardcoded ZONE_DMA it's not absolutely necessary. Though I remember you said it
was a first step towards being able to initialize dma-direct's min_mask in
meminit.

Regards,
Nicolas


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 01/11] asm-generic: add dma_zone_size
  2019-08-30 17:24         ` Nicolas Saenz Julienne
@ 2019-09-02 13:01           ` Christoph Hellwig
  0 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2019-09-02 13:01 UTC (permalink / raw)
  To: Nicolas Saenz Julienne
  Cc: Catalin Marinas, Christoph Hellwig, linux-mm, linux-riscv, will,
	m.szyprowski, linux-arch, f.fainelli, frowand.list, devicetree,
	Arnd Bergmann, marc.zyngier, robh+dt, linux-rpi-kernel,
	linux-arm-kernel, phill, mbrugger, eric, linux-kernel, iommu,
	wahrenst, akpm, Robin Murphy

On Fri, Aug 30, 2019 at 07:24:25PM +0200, Nicolas Saenz Julienne wrote:
> I'll be happy to implement it that way. I agree it's a good compromise.
> 
> @Christoph, do you still want the patch where I create 'zone_dma_bits'? With a
> hardcoded ZONE_DMA it's not absolutely necessary. Though I remember you said it
> was a first step towards being able to initialize dma-direct's min_mask in
> meminit.

I do like the variable better than the current #define.  I wonder if
really want a mask or a max_zone_dma_address like variable.  So for this
series feel free to drop the patch.   I'll see if I'll pick it up
later or if we can find some way to automatically propagate that
information from the zone initialization.


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-09-02 13:01 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20190820145821.27214-1-nsaenzjulienne@suse.de>
     [not found] ` <20190820145821.27214-5-nsaenzjulienne@suse.de>
2019-08-20 17:14   ` [PATCH v2 04/11] of/fdt: add early_init_dt_get_dma_zone_size() Rob Herring
     [not found] ` <20190820145821.27214-4-nsaenzjulienne@suse.de>
2019-08-20 17:16   ` [PATCH v2 03/11] of/fdt: add of_fdt_machine_is_compatible function Rob Herring
2019-08-20 17:27     ` Nicolas Saenz Julienne
     [not found] ` <20190820145821.27214-11-nsaenzjulienne@suse.de>
2019-08-26  7:06   ` [PATCH v2 10/11] arm64: edit zone_dma_bits to fine tune dma-direct min mask Christoph Hellwig
2019-08-26 11:08     ` Nicolas Saenz Julienne
2019-08-27  7:03       ` Petr Tesarik
     [not found] ` <20190820145821.27214-12-nsaenzjulienne@suse.de>
2019-08-26  7:07   ` [PATCH v2 11/11] mm: refresh ZONE_DMA and ZONE_DMA32 comments in 'enum zone_type' Christoph Hellwig
     [not found] ` <20190820145821.27214-2-nsaenzjulienne@suse.de>
2019-08-26  7:09   ` [PATCH v2 01/11] asm-generic: add dma_zone_size Christoph Hellwig
2019-08-26 13:46     ` Nicolas Saenz Julienne
2019-08-28  9:44       ` Nicolas Saenz Julienne
2019-08-30 14:45       ` Catalin Marinas
2019-08-30 17:24         ` Nicolas Saenz Julienne
2019-09-02 13:01           ` Christoph Hellwig
     [not found] ` <20190820145821.27214-10-nsaenzjulienne@suse.de>
2019-08-26  7:05   ` [PATCH v2 09/11] dma-direct: turn ARCH_ZONE_DMA_BITS into a variable Christoph Hellwig
2019-08-26 11:33   ` Michael Ellerman

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).