[RFC PATCH v2 09/48] lmb: remove call to lmb_init()

Sughosh Ganu sughosh.ganu at linaro.org
Thu Jul 4 09:35:05 CEST 2024


The LMB module will be changed to have persistent and global memory
maps of available and used memory. With this change, there won't be
any need to explicitly initialise the LMB memory maps. Remove the call
to the lmb_init() function.

Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
---
Changes since V1: New patch

 arch/arm/mach-stm32mp/dram_init.c |  1 -
 board/xilinx/common/board.c       |  1 -
 drivers/iommu/apple_dart.c        |  1 -
 drivers/iommu/sandbox_iommu.c     |  1 -
 include/lmb.h                     |  1 -
 lib/lmb.c                         | 18 ------------------
 test/lib/lmb.c                    | 18 ------------------
 7 files changed, 41 deletions(-)

diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c
index 6024959b97..a5437e4e55 100644
--- a/arch/arm/mach-stm32mp/dram_init.c
+++ b/arch/arm/mach-stm32mp/dram_init.c
@@ -59,7 +59,6 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
 	gd->ram_top = clamp_val(gd->ram_top, 0, SZ_4G - 1);
 
 	/* found enough not-reserved memory to relocated U-Boot */
-	lmb_init(&lmb);
 	lmb_add(&lmb, gd->ram_base, gd->ram_top - gd->ram_base);
 	boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob);
 	/* add 8M for reserved memory for display, fdt, gd,... */
diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 0b43407b9e..61dc37964d 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -684,7 +684,6 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
 		panic("Not 64bit aligned DT location: %p\n", gd->fdt_blob);
 
 	/* found enough not-reserved memory to relocated U-Boot */
-	lmb_init(&lmb);
 	lmb_add(&lmb, gd->ram_base, gd->ram_size);
 	boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob);
 	size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE);
diff --git a/drivers/iommu/apple_dart.c b/drivers/iommu/apple_dart.c
index 9327dea1e3..3e59490973 100644
--- a/drivers/iommu/apple_dart.c
+++ b/drivers/iommu/apple_dart.c
@@ -213,7 +213,6 @@ static int apple_dart_probe(struct udevice *dev)
 	priv->dvabase = DART_PAGE_SIZE;
 	priv->dvaend = SZ_4G - DART_PAGE_SIZE;
 
-	lmb_init(&priv->lmb);
 	lmb_add(&priv->lmb, priv->dvabase, priv->dvaend - priv->dvabase);
 
 	/* Disable translations. */
diff --git a/drivers/iommu/sandbox_iommu.c b/drivers/iommu/sandbox_iommu.c
index e37976f86f..3184b3a64e 100644
--- a/drivers/iommu/sandbox_iommu.c
+++ b/drivers/iommu/sandbox_iommu.c
@@ -54,7 +54,6 @@ static int sandbox_iommu_probe(struct udevice *dev)
 {
 	struct sandbox_iommu_priv *priv = dev_get_priv(dev);
 
-	lmb_init(&priv->lmb);
 	lmb_add(&priv->lmb, 0x89abc000, SZ_16K);
 
 	return 0;
diff --git a/include/lmb.h b/include/lmb.h
index 7b87181b9e..20d6feebf5 100644
--- a/include/lmb.h
+++ b/include/lmb.h
@@ -92,7 +92,6 @@ struct lmb {
 #endif
 };
 
-void lmb_init(struct lmb *lmb);
 void lmb_init_and_reserve(struct lmb *lmb, struct bd_info *bd, void *fdt_blob);
 void lmb_init_and_reserve_range(struct lmb *lmb, phys_addr_t base,
 				phys_size_t size, void *fdt_blob);
diff --git a/lib/lmb.c b/lib/lmb.c
index 4d39c0d1f9..0141da9766 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -130,21 +130,6 @@ static void lmb_fix_over_lap_regions(struct lmb_region *rgn, unsigned long r1,
 	lmb_remove_region(rgn, r2);
 }
 
-void lmb_init(struct lmb *lmb)
-{
-#if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS)
-	lmb->memory.max = CONFIG_LMB_MAX_REGIONS;
-	lmb->reserved.max = CONFIG_LMB_MAX_REGIONS;
-#else
-	lmb->memory.max = CONFIG_LMB_MEMORY_REGIONS;
-	lmb->reserved.max = CONFIG_LMB_RESERVED_REGIONS;
-	lmb->memory.region = lmb->memory_regions;
-	lmb->reserved.region = lmb->reserved_regions;
-#endif
-	lmb->memory.cnt = 0;
-	lmb->reserved.cnt = 0;
-}
-
 void arch_lmb_reserve_generic(struct lmb *lmb, ulong sp, ulong end, ulong align)
 {
 	ulong bank_end;
@@ -231,8 +216,6 @@ void lmb_init_and_reserve(struct lmb *lmb, struct bd_info *bd, void *fdt_blob)
 {
 	int i;
 
-	lmb_init(lmb);
-
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
 		if (bd->bi_dram[i].size) {
 			lmb_add(lmb, bd->bi_dram[i].start,
@@ -247,7 +230,6 @@ void lmb_init_and_reserve(struct lmb *lmb, struct bd_info *bd, void *fdt_blob)
 void lmb_init_and_reserve_range(struct lmb *lmb, phys_addr_t base,
 				phys_size_t size, void *fdt_blob)
 {
-	lmb_init(lmb);
 	lmb_add(lmb, base, size);
 	lmb_reserve_common(lmb, fdt_blob);
 }
diff --git a/test/lib/lmb.c b/test/lib/lmb.c
index 4b5b6e5e20..74e74501cf 100644
--- a/test/lib/lmb.c
+++ b/test/lib/lmb.c
@@ -75,8 +75,6 @@ static int test_multi_alloc(struct unit_test_state *uts, const phys_addr_t ram,
 	ut_assert(alloc_64k_addr >= ram + 8);
 	ut_assert(alloc_64k_end <= ram_end - 8);
 
-	lmb_init(&lmb);
-
 	if (ram0_size) {
 		ret = lmb_add(&lmb, ram0, ram0_size);
 		ut_asserteq(ret, 0);
@@ -236,8 +234,6 @@ static int test_bigblock(struct unit_test_state *uts, const phys_addr_t ram)
 	/* check for overflow */
 	ut_assert(ram_end == 0 || ram_end > ram);
 
-	lmb_init(&lmb);
-
 	ret = lmb_add(&lmb, ram, ram_size);
 	ut_asserteq(ret, 0);
 
@@ -303,8 +299,6 @@ static int test_noreserved(struct unit_test_state *uts, const phys_addr_t ram,
 	/* check for overflow */
 	ut_assert(ram_end == 0 || ram_end > ram);
 
-	lmb_init(&lmb);
-
 	ret = lmb_add(&lmb, ram, ram_size);
 	ut_asserteq(ret, 0);
 	ASSERT_LMB(&lmb, ram, ram_size, 0, 0, 0, 0, 0, 0, 0);
@@ -389,8 +383,6 @@ static int lib_test_lmb_at_0(struct unit_test_state *uts)
 	long ret;
 	phys_addr_t a, b;
 
-	lmb_init(&lmb);
-
 	ret = lmb_add(&lmb, ram, ram_size);
 	ut_asserteq(ret, 0);
 
@@ -428,8 +420,6 @@ static int lib_test_lmb_overlapping_reserve(struct unit_test_state *uts)
 	struct lmb lmb;
 	long ret;
 
-	lmb_init(&lmb);
-
 	ret = lmb_add(&lmb, ram, ram_size);
 	ut_asserteq(ret, 0);
 
@@ -486,8 +476,6 @@ static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram)
 	/* check for overflow */
 	ut_assert(ram_end == 0 || ram_end > ram);
 
-	lmb_init(&lmb);
-
 	ret = lmb_add(&lmb, ram, ram_size);
 	ut_asserteq(ret, 0);
 
@@ -613,8 +601,6 @@ static int test_get_unreserved_size(struct unit_test_state *uts,
 	/* check for overflow */
 	ut_assert(ram_end == 0 || ram_end > ram);
 
-	lmb_init(&lmb);
-
 	ret = lmb_add(&lmb, ram, ram_size);
 	ut_asserteq(ret, 0);
 
@@ -683,8 +669,6 @@ static int lib_test_lmb_max_regions(struct unit_test_state *uts)
 	struct lmb lmb;
 	int ret, i;
 
-	lmb_init(&lmb);
-
 	ut_asserteq(lmb.memory.cnt, 0);
 	ut_asserteq(lmb.memory.max, CONFIG_LMB_MAX_REGIONS);
 	ut_asserteq(lmb.reserved.cnt, 0);
@@ -744,8 +728,6 @@ static int lib_test_lmb_flags(struct unit_test_state *uts)
 	struct lmb lmb;
 	long ret;
 
-	lmb_init(&lmb);
-
 	ret = lmb_add(&lmb, ram, ram_size);
 	ut_asserteq(ret, 0);
 
-- 
2.34.1



More information about the U-Boot mailing list