[RFC PATCH v2 20/48] lmb: reserve common areas during board init
Sughosh Ganu
sughosh.ganu at linaro.org
Thu Jul 4 09:35:16 CEST 2024
The LMB module provides API's for allocating and reserving chunks of
memory which is then typically used for things like loading images for
booting. Reserve the portion of memory that is occupied by the U-Boot
image itself, and other parts of memory that might have been marked as
reserved in the board's DTB.
Mark these regions of memory with the LMB_NOOVERWRITE flag to indicate
that these regions cannot be re-requested or overwritten.
Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
---
Changes since V1:
* Mark the reserved regions as LMB_NOOVERWRITE.
* Call the lmb_reserve_common() function in U-Boot proper after
relocation.
lib/lmb.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/lmb.c b/lib/lmb.c
index e1dde14a3c..456b64c00a 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -13,6 +13,7 @@
#include <lmb.h>
#include <log.h>
#include <malloc.h>
+#include <spl.h>
#include <asm/global_data.h>
#include <asm/sections.h>
@@ -173,10 +174,11 @@ void arch_lmb_reserve_generic(ulong sp, ulong end, ulong align)
if (bank_end > end)
bank_end = end - 1;
- lmb_reserve(sp, bank_end - sp + 1);
+ lmb_reserve_flags(sp, bank_end - sp + 1, LMB_NOOVERWRITE);
if (gd->flags & GD_FLG_SKIP_RELOC)
- lmb_reserve((phys_addr_t)(uintptr_t)_start, gd->mon_len);
+ lmb_reserve_flags((phys_addr_t)(uintptr_t)_start,
+ gd->mon_len, LMB_NOOVERWRITE);
break;
}
@@ -739,5 +741,9 @@ int lmb_mem_regions_init(void)
lmb_add_memory();
+ /* Reserve the U-Boot image region once U-Boot has relocated */
+ if (spl_phase() == PHASE_BOARD_R)
+ lmb_reserve_common((void *)gd->fdt_blob);
+
return 0;
}
--
2.34.1
More information about the U-Boot
mailing list