[PATCH] mach-snapdragon: fix erroneous lmb allocations

Casey Connolly casey.connolly at linaro.org
Mon Aug 11 12:45:13 CEST 2025


In 6e4675b8e5d8 ("lmb: replace the lmb_alloc() and lmb_alloc_base()
API's") an additional allocation was mistakenly introduced resulting
in ${kernel_comp_size} containing the address of a second 64mb region
rather than the actual value of KERNEL_COMP_SIZE.

Additionally, in b40d7b8f72f1 ("Merge patch series "lmb: use a single
API for all allocations"") merge conflict resulted in an additional
128mb allocation for ${loadaddr} when CONFIG_FASTBOOT is enabled, where
it should actually be set to the same value as ${fastboot_addr_r} to
respect size constraints (and since it doesn't seem to interfer with
any bootflows).

Fixup both of these, freeing up 192mb of memory.

Fixes: 6e4675b8e5d8 ("lmb: replace the lmb_alloc() and lmb_alloc_base() API's")
Fixes: b40d7b8f72f1 ("Merge patch series "lmb: use a single API for all allocations"")
Signed-off-by: Casey Connolly <casey.connolly at linaro.org>
---
 arch/arm/mach-snapdragon/board.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c
index fc921a4be269..5fb3240acc5a 100644
--- a/arch/arm/mach-snapdragon/board.c
+++ b/arch/arm/mach-snapdragon/board.c
@@ -533,21 +533,24 @@ int board_late_init(void)
 	status |= !lmb_alloc(SZ_128M, &addr) ?
 		env_set_hex("ramdisk_addr_r", addr) : 1;
 	status |= !lmb_alloc(KERNEL_COMP_SIZE, &addr) ?
 		env_set_hex("kernel_comp_addr_r", addr) : 1;
-	status |= !lmb_alloc(KERNEL_COMP_SIZE, &addr) ?
-		env_set_hex("kernel_comp_size", addr) : 1;
+	status |= env_set_hex("kernel_comp_size", KERNEL_COMP_SIZE);
 	status |= !lmb_alloc(SZ_4M, &addr) ?
 		env_set_hex("scriptaddr", addr) : 1;
 	status |= !lmb_alloc(SZ_4M, &addr) ?
 		env_set_hex("pxefile_addr_r", addr) : 1;
 
 	if (IS_ENABLED(CONFIG_FASTBOOT)) {
 		status |= !lmb_alloc(FASTBOOT_BUF_SIZE, &addr) ?
 			env_set_hex("fastboot_addr_r", addr) : 1;
-		/* override loadaddr for memory rich soc */
-		status |= !lmb_alloc(SZ_128M, &addr) ?
-			env_set_hex("loadaddr", addr) : 1;
+		/*
+		 * Override loadaddr for memory rich soc since ${loadaddr} and
+		 * ${kernel_addr_r} need to be different for the Android boot image
+		 * flow. It's typically safe for ${loadaddr} to be the same address
+		 * as the fastboot buffer.
+		 */
+		status |= env_set_hex("loadaddr", addr);
 	}
 
 	fdt_status |= !lmb_alloc(SZ_2M, &addr) ?
 		env_set_hex("fdt_addr_r", addr) : 1;
-- 
2.50.1



More information about the U-Boot mailing list