diff mbox series

[18/40] lmb: remove the lmb_init_and_reserve() function

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

Commit Message

Sughosh Ganu July 24, 2024, 6:02 a.m. UTC
With the changes to make the LMB reservations persistent, the common
memory regions are being added during board init. Remove the
now superfluous lmb_init_and_reserve() function.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
Changes since rfc: None

 arch/arm/mach-apple/board.c          |  2 --
 arch/arm/mach-snapdragon/board.c     |  2 --
 arch/arm/mach-stm32mp/stm32mp1/cpu.c |  3 ---
 cmd/bdinfo.c                         |  1 -
 cmd/load.c                           |  2 --
 fs/fs.c                              |  1 -
 include/lmb.h                        |  1 -
 lib/lmb.c                            | 13 -------------
 net/tftp.c                           |  2 --
 net/wget.c                           |  2 --
 test/cmd/bdinfo.c                    |  9 ---------
 11 files changed, 38 deletions(-)

Comments

Caleb Connolly Aug. 15, 2024, 4:44 p.m. UTC | #1
Hi,

On 24/07/2024 08:02, Sughosh Ganu wrote:
> With the changes to make the LMB reservations persistent, the common
> memory regions are being added during board init. Remove the
> now superfluous lmb_init_and_reserve() function.

This patch comes before the patches doing these reservations in generic 
code. I think this could break bisecting.

Could you instead make the switch over to the generic code atomic?

Kind regards,
> 
> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> ---
> Changes since rfc: None
> 
>   arch/arm/mach-apple/board.c          |  2 --
>   arch/arm/mach-snapdragon/board.c     |  2 --
>   arch/arm/mach-stm32mp/stm32mp1/cpu.c |  3 ---
>   cmd/bdinfo.c                         |  1 -
>   cmd/load.c                           |  2 --
>   fs/fs.c                              |  1 -
>   include/lmb.h                        |  1 -
>   lib/lmb.c                            | 13 -------------
>   net/tftp.c                           |  2 --
>   net/wget.c                           |  2 --
>   test/cmd/bdinfo.c                    |  9 ---------
>   11 files changed, 38 deletions(-)
> 
> diff --git a/arch/arm/mach-apple/board.c b/arch/arm/mach-apple/board.c
> index 213390d6e8..0b6d290b8a 100644
> --- a/arch/arm/mach-apple/board.c
> +++ b/arch/arm/mach-apple/board.c
> @@ -775,8 +775,6 @@ int board_late_init(void)
>   {
>   	u32 status = 0;
>   
> -	lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> -
>   	/* somewhat based on the Linux Kernel boot requirements:
>   	 * align by 2M and maximal FDT size 2M
>   	 */
> diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c
> index a63c8bec45..22a7d2a637 100644
> --- a/arch/arm/mach-snapdragon/board.c
> +++ b/arch/arm/mach-snapdragon/board.c
> @@ -282,8 +282,6 @@ int board_late_init(void)
>   {
>   	u32 status = 0;
>   
> -	lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> -
>   	/* We need to be fairly conservative here as we support boards with just 1G of TOTAL RAM */
>   	status |= env_set_hex("kernel_addr_r", addr_alloc(SZ_128M));
>   	status |= env_set_hex("ramdisk_addr_r", addr_alloc(SZ_128M));
> diff --git a/arch/arm/mach-stm32mp/stm32mp1/cpu.c b/arch/arm/mach-stm32mp/stm32mp1/cpu.c
> index a913737342..64480da9f8 100644
> --- a/arch/arm/mach-stm32mp/stm32mp1/cpu.c
> +++ b/arch/arm/mach-stm32mp/stm32mp1/cpu.c
> @@ -141,9 +141,6 @@ int mach_cpu_init(void)
>   
>   void enable_caches(void)
>   {
> -	/* parse device tree when data cache is still activated */
> -	lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> -
>   	/* I-cache is already enabled in start.S: icache_enable() not needed */
>   
>   	/* deactivate the data cache, early enabled in arch_cpu_init() */
> diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
> index b31e0208df..3c40dee143 100644
> --- a/cmd/bdinfo.c
> +++ b/cmd/bdinfo.c
> @@ -162,7 +162,6 @@ static int bdinfo_print_all(struct bd_info *bd)
>   	bdinfo_print_num_l("multi_dtb_fit", (ulong)gd->multi_dtb_fit);
>   #endif
>   	if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) {
> -		lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
>   		lmb_dump_all_force();
>   		if (IS_ENABLED(CONFIG_OF_REAL))
>   			printf("devicetree  = %s\n", fdtdec_get_srcname());
> diff --git a/cmd/load.c b/cmd/load.c
> index 56da3a4c5d..20d802502a 100644
> --- a/cmd/load.c
> +++ b/cmd/load.c
> @@ -153,8 +153,6 @@ static ulong load_serial(long offset)
>   	int	line_count =  0;
>   	long ret;
>   
> -	lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> -
>   	while (read_record(record, SREC_MAXRECLEN + 1) >= 0) {
>   		type = srec_decode(record, &binlen, &addr, binbuf);
>   
> diff --git a/fs/fs.c b/fs/fs.c
> index 3fb00590be..4bc28d1dff 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -549,7 +549,6 @@ static int fs_read_lmb_check(const char *filename, ulong addr, loff_t offset,
>   	if (len && len < read_len)
>   		read_len = len;
>   
> -	lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
>   	lmb_dump_all();
>   
>   	if (lmb_alloc_addr(addr, read_len) == addr)
> diff --git a/include/lmb.h b/include/lmb.h
> index 77e2a23c0d..50977e6561 100644
> --- a/include/lmb.h
> +++ b/include/lmb.h
> @@ -37,7 +37,6 @@ struct lmb_region {
>   	enum lmb_flags flags;
>   };
>   
> -void lmb_init_and_reserve(struct bd_info *bd, void *fdt_blob);
>   void lmb_init_and_reserve_range(phys_addr_t base, phys_size_t size,
>   				void *fdt_blob);
>   
> diff --git a/lib/lmb.c b/lib/lmb.c
> index db0874371a..f1142033ef 100644
> --- a/lib/lmb.c
> +++ b/lib/lmb.c
> @@ -226,19 +226,6 @@ static void lmb_reserve_common(void *fdt_blob)
>   		efi_lmb_reserve();
>   }
>   
> -/* Initialize the struct, add memory and call arch/board reserve functions */
> -void lmb_init_and_reserve(struct bd_info *bd, void *fdt_blob)
> -{
> -	int i;
> -
> -	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
> -		if (bd->bi_dram[i].size)
> -			lmb_add(bd->bi_dram[i].start, bd->bi_dram[i].size);
> -	}
> -
> -	lmb_reserve_common(fdt_blob);
> -}
> -
>   /**
>    * lmb_add_memory() - Add memory range for LMB allocations
>    *
> diff --git a/net/tftp.c b/net/tftp.c
> index f841f6b701..9b1f06ba8e 100644
> --- a/net/tftp.c
> +++ b/net/tftp.c
> @@ -711,8 +711,6 @@ static int tftp_init_load_addr(void)
>   	if (CONFIG_IS_ENABLED(LMB)) {
>   		phys_size_t max_size;
>   
> -		lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> -
>   		max_size = lmb_get_free_size(image_load_addr);
>   		if (!max_size)
>   			return -1;
> diff --git a/net/wget.c b/net/wget.c
> index b8ea43e7f0..82a7e30ea7 100644
> --- a/net/wget.c
> +++ b/net/wget.c
> @@ -75,8 +75,6 @@ static int wget_init_load_size(void)
>   {
>   	phys_size_t max_size;
>   
> -	lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> -
>   	max_size = lmb_get_free_size(image_load_addr);
>   	if (!max_size)
>   		return -1;
> diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c
> index 34d2b141d8..1cd81a195b 100644
> --- a/test/cmd/bdinfo.c
> +++ b/test/cmd/bdinfo.c
> @@ -113,14 +113,6 @@ static int lmb_test_dump_region(struct unit_test_state *uts,
>   		end = base + size - 1;
>   		flags = rgn->region[i].flags;
>   
> -		/*
> -		 * this entry includes the stack (get_sp()) on many platforms
> -		 * so will different each time lmb_init_and_reserve() is called.
> -		 * We could instead have the bdinfo command put its lmb region
> -		 * in a known location, so we can check it directly, rather than
> -		 * calling lmb_init_and_reserve() to create a new (and hopefully
> -		 * identical one). But for now this seems good enough.
> -		 */
>   		if (!IS_ENABLED(CONFIG_SANDBOX) && i == 3) {
>   			ut_assert_nextlinen(" %s[%d]\t[", name, i);
>   			continue;
> @@ -200,7 +192,6 @@ static int bdinfo_test_all(struct unit_test_state *uts)
>   	if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) {
>   		struct lmb lmb;
>   
> -		lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
>   		ut_assertok(lmb_test_dump_all(uts, &lmb));
>   		if (IS_ENABLED(CONFIG_OF_REAL))
>   			ut_assert_nextline("devicetree  = %s", fdtdec_get_srcname());
Simon Glass Aug. 15, 2024, 8:33 p.m. UTC | #2
On Thu, 15 Aug 2024 at 17:44, Caleb Connolly <caleb.connolly@linaro.org> wrote:
>
> Hi,
>
> On 24/07/2024 08:02, Sughosh Ganu wrote:
> > With the changes to make the LMB reservations persistent, the common
> > memory regions are being added during board init. Remove the
> > now superfluous lmb_init_and_reserve() function.
>
> This patch comes before the patches doing these reservations in generic
> code. I think this could break bisecting.
>
> Could you instead make the switch over to the generic code atomic?

+1


>
> Kind regards,
> >
> > Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> > Reviewed-by: Simon Glass <sjg@chromium.org>
> > Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> > ---
> > Changes since rfc: None
> >
> >   arch/arm/mach-apple/board.c          |  2 --
> >   arch/arm/mach-snapdragon/board.c     |  2 --
> >   arch/arm/mach-stm32mp/stm32mp1/cpu.c |  3 ---
> >   cmd/bdinfo.c                         |  1 -
> >   cmd/load.c                           |  2 --
> >   fs/fs.c                              |  1 -
> >   include/lmb.h                        |  1 -
> >   lib/lmb.c                            | 13 -------------
> >   net/tftp.c                           |  2 --
> >   net/wget.c                           |  2 --
> >   test/cmd/bdinfo.c                    |  9 ---------
> >   11 files changed, 38 deletions(-)
> >
> > diff --git a/arch/arm/mach-apple/board.c b/arch/arm/mach-apple/board.c
> > index 213390d6e8..0b6d290b8a 100644
> > --- a/arch/arm/mach-apple/board.c
> > +++ b/arch/arm/mach-apple/board.c
> > @@ -775,8 +775,6 @@ int board_late_init(void)
> >   {
> >       u32 status = 0;
> >
> > -     lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> > -
> >       /* somewhat based on the Linux Kernel boot requirements:
> >        * align by 2M and maximal FDT size 2M
> >        */
> > diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c
> > index a63c8bec45..22a7d2a637 100644
> > --- a/arch/arm/mach-snapdragon/board.c
> > +++ b/arch/arm/mach-snapdragon/board.c
> > @@ -282,8 +282,6 @@ int board_late_init(void)
> >   {
> >       u32 status = 0;
> >
> > -     lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> > -
> >       /* We need to be fairly conservative here as we support boards with just 1G of TOTAL RAM */
> >       status |= env_set_hex("kernel_addr_r", addr_alloc(SZ_128M));
> >       status |= env_set_hex("ramdisk_addr_r", addr_alloc(SZ_128M));
> > diff --git a/arch/arm/mach-stm32mp/stm32mp1/cpu.c b/arch/arm/mach-stm32mp/stm32mp1/cpu.c
> > index a913737342..64480da9f8 100644
> > --- a/arch/arm/mach-stm32mp/stm32mp1/cpu.c
> > +++ b/arch/arm/mach-stm32mp/stm32mp1/cpu.c
> > @@ -141,9 +141,6 @@ int mach_cpu_init(void)
> >
> >   void enable_caches(void)
> >   {
> > -     /* parse device tree when data cache is still activated */
> > -     lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> > -
> >       /* I-cache is already enabled in start.S: icache_enable() not needed */
> >
> >       /* deactivate the data cache, early enabled in arch_cpu_init() */
> > diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
> > index b31e0208df..3c40dee143 100644
> > --- a/cmd/bdinfo.c
> > +++ b/cmd/bdinfo.c
> > @@ -162,7 +162,6 @@ static int bdinfo_print_all(struct bd_info *bd)
> >       bdinfo_print_num_l("multi_dtb_fit", (ulong)gd->multi_dtb_fit);
> >   #endif
> >       if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) {
> > -             lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> >               lmb_dump_all_force();
> >               if (IS_ENABLED(CONFIG_OF_REAL))
> >                       printf("devicetree  = %s\n", fdtdec_get_srcname());
> > diff --git a/cmd/load.c b/cmd/load.c
> > index 56da3a4c5d..20d802502a 100644
> > --- a/cmd/load.c
> > +++ b/cmd/load.c
> > @@ -153,8 +153,6 @@ static ulong load_serial(long offset)
> >       int     line_count =  0;
> >       long ret;
> >
> > -     lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> > -
> >       while (read_record(record, SREC_MAXRECLEN + 1) >= 0) {
> >               type = srec_decode(record, &binlen, &addr, binbuf);
> >
> > diff --git a/fs/fs.c b/fs/fs.c
> > index 3fb00590be..4bc28d1dff 100644
> > --- a/fs/fs.c
> > +++ b/fs/fs.c
> > @@ -549,7 +549,6 @@ static int fs_read_lmb_check(const char *filename, ulong addr, loff_t offset,
> >       if (len && len < read_len)
> >               read_len = len;
> >
> > -     lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> >       lmb_dump_all();
> >
> >       if (lmb_alloc_addr(addr, read_len) == addr)
> > diff --git a/include/lmb.h b/include/lmb.h
> > index 77e2a23c0d..50977e6561 100644
> > --- a/include/lmb.h
> > +++ b/include/lmb.h
> > @@ -37,7 +37,6 @@ struct lmb_region {
> >       enum lmb_flags flags;
> >   };
> >
> > -void lmb_init_and_reserve(struct bd_info *bd, void *fdt_blob);
> >   void lmb_init_and_reserve_range(phys_addr_t base, phys_size_t size,
> >                               void *fdt_blob);
> >
> > diff --git a/lib/lmb.c b/lib/lmb.c
> > index db0874371a..f1142033ef 100644
> > --- a/lib/lmb.c
> > +++ b/lib/lmb.c
> > @@ -226,19 +226,6 @@ static void lmb_reserve_common(void *fdt_blob)
> >               efi_lmb_reserve();
> >   }
> >
> > -/* Initialize the struct, add memory and call arch/board reserve functions */
> > -void lmb_init_and_reserve(struct bd_info *bd, void *fdt_blob)
> > -{
> > -     int i;
> > -
> > -     for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
> > -             if (bd->bi_dram[i].size)
> > -                     lmb_add(bd->bi_dram[i].start, bd->bi_dram[i].size);
> > -     }
> > -
> > -     lmb_reserve_common(fdt_blob);
> > -}
> > -
> >   /**
> >    * lmb_add_memory() - Add memory range for LMB allocations
> >    *
> > diff --git a/net/tftp.c b/net/tftp.c
> > index f841f6b701..9b1f06ba8e 100644
> > --- a/net/tftp.c
> > +++ b/net/tftp.c
> > @@ -711,8 +711,6 @@ static int tftp_init_load_addr(void)
> >       if (CONFIG_IS_ENABLED(LMB)) {
> >               phys_size_t max_size;
> >
> > -             lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> > -
> >               max_size = lmb_get_free_size(image_load_addr);
> >               if (!max_size)
> >                       return -1;
> > diff --git a/net/wget.c b/net/wget.c
> > index b8ea43e7f0..82a7e30ea7 100644
> > --- a/net/wget.c
> > +++ b/net/wget.c
> > @@ -75,8 +75,6 @@ static int wget_init_load_size(void)
> >   {
> >       phys_size_t max_size;
> >
> > -     lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> > -
> >       max_size = lmb_get_free_size(image_load_addr);
> >       if (!max_size)
> >               return -1;
> > diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c
> > index 34d2b141d8..1cd81a195b 100644
> > --- a/test/cmd/bdinfo.c
> > +++ b/test/cmd/bdinfo.c
> > @@ -113,14 +113,6 @@ static int lmb_test_dump_region(struct unit_test_state *uts,
> >               end = base + size - 1;
> >               flags = rgn->region[i].flags;
> >
> > -             /*
> > -              * this entry includes the stack (get_sp()) on many platforms
> > -              * so will different each time lmb_init_and_reserve() is called.
> > -              * We could instead have the bdinfo command put its lmb region
> > -              * in a known location, so we can check it directly, rather than
> > -              * calling lmb_init_and_reserve() to create a new (and hopefully
> > -              * identical one). But for now this seems good enough.
> > -              */
> >               if (!IS_ENABLED(CONFIG_SANDBOX) && i == 3) {
> >                       ut_assert_nextlinen(" %s[%d]\t[", name, i);
> >                       continue;
> > @@ -200,7 +192,6 @@ static int bdinfo_test_all(struct unit_test_state *uts)
> >       if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) {
> >               struct lmb lmb;
> >
> > -             lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> >               ut_assertok(lmb_test_dump_all(uts, &lmb));
> >               if (IS_ENABLED(CONFIG_OF_REAL))
> >                       ut_assert_nextline("devicetree  = %s", fdtdec_get_srcname());
>
> --
> // Caleb (they/them)
Sughosh Ganu Aug. 16, 2024, 10:28 a.m. UTC | #3
On Thu, 15 Aug 2024 at 22:14, Caleb Connolly <caleb.connolly@linaro.org> wrote:
>
> Hi,
>
> On 24/07/2024 08:02, Sughosh Ganu wrote:
> > With the changes to make the LMB reservations persistent, the common
> > memory regions are being added during board init. Remove the
> > now superfluous lmb_init_and_reserve() function.
>
> This patch comes before the patches doing these reservations in generic
> code. I think this could break bisecting.
>
> Could you instead make the switch over to the generic code atomic?

Yes, I will flip the order of the patches such that the patches remain
bisectable. Thanks.

-sughosh

>
> Kind regards,
> >
> > Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> > Reviewed-by: Simon Glass <sjg@chromium.org>
> > Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> > ---
> > Changes since rfc: None
> >
> >   arch/arm/mach-apple/board.c          |  2 --
> >   arch/arm/mach-snapdragon/board.c     |  2 --
> >   arch/arm/mach-stm32mp/stm32mp1/cpu.c |  3 ---
> >   cmd/bdinfo.c                         |  1 -
> >   cmd/load.c                           |  2 --
> >   fs/fs.c                              |  1 -
> >   include/lmb.h                        |  1 -
> >   lib/lmb.c                            | 13 -------------
> >   net/tftp.c                           |  2 --
> >   net/wget.c                           |  2 --
> >   test/cmd/bdinfo.c                    |  9 ---------
> >   11 files changed, 38 deletions(-)
> >
> > diff --git a/arch/arm/mach-apple/board.c b/arch/arm/mach-apple/board.c
> > index 213390d6e8..0b6d290b8a 100644
> > --- a/arch/arm/mach-apple/board.c
> > +++ b/arch/arm/mach-apple/board.c
> > @@ -775,8 +775,6 @@ int board_late_init(void)
> >   {
> >       u32 status = 0;
> >
> > -     lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> > -
> >       /* somewhat based on the Linux Kernel boot requirements:
> >        * align by 2M and maximal FDT size 2M
> >        */
> > diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c
> > index a63c8bec45..22a7d2a637 100644
> > --- a/arch/arm/mach-snapdragon/board.c
> > +++ b/arch/arm/mach-snapdragon/board.c
> > @@ -282,8 +282,6 @@ int board_late_init(void)
> >   {
> >       u32 status = 0;
> >
> > -     lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> > -
> >       /* We need to be fairly conservative here as we support boards with just 1G of TOTAL RAM */
> >       status |= env_set_hex("kernel_addr_r", addr_alloc(SZ_128M));
> >       status |= env_set_hex("ramdisk_addr_r", addr_alloc(SZ_128M));
> > diff --git a/arch/arm/mach-stm32mp/stm32mp1/cpu.c b/arch/arm/mach-stm32mp/stm32mp1/cpu.c
> > index a913737342..64480da9f8 100644
> > --- a/arch/arm/mach-stm32mp/stm32mp1/cpu.c
> > +++ b/arch/arm/mach-stm32mp/stm32mp1/cpu.c
> > @@ -141,9 +141,6 @@ int mach_cpu_init(void)
> >
> >   void enable_caches(void)
> >   {
> > -     /* parse device tree when data cache is still activated */
> > -     lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> > -
> >       /* I-cache is already enabled in start.S: icache_enable() not needed */
> >
> >       /* deactivate the data cache, early enabled in arch_cpu_init() */
> > diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
> > index b31e0208df..3c40dee143 100644
> > --- a/cmd/bdinfo.c
> > +++ b/cmd/bdinfo.c
> > @@ -162,7 +162,6 @@ static int bdinfo_print_all(struct bd_info *bd)
> >       bdinfo_print_num_l("multi_dtb_fit", (ulong)gd->multi_dtb_fit);
> >   #endif
> >       if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) {
> > -             lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> >               lmb_dump_all_force();
> >               if (IS_ENABLED(CONFIG_OF_REAL))
> >                       printf("devicetree  = %s\n", fdtdec_get_srcname());
> > diff --git a/cmd/load.c b/cmd/load.c
> > index 56da3a4c5d..20d802502a 100644
> > --- a/cmd/load.c
> > +++ b/cmd/load.c
> > @@ -153,8 +153,6 @@ static ulong load_serial(long offset)
> >       int     line_count =  0;
> >       long ret;
> >
> > -     lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> > -
> >       while (read_record(record, SREC_MAXRECLEN + 1) >= 0) {
> >               type = srec_decode(record, &binlen, &addr, binbuf);
> >
> > diff --git a/fs/fs.c b/fs/fs.c
> > index 3fb00590be..4bc28d1dff 100644
> > --- a/fs/fs.c
> > +++ b/fs/fs.c
> > @@ -549,7 +549,6 @@ static int fs_read_lmb_check(const char *filename, ulong addr, loff_t offset,
> >       if (len && len < read_len)
> >               read_len = len;
> >
> > -     lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> >       lmb_dump_all();
> >
> >       if (lmb_alloc_addr(addr, read_len) == addr)
> > diff --git a/include/lmb.h b/include/lmb.h
> > index 77e2a23c0d..50977e6561 100644
> > --- a/include/lmb.h
> > +++ b/include/lmb.h
> > @@ -37,7 +37,6 @@ struct lmb_region {
> >       enum lmb_flags flags;
> >   };
> >
> > -void lmb_init_and_reserve(struct bd_info *bd, void *fdt_blob);
> >   void lmb_init_and_reserve_range(phys_addr_t base, phys_size_t size,
> >                               void *fdt_blob);
> >
> > diff --git a/lib/lmb.c b/lib/lmb.c
> > index db0874371a..f1142033ef 100644
> > --- a/lib/lmb.c
> > +++ b/lib/lmb.c
> > @@ -226,19 +226,6 @@ static void lmb_reserve_common(void *fdt_blob)
> >               efi_lmb_reserve();
> >   }
> >
> > -/* Initialize the struct, add memory and call arch/board reserve functions */
> > -void lmb_init_and_reserve(struct bd_info *bd, void *fdt_blob)
> > -{
> > -     int i;
> > -
> > -     for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
> > -             if (bd->bi_dram[i].size)
> > -                     lmb_add(bd->bi_dram[i].start, bd->bi_dram[i].size);
> > -     }
> > -
> > -     lmb_reserve_common(fdt_blob);
> > -}
> > -
> >   /**
> >    * lmb_add_memory() - Add memory range for LMB allocations
> >    *
> > diff --git a/net/tftp.c b/net/tftp.c
> > index f841f6b701..9b1f06ba8e 100644
> > --- a/net/tftp.c
> > +++ b/net/tftp.c
> > @@ -711,8 +711,6 @@ static int tftp_init_load_addr(void)
> >       if (CONFIG_IS_ENABLED(LMB)) {
> >               phys_size_t max_size;
> >
> > -             lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> > -
> >               max_size = lmb_get_free_size(image_load_addr);
> >               if (!max_size)
> >                       return -1;
> > diff --git a/net/wget.c b/net/wget.c
> > index b8ea43e7f0..82a7e30ea7 100644
> > --- a/net/wget.c
> > +++ b/net/wget.c
> > @@ -75,8 +75,6 @@ static int wget_init_load_size(void)
> >   {
> >       phys_size_t max_size;
> >
> > -     lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> > -
> >       max_size = lmb_get_free_size(image_load_addr);
> >       if (!max_size)
> >               return -1;
> > diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c
> > index 34d2b141d8..1cd81a195b 100644
> > --- a/test/cmd/bdinfo.c
> > +++ b/test/cmd/bdinfo.c
> > @@ -113,14 +113,6 @@ static int lmb_test_dump_region(struct unit_test_state *uts,
> >               end = base + size - 1;
> >               flags = rgn->region[i].flags;
> >
> > -             /*
> > -              * this entry includes the stack (get_sp()) on many platforms
> > -              * so will different each time lmb_init_and_reserve() is called.
> > -              * We could instead have the bdinfo command put its lmb region
> > -              * in a known location, so we can check it directly, rather than
> > -              * calling lmb_init_and_reserve() to create a new (and hopefully
> > -              * identical one). But for now this seems good enough.
> > -              */
> >               if (!IS_ENABLED(CONFIG_SANDBOX) && i == 3) {
> >                       ut_assert_nextlinen(" %s[%d]\t[", name, i);
> >                       continue;
> > @@ -200,7 +192,6 @@ static int bdinfo_test_all(struct unit_test_state *uts)
> >       if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) {
> >               struct lmb lmb;
> >
> > -             lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
> >               ut_assertok(lmb_test_dump_all(uts, &lmb));
> >               if (IS_ENABLED(CONFIG_OF_REAL))
> >                       ut_assert_nextline("devicetree  = %s", fdtdec_get_srcname());
>
> --
> // Caleb (they/them)
diff mbox series

Patch

diff --git a/arch/arm/mach-apple/board.c b/arch/arm/mach-apple/board.c
index 213390d6e8..0b6d290b8a 100644
--- a/arch/arm/mach-apple/board.c
+++ b/arch/arm/mach-apple/board.c
@@ -775,8 +775,6 @@  int board_late_init(void)
 {
 	u32 status = 0;
 
-	lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
-
 	/* somewhat based on the Linux Kernel boot requirements:
 	 * align by 2M and maximal FDT size 2M
 	 */
diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c
index a63c8bec45..22a7d2a637 100644
--- a/arch/arm/mach-snapdragon/board.c
+++ b/arch/arm/mach-snapdragon/board.c
@@ -282,8 +282,6 @@  int board_late_init(void)
 {
 	u32 status = 0;
 
-	lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
-
 	/* We need to be fairly conservative here as we support boards with just 1G of TOTAL RAM */
 	status |= env_set_hex("kernel_addr_r", addr_alloc(SZ_128M));
 	status |= env_set_hex("ramdisk_addr_r", addr_alloc(SZ_128M));
diff --git a/arch/arm/mach-stm32mp/stm32mp1/cpu.c b/arch/arm/mach-stm32mp/stm32mp1/cpu.c
index a913737342..64480da9f8 100644
--- a/arch/arm/mach-stm32mp/stm32mp1/cpu.c
+++ b/arch/arm/mach-stm32mp/stm32mp1/cpu.c
@@ -141,9 +141,6 @@  int mach_cpu_init(void)
 
 void enable_caches(void)
 {
-	/* parse device tree when data cache is still activated */
-	lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
-
 	/* I-cache is already enabled in start.S: icache_enable() not needed */
 
 	/* deactivate the data cache, early enabled in arch_cpu_init() */
diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index b31e0208df..3c40dee143 100644
--- a/cmd/bdinfo.c
+++ b/cmd/bdinfo.c
@@ -162,7 +162,6 @@  static int bdinfo_print_all(struct bd_info *bd)
 	bdinfo_print_num_l("multi_dtb_fit", (ulong)gd->multi_dtb_fit);
 #endif
 	if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) {
-		lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
 		lmb_dump_all_force();
 		if (IS_ENABLED(CONFIG_OF_REAL))
 			printf("devicetree  = %s\n", fdtdec_get_srcname());
diff --git a/cmd/load.c b/cmd/load.c
index 56da3a4c5d..20d802502a 100644
--- a/cmd/load.c
+++ b/cmd/load.c
@@ -153,8 +153,6 @@  static ulong load_serial(long offset)
 	int	line_count =  0;
 	long ret;
 
-	lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
-
 	while (read_record(record, SREC_MAXRECLEN + 1) >= 0) {
 		type = srec_decode(record, &binlen, &addr, binbuf);
 
diff --git a/fs/fs.c b/fs/fs.c
index 3fb00590be..4bc28d1dff 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -549,7 +549,6 @@  static int fs_read_lmb_check(const char *filename, ulong addr, loff_t offset,
 	if (len && len < read_len)
 		read_len = len;
 
-	lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
 	lmb_dump_all();
 
 	if (lmb_alloc_addr(addr, read_len) == addr)
diff --git a/include/lmb.h b/include/lmb.h
index 77e2a23c0d..50977e6561 100644
--- a/include/lmb.h
+++ b/include/lmb.h
@@ -37,7 +37,6 @@  struct lmb_region {
 	enum lmb_flags flags;
 };
 
-void lmb_init_and_reserve(struct bd_info *bd, void *fdt_blob);
 void lmb_init_and_reserve_range(phys_addr_t base, phys_size_t size,
 				void *fdt_blob);
 
diff --git a/lib/lmb.c b/lib/lmb.c
index db0874371a..f1142033ef 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -226,19 +226,6 @@  static void lmb_reserve_common(void *fdt_blob)
 		efi_lmb_reserve();
 }
 
-/* Initialize the struct, add memory and call arch/board reserve functions */
-void lmb_init_and_reserve(struct bd_info *bd, void *fdt_blob)
-{
-	int i;
-
-	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
-		if (bd->bi_dram[i].size)
-			lmb_add(bd->bi_dram[i].start, bd->bi_dram[i].size);
-	}
-
-	lmb_reserve_common(fdt_blob);
-}
-
 /**
  * lmb_add_memory() - Add memory range for LMB allocations
  *
diff --git a/net/tftp.c b/net/tftp.c
index f841f6b701..9b1f06ba8e 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -711,8 +711,6 @@  static int tftp_init_load_addr(void)
 	if (CONFIG_IS_ENABLED(LMB)) {
 		phys_size_t max_size;
 
-		lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
-
 		max_size = lmb_get_free_size(image_load_addr);
 		if (!max_size)
 			return -1;
diff --git a/net/wget.c b/net/wget.c
index b8ea43e7f0..82a7e30ea7 100644
--- a/net/wget.c
+++ b/net/wget.c
@@ -75,8 +75,6 @@  static int wget_init_load_size(void)
 {
 	phys_size_t max_size;
 
-	lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
-
 	max_size = lmb_get_free_size(image_load_addr);
 	if (!max_size)
 		return -1;
diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c
index 34d2b141d8..1cd81a195b 100644
--- a/test/cmd/bdinfo.c
+++ b/test/cmd/bdinfo.c
@@ -113,14 +113,6 @@  static int lmb_test_dump_region(struct unit_test_state *uts,
 		end = base + size - 1;
 		flags = rgn->region[i].flags;
 
-		/*
-		 * this entry includes the stack (get_sp()) on many platforms
-		 * so will different each time lmb_init_and_reserve() is called.
-		 * We could instead have the bdinfo command put its lmb region
-		 * in a known location, so we can check it directly, rather than
-		 * calling lmb_init_and_reserve() to create a new (and hopefully
-		 * identical one). But for now this seems good enough.
-		 */
 		if (!IS_ENABLED(CONFIG_SANDBOX) && i == 3) {
 			ut_assert_nextlinen(" %s[%d]\t[", name, i);
 			continue;
@@ -200,7 +192,6 @@  static int bdinfo_test_all(struct unit_test_state *uts)
 	if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) {
 		struct lmb lmb;
 
-		lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
 		ut_assertok(lmb_test_dump_all(uts, &lmb));
 		if (IS_ENABLED(CONFIG_OF_REAL))
 			ut_assert_nextline("devicetree  = %s", fdtdec_get_srcname());