diff mbox series

[v3,11/15] layerscape: use the lmb API's to add RAM memory

Message ID 20241013105522.391414-12-sughosh.ganu@linaro.org
State Superseded
Headers show
Series Make EFI memory allocations synchronous with LMB | expand

Commit Message

Sughosh Ganu Oct. 13, 2024, 10:55 a.m. UTC
The EFI memory allocations are now being done through the LMB module,
and hence the memory map is maintained by the LMB module. Use the
lmb_arch_add_memory() API function to add the usable RAM memory to the
LMB's memory map.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
Changes since V2: None

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 8 ++++----
 lib/Kconfig                             | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

Comments

Simon Glass Oct. 14, 2024, 3:50 p.m. UTC | #1
Hi Sughosh,

On Sun, 13 Oct 2024 at 04:56, Sughosh Ganu <sughosh.ganu@linaro.org> wrote:
>
> The EFI memory allocations are now being done through the LMB module,
> and hence the memory map is maintained by the LMB module. Use the
> lmb_arch_add_memory() API function to add the usable RAM memory to the
> LMB's memory map.
>
> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> ---
> Changes since V2: None
>
>  arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 8 ++++----
>  lib/Kconfig                             | 1 +
>  2 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> index f9c2083677..d2d3e346a3 100644
> --- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> +++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> @@ -10,6 +10,7 @@
>  #include <env.h>
>  #include <init.h>
>  #include <hang.h>
> +#include <lmb.h>
>  #include <log.h>
>  #include <net.h>
>  #include <vsprintf.h>
> @@ -1525,8 +1526,8 @@ int dram_init_banksize(void)
>         return 0;
>  }
>
> -#if CONFIG_IS_ENABLED(EFI_LOADER)
> -void efi_add_known_memory(void)
> +#if CONFIG_IS_ENABLED(LMB_ARCH_MEM_MAP)
> +void lmb_arch_add_memory(void)
>  {
>         int i;
>         phys_addr_t ram_start;
> @@ -1548,8 +1549,7 @@ void efi_add_known_memory(void)
>                     gd->arch.resv_ram < ram_start + ram_size)just
>                         ram_size = gd->arch.resv_ram - ram_start;
>  #endif
> -               efi_add_memory_map(ram_start, ram_size,
> -                                  EFI_CONVENTIONAL_MEMORY);
> +               lmb_add(ram_start, ram_size);

But isn't RAM added to lmb anyway? I understand the call-removal but
why the lmb_add() ?

>         }
>  }
>  #endif
> diff --git a/lib/Kconfig b/lib/Kconfig
> index 100c4e5c25..3796adc453 100644
> --- a/lib/Kconfig
> +++ b/lib/Kconfig
> @@ -1135,6 +1135,7 @@ config SPL_LMB
>  config LMB_ARCH_MEM_MAP
>         bool "Add an architecture specific memory map"
>         depends on LMB
> +       default y if FSL_LAYERSCAPE

This should use an event.

>         help
>           Some architectures have special or unique aspects which need
>           consideration when adding memory ranges to the list of available
> --
> 2.34.1
>

Regards,
Simon
Sughosh Ganu Oct. 15, 2024, 9:34 a.m. UTC | #2
On Mon, 14 Oct 2024 at 21:21, Simon Glass <sjg@chromium.org> wrote:
>
> Hi Sughosh,
>
> On Sun, 13 Oct 2024 at 04:56, Sughosh Ganu <sughosh.ganu@linaro.org> wrote:
> >
> > The EFI memory allocations are now being done through the LMB module,
> > and hence the memory map is maintained by the LMB module. Use the
> > lmb_arch_add_memory() API function to add the usable RAM memory to the
> > LMB's memory map.
> >
> > Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> > ---
> > Changes since V2: None
> >
> >  arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 8 ++++----
> >  lib/Kconfig                             | 1 +
> >  2 files changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> > index f9c2083677..d2d3e346a3 100644
> > --- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> > +++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
> > @@ -10,6 +10,7 @@
> >  #include <env.h>
> >  #include <init.h>
> >  #include <hang.h>
> > +#include <lmb.h>
> >  #include <log.h>
> >  #include <net.h>
> >  #include <vsprintf.h>
> > @@ -1525,8 +1526,8 @@ int dram_init_banksize(void)
> >         return 0;
> >  }
> >
> > -#if CONFIG_IS_ENABLED(EFI_LOADER)
> > -void efi_add_known_memory(void)
> > +#if CONFIG_IS_ENABLED(LMB_ARCH_MEM_MAP)
> > +void lmb_arch_add_memory(void)
> >  {
> >         int i;
> >         phys_addr_t ram_start;
> > @@ -1548,8 +1549,7 @@ void efi_add_known_memory(void)
> >                     gd->arch.resv_ram < ram_start + ram_size)just
> >                         ram_size = gd->arch.resv_ram - ram_start;
> >  #endif
> > -               efi_add_memory_map(ram_start, ram_size,
> > -                                  EFI_CONVENTIONAL_MEMORY);
> > +               lmb_add(ram_start, ram_size);
>
> But isn't RAM added to lmb anyway? I understand the call-removal but
> why the lmb_add() ?

This function gets called from lmb_add_memory() since an architecture
specific memory map is enabled for this arch. And in this case, the
addition of lmb memory is the responsibility of this function. So this
code is doing the right thing.


>
> >         }
> >  }
> >  #endif
> > diff --git a/lib/Kconfig b/lib/Kconfig
> > index 100c4e5c25..3796adc453 100644
> > --- a/lib/Kconfig
> > +++ b/lib/Kconfig
> > @@ -1135,6 +1135,7 @@ config SPL_LMB
> >  config LMB_ARCH_MEM_MAP
> >         bool "Add an architecture specific memory map"
> >         depends on LMB
> > +       default y if FSL_LAYERSCAPE
>
> This should use an event.

Again, using this method had been agreed upon by you earlier.

-sughosh

>
> >         help
> >           Some architectures have special or unique aspects which need
> >           consideration when adding memory ranges to the list of available
> > --
> > 2.34.1
> >
>
> Regards,
> Simon
diff mbox series

Patch

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index f9c2083677..d2d3e346a3 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -10,6 +10,7 @@ 
 #include <env.h>
 #include <init.h>
 #include <hang.h>
+#include <lmb.h>
 #include <log.h>
 #include <net.h>
 #include <vsprintf.h>
@@ -1525,8 +1526,8 @@  int dram_init_banksize(void)
 	return 0;
 }
 
-#if CONFIG_IS_ENABLED(EFI_LOADER)
-void efi_add_known_memory(void)
+#if CONFIG_IS_ENABLED(LMB_ARCH_MEM_MAP)
+void lmb_arch_add_memory(void)
 {
 	int i;
 	phys_addr_t ram_start;
@@ -1548,8 +1549,7 @@  void efi_add_known_memory(void)
 		    gd->arch.resv_ram < ram_start + ram_size)
 			ram_size = gd->arch.resv_ram - ram_start;
 #endif
-		efi_add_memory_map(ram_start, ram_size,
-				   EFI_CONVENTIONAL_MEMORY);
+		lmb_add(ram_start, ram_size);
 	}
 }
 #endif
diff --git a/lib/Kconfig b/lib/Kconfig
index 100c4e5c25..3796adc453 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -1135,6 +1135,7 @@  config SPL_LMB
 config LMB_ARCH_MEM_MAP
 	bool "Add an architecture specific memory map"
 	depends on LMB
+	default y if FSL_LAYERSCAPE
 	help
 	  Some architectures have special or unique aspects which need
 	  consideration when adding memory ranges to the list of available