[PATCH] layerscape: optee: remove fdt_pack() after applying overlay

Chunguang Li <[email protected]>
Newsgroups gmane.comp.boot-loaders.u-boot.general,gmane.comp.boot-loaders.u-boot
Message-ID <[email protected]>
From: Andy Tang <[email protected]>

When CONFIG_OPTEE is enabled on Layerscape boards, ft_add_optee_overlay()
applies the OP-TEE device-tree overlay to the kernel FDT and then calls
fdt_pack(). fdt_pack() shrinks the blob to its exact used size, which
discards the CONFIG_SYS_FDT_PAD free space that boot_relocate_fdt() had
reserved at the end of the FDT.

Later in the bootm flow fdt_initrd() inserts a memory reservation for the
ramdisk (fdt_add_mem_rsv) and writes the linux,initrd-start/-end
properties into /chosen. Without any spare space in the packed blob these
operations fail with:

    fdt_initrd: FDT_ERR_NOSPACE
     - must RESET the board to recover.

This only happens on OP-TEE builds because the overlay path is the only
caller of fdt_pack() in the FDT fixup sequence.

Remove the fdt_pack() call so that the free space reserved by
boot_relocate_fdt() is preserved and subsequent fixups have room to grow.

Signed-off-by: Andy Tang <[email protected]>
Signed-off-by: Chunguang.Li <[email protected]>
---
 arch/arm/cpu/armv8/fsl-layerscape/dt_optee.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/dt_optee.c b/arch/arm/cpu/armv8/fsl-layerscape/dt_optee.c
index 3345e6d61f1..e1d3dcda30a 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/dt_optee.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/dt_optee.c
@@ -30,7 +30,6 @@ int ft_add_optee_overlay(void *fdt, struct bd_info *bd)
 			ret = fdt_overlay_apply_verbose(fdt, (void *)(rom_pointer[2] + SZ_1M));
 			if (ret == 0) {
 				debug("Overlay applied with success");
-				fdt_pack(fdt);
 			}
 		} else {
 			printf("DTB overlay not present, exiting without applying\n");
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.