diff mbox series

[v2,17/32] lmb: init: initialise the lmb data structures during board init

Message ID 20240814110009.45310-18-sughosh.ganu@linaro.org
State Superseded
Headers show
Series Make LMB memory map global and persistent | expand

Commit Message

Sughosh Ganu Aug. 14, 2024, 10:59 a.m. UTC
The memory map maintained by the LMB module is now persistent and
global. This memory map is being maintained through the alloced list
structure which can be extended at runtime -- there is one list for
the available memory, and one for the used memory. Allocate and
initialise these lists during the board init.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
Changes since V1:
* Move the initr_lmb() function to board_r.c
* Call lmb_init() from spl.c instead of initr_lmb().

 common/board_r.c | 17 +++++++++++++++++
 common/spl/spl.c |  3 +++
 2 files changed, 20 insertions(+)

Comments

Simon Glass Aug. 15, 2024, 8:34 p.m. UTC | #1
Hi Sughosh,

On Wed, 14 Aug 2024 at 12:01, Sughosh Ganu <sughosh.ganu@linaro.org> wrote:
>
> The memory map maintained by the LMB module is now persistent and
> global. This memory map is being maintained through the alloced list
> structure which can be extended at runtime -- there is one list for
> the available memory, and one for the used memory. Allocate and
> initialise these lists during the board init.
>
> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> ---
> Changes since V1:
> * Move the initr_lmb() function to board_r.c
> * Call lmb_init() from spl.c instead of initr_lmb().
>
>  common/board_r.c | 17 +++++++++++++++++
>  common/spl/spl.c |  3 +++
>  2 files changed, 20 insertions(+)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

nit below

> diff --git a/common/board_r.c b/common/board_r.c
> index f445803d7a..0943ed3d01 100644
> --- a/common/board_r.c
> +++ b/common/board_r.c
> @@ -22,6 +22,7 @@
>  #include <hang.h>
>  #include <image.h>
>  #include <irq_func.h>
> +#include <lmb.h>
>  #include <log.h>
>  #include <net.h>
>  #include <asm/cache.h>
> @@ -510,6 +511,21 @@ int initr_mem(void)
>  }
>  #endif
>
> +static int initr_lmb(void)
> +{
> +#if CONFIG_IS_ENABLED(LMB)

This should use if()

> +       int ret;
> +
> +       ret = lmb_init();
> +       if (ret)
> +               printf("Unable to initialise the LMB data structures\n");
> +
> +       return ret;
> +#else
> +       return 0;
> +#endif
> +}
> +
>  static int dm_announce(void)
>  {
>         int device_count;
> @@ -612,6 +628,7 @@ static init_fnc_t init_sequence_r[] = {
>  #ifdef CONFIG_CLOCKS
>         set_cpu_clk_info, /* Setup clock information */
>  #endif
> +       initr_lmb,
>  #ifdef CONFIG_EFI_LOADER
>         efi_memory_init,
>  #endif
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index d6a364de6e..4102e25115 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -723,6 +723,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>             IS_ENABLED(CONFIG_SPL_ATF))
>                 dram_init_banksize();
>
> +       if (IS_ENABLED(CONFIG_SPL_LMB))
> +               lmb_init();
> +
>         if (CONFIG_IS_ENABLED(PCI) && !(gd->flags & GD_FLG_DM_DEAD)) {
>                 ret = pci_init();
>                 if (ret)
> --
> 2.34.1
>

Regards,
Simon
diff mbox series

Patch

diff --git a/common/board_r.c b/common/board_r.c
index f445803d7a..0943ed3d01 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -22,6 +22,7 @@ 
 #include <hang.h>
 #include <image.h>
 #include <irq_func.h>
+#include <lmb.h>
 #include <log.h>
 #include <net.h>
 #include <asm/cache.h>
@@ -510,6 +511,21 @@  int initr_mem(void)
 }
 #endif
 
+static int initr_lmb(void)
+{
+#if CONFIG_IS_ENABLED(LMB)
+	int ret;
+
+	ret = lmb_init();
+	if (ret)
+		printf("Unable to initialise the LMB data structures\n");
+
+	return ret;
+#else
+	return 0;
+#endif
+}
+
 static int dm_announce(void)
 {
 	int device_count;
@@ -612,6 +628,7 @@  static init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_CLOCKS
 	set_cpu_clk_info, /* Setup clock information */
 #endif
+	initr_lmb,
 #ifdef CONFIG_EFI_LOADER
 	efi_memory_init,
 #endif
diff --git a/common/spl/spl.c b/common/spl/spl.c
index d6a364de6e..4102e25115 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -723,6 +723,9 @@  void board_init_r(gd_t *dummy1, ulong dummy2)
 	    IS_ENABLED(CONFIG_SPL_ATF))
 		dram_init_banksize();
 
+	if (IS_ENABLED(CONFIG_SPL_LMB))
+		lmb_init();
+
 	if (CONFIG_IS_ENABLED(PCI) && !(gd->flags & GD_FLG_DM_DEAD)) {
 		ret = pci_init();
 		if (ret)