From d3e287405f0a0f9683f9c6c49e84495ea18d9f01 Mon Sep 17 00:00:00 2001 From: Paresh Bhagat Date: Wed, 1 Jul 2026 13:20:18 +0530 Subject: arm: mach-k3: Fix phandle corruption in fdt fixup Fix phandle corruption in fdt_fixup_reserved_memory() The original implementation used a delete/recreate approach: - Find existing reserved memory node (e.g. tfa@80000000) - Delete the entire node with fdt_del_node() - Create new node with fdtdec_add_reserved_memory() This worked fine for ATF and OPTEE nodes because no other device tree nodes reference them via phandles but other nodes example DM are referenced by R5 nodes. If these nodes are deleted and recreated, it will not have any phandle property but the nodes referencing it will still contain the old phandle, causing initialization to fail. Update nodes in-place instead of delete/recreate to update only the "reg" property using fdt_setprop(). Fixes: 8b0fc29de0e3 ("arm: mach-k3: am62: Fixup TF-A/OP-TEE reserved-memory node in FDT") Signed-off-by: Paresh Bhagat Reviewed-by: Neha Malcom Francis Acked-by: Andrew Davis --- arch/arm/mach-k3/common_fdt.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/arch/arm/mach-k3/common_fdt.c b/arch/arm/mach-k3/common_fdt.c index 39cb00c3f43..4b833f5fabe 100644 --- a/arch/arm/mach-k3/common_fdt.c +++ b/arch/arm/mach-k3/common_fdt.c @@ -119,7 +119,6 @@ static int fdt_fixup_reserved_memory(void *blob, const char *name, unsigned int new_size) { int nodeoffset, subnode; - int ret; struct fdt_memory carveout = { .start = new_address, }; @@ -129,43 +128,27 @@ static int fdt_fixup_reserved_memory(void *blob, const char *name, if (nodeoffset < 0) goto add_carveout; - /* Find existing matching subnode and remove it */ + /* Find existing matching subnode and update it in place */ fdt_for_each_subnode(subnode, blob, nodeoffset) { const char *node_name; - fdt_addr_t addr; - fdt_size_t size; + u64 reg[2]; /* Name matching */ node_name = fdt_get_name(blob, subnode, NULL); if (!name) return -EINVAL; if (!strncmp(node_name, name, strlen(name))) { - /* Read out old size first */ - addr = fdtdec_get_addr_size_auto_parent( - blob, nodeoffset, subnode, "reg", 0, &size, - false); - if (addr == FDT_ADDR_T_NONE) - return -EINVAL; - new_size = size; - - /* Delete node */ - ret = fdt_del_node(blob, subnode); - if (ret < 0) - return ret; - - /* Only one matching node */ - break; + /* Update the reg property in place */ + reg[0] = cpu_to_fdt64(new_address); + reg[1] = cpu_to_fdt64(new_size); + return fdt_setprop(blob, subnode, "reg", reg, sizeof(reg)); } } add_carveout: carveout.end = new_address + new_size - 1; - ret = fdtdec_add_reserved_memory(blob, name, &carveout, NULL, 0, NULL, + return fdtdec_add_reserved_memory(blob, name, &carveout, NULL, 0, NULL, FDTDEC_RESERVED_MEMORY_NO_MAP); - if (ret < 0) - return ret; - - return 0; } int fdt_fixup_reserved(void *blob) -- cgit v1.3.1 From f16e4c80040c2d5186ad3cfa83c469b26adbd46f Mon Sep 17 00:00:00 2001 From: Paresh Bhagat Date: Wed, 1 Jul 2026 13:20:19 +0530 Subject: arm: mach-k3: am62ax: Enable OF_SYSTEM_SETUP for AM62D2 Enable OF_SYSTEM_SETUP for AM62D2 to ensure FDT fixups are applied to the dtb before passing to kernel. Signed-off-by: Paresh Bhagat Reviewed-by: Anshul Dalal --- arch/arm/mach-k3/am62ax/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-k3/am62ax/Kconfig b/arch/arm/mach-k3/am62ax/Kconfig index 6a3969343ec..e7c2a2de9be 100644 --- a/arch/arm/mach-k3/am62ax/Kconfig +++ b/arch/arm/mach-k3/am62ax/Kconfig @@ -54,6 +54,7 @@ config TARGET_AM62D2_A53_EVM bool "TI K3 based AM62D2 EVM running on A53" select ARM64 select BINMAN + select OF_SYSTEM_SETUP imply BOARD imply SPL_BOARD imply TI_I2C_BOARD_DETECT -- cgit v1.3.1 From 5e2be9f5ccc4ca3c9cd326d4671a853b783adcae Mon Sep 17 00:00:00 2001 From: Paresh Bhagat Date: Wed, 1 Jul 2026 13:20:20 +0530 Subject: arm: mack-k3: Kconfig: Add DM firmware reserved memory configs Add Kconfig options for DM firmware reserved memory for K3 SOCs that support DM firmware (K3_DM_FW enabled) - K3_DM_FW_RESERVED_ADDR: DM firmware address - K3_DM_FW_RESERVED_SIZE: DM firmware reserved size These configs will be used to fixup the kernel device tree's reserved memory node for DM. Currently the fixup is only done for AM62A7 SoC, as K3_DM_FW_RESERVED_SIZE is being used to update DM reserved memory from 0xf0000 to 0x1f0000 as the current reserved carveout is insufficient to accommodate the binary. For other platforms, the addresses and sizes are based on the existing device tree reserved memory. If needed for other SoCs, address and size could be modified in Kconfig. Signed-off-by: Paresh Bhagat --- arch/arm/mach-k3/Kconfig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arch/arm/mach-k3/Kconfig b/arch/arm/mach-k3/Kconfig index a32ed3a9683..1b6678e72b7 100644 --- a/arch/arm/mach-k3/Kconfig +++ b/arch/arm/mach-k3/Kconfig @@ -165,6 +165,27 @@ config K3_DM_FW bootloader, it makes RM and PM services not being available during R5 SPL execution time. +config K3_DM_FW_RESERVED_ADDR + hex "Start address of DM firmware reserved memory region" + depends on !SOC_K3_AM642 && !SOC_K3_AM654 + default 0x9c900000 if SOC_K3_AM62A7 || SOC_K3_AM62P5 + default 0x9db00000 if SOC_K3_AM625 + default 0xa0100000 if SOC_K3_J721E || SOC_K3_J7200 || SOC_K3_J721S2 || SOC_K3_J722S || SOC_K3_J784S4 + help + Start address of the DDR region reserved for DM firmware at runtime. + Used only to fixup the kernel device-tree reserved-memory node. + +config K3_DM_FW_RESERVED_SIZE + hex "Reserved memory size for DM firmware" + depends on !SOC_K3_AM642 && !SOC_K3_AM654 + default 0x1f00000 if SOC_K3_AM62A7 + default 0xc00000 if SOC_K3_AM625 + default 0x1e00000 if TARGET_VERDIN_AM62P_A53 || TARGET_VERDIN_AM62P_R5 + default 0xf00000 if SOC_K3_AM62P5 || SOC_K3_J721E || SOC_K3_J7200 || SOC_K3_J721S2 || SOC_K3_J722S || SOC_K3_J784S4 + help + The runtime memory size reserved for DM firmware. This is the total + DDR span needed for the DM firmware binary. + config K3_X509_SWRV int "SWRV for X509 certificate used for boot images" default 1 -- cgit v1.3.1 From 0cceea6e449888f4422e674e7157696d382eb686 Mon Sep 17 00:00:00 2001 From: Paresh Bhagat Date: Wed, 1 Jul 2026 13:20:21 +0530 Subject: arm: mach-k3: Add DM reserved memory fixup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for fixing up DM firmware reserved memory in the kernel device tree for K3 SoCs that use separate DM firmware. The fixup uses the CONFIG_K3_DM_FW_RESERVED_ADDR and CONFIG_K3_DM_FW_RESERVED_SIZE Kconfig options to update the reserved-memory node with the correct DM firmware carveout. Note that the fixup needs DM reserved memory node is to be renamed in dts. Example memory@9c900000 → dm@9c900000 Signed-off-by: Paresh Bhagat Reviewed-by: Neha Malcom Francis --- arch/arm/mach-k3/common_fdt.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-k3/common_fdt.c b/arch/arm/mach-k3/common_fdt.c index 4b833f5fabe..18f30e9d052 100644 --- a/arch/arm/mach-k3/common_fdt.c +++ b/arch/arm/mach-k3/common_fdt.c @@ -160,9 +160,23 @@ int fdt_fixup_reserved(void *blob) if (ret) return ret; - return fdt_fixup_reserved_memory(blob, "optee", - CONFIG_K3_OPTEE_LOAD_ADDR, - CONFIG_K3_OPTEE_RESERVED_SIZE); + ret = fdt_fixup_reserved_memory(blob, "optee", + CONFIG_K3_OPTEE_LOAD_ADDR, + CONFIG_K3_OPTEE_RESERVED_SIZE); + + if (ret) + return ret; + +#if defined(CONFIG_K3_DM_FW_RESERVED_ADDR) && defined(CONFIG_K3_DM_FW_RESERVED_SIZE) + ret = fdt_fixup_reserved_memory(blob, "dm", + CONFIG_K3_DM_FW_RESERVED_ADDR, + CONFIG_K3_DM_FW_RESERVED_SIZE); + + if (ret) + return ret; +#endif + + return 0; } static int fdt_fixup_critical_trips(void *blob, int zoneoffset, int maxc) -- cgit v1.3.1