Hi all,

Due to the need to update the commit message, please ignore this patch review 
request.

I will resend an updated version shortly.

Sorry for the inconvenience and thank you for your understanding.

Best regards,
Chunguang Li


NXP Confidential
-----Original Message-----
From: Chunguang Li <[email protected]>
Sent: Thursday, August 13, 2026 10:55 AM
To: [email protected]
Cc: Sahil Malhotra <[email protected]>; Chunguang Li 
<[email protected]>; Andy Tang <[email protected]>; [email protected]
Subject: [PATCH] LFU-1040 layerscape: optee: restore fdt headroom after 
applying overlay

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.

Re-open the blob with extra headroom after packing so the subsequent fixups 
have room to grow. SZ_64K is comfortably larger than the initrd reservation 
plus the /chosen properties and keeps the FDT well within the region that 
boot_relocate_fdt() already allocated.

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

Reply via email to