ti: k3: abstract common fdt api for reserved mem fixups
Subsystems (2)
PATCH v2 1/1 ti: k3: abstract common fdt api for reserved mem fixups
The usage of fdt_fixup_reserved is repeated for ATF and OP-TEE for multiple platforms, this patch creates a single fdt API for fixing up the reserved-memory node with added error handling.
All k3 platforms already share a common tispl template which ensures binaries are loaded as per the respective CONFIG_*_LOAD_ADDR. And the provided new_size for the fixup is overridden by the size from fdt node anyways. This allows for safe abstraction of the reserved memory fixups for all current platforms.
fdt_fixup_reserved now abstracts the ATF and OP-TEE fixups by calling the renamed static fdt_fixup_reserved_memory function with the required parameters.
---
Unlike the other fdt_fixup_* APIs such as fdt_fixup_cores_nodes_am625 which can silently fail and still proceed to a successful kernel boot, the APIs to fix reserved-memory node have to succeed to ensure the kernel doesn't overwrite the TFA and TEE's memory. Which is why we return an int instead of void here.
---
Changes in v2:
- Rebase to next
- Minor fix as per reviewer comments
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/
--- arch/arm/mach-k3/am62ax/am62a7_fdt.c | 5 +---- arch/arm/mach-k3/am62px/am62p5_fdt.c | 4 +--- arch/arm/mach-k3/am62x/am625_fdt.c | 4 +--- arch/arm/mach-k3/common.c | 18 ++++++------------ arch/arm/mach-k3/common_fdt.c | 18 ++++++++++++++++-- arch/arm/mach-k3/include/mach/k3-common-fdt.h | 3 +-- arch/arm/mach-k3/j722s/j722s_fdt.c | 5 +---- 7 files changed, 27 insertions(+), 30 deletions(-)
arch/arm/mach-k3/am62ax/am62a7_fdt.c +1 -4
@@ -9,8 +9,5 @@int ft_system_setup (void *blob,struct bd_info *bd) { -fdt_fixup_reserved (blob,"tfa" ,CONFIG_K3_ATF_LOAD_ADDR ,0x80000 ); -fdt_fixup_reserved (blob,"optee" ,CONFIG_K3_OPTEE_LOAD_ADDR ,0x1800000 ); - -return 0 ; +return fdt_fixup_reserved (blob); }
arch/arm/mach-k3/am62px/am62p5_fdt.c +1 -3
@@ -81,8 +81,6 @@ int ft_system_setup(void *blob, struct bd_info *bd)fdt_fixup_canfd_nodes_am62p (blob,k3_has_canfd ());fdt_fixup_thermal_critical_trips_k3 (blob,k3_get_max_temp ());fdt_fixup_thermal_cooling_device_cpus_am62p (blob,k3_get_core_nr ()); -fdt_fixup_reserved (blob,"tfa" ,CONFIG_K3_ATF_LOAD_ADDR ,0x80000 ); -fdt_fixup_reserved (blob,"optee" ,CONFIG_K3_OPTEE_LOAD_ADDR ,0x1800000 ); -return 0 ; +return fdt_fixup_reserved (blob); }
arch/arm/mach-k3/am62x/am625_fdt.c +1 -3
@@ -80,8 +80,6 @@ int ft_system_setup(void *blob, struct bd_info *bd)fdt_fixup_pru_node_am625 (blob,k3_has_pru ());fdt_fixup_thermal_critical_trips_k3 (blob,k3_get_max_temp ());fdt_fixup_thermal_cooling_device_cpus_am625 (blob,k3_get_core_nr ()); -fdt_fixup_reserved (blob,"tfa" ,CONFIG_K3_ATF_LOAD_ADDR ,0x80000 ); -fdt_fixup_reserved (blob,"optee" ,CONFIG_K3_OPTEE_LOAD_ADDR ,0x1800000 ); -return 0 ; +return fdt_fixup_reserved (blob); }
arch/arm/mach-k3/common.c +6 -12
@@ -273,14 +273,14 @@ void enable_caches(void)if (ret)debug ("%s: Failed to setup dram banks\n" , __func__); + ret =fdt_fixup_reserved (fdt); +if (ret) +printf ("%s: Failed to perform reserved-memory fixups (%s)\n" , + __func__,fdt_strerror (ret)); +mmu_setup ();if (CONFIG_K3_ATF_LOAD_ADDR >=CFG_SYS_SDRAM_BASE ) { - ret =fdt_fixup_reserved (fdt,"tfa" ,CONFIG_K3_ATF_LOAD_ADDR , -0x80000 ); -if (ret) -printf ("%s: Failed to perform tfa fixups (%s)\n" , - __func__,fdt_strerror (ret)); ret =mmu_unmap_reserved_mem ("tfa" , true);if (ret) printf("%s: Failed to unmap tfa reserved mem (%d)\n",
@@ -288,11 +288,6 @@ void enable_caches(void) }if (CONFIG_K3_OPTEE_LOAD_ADDR >=CFG_SYS_SDRAM_BASE ) { - ret =fdt_fixup_reserved (fdt,"optee" , -CONFIG_K3_OPTEE_LOAD_ADDR ,0x1800000 ); -if (ret) -printf ("%s: Failed to perform optee fixups (%s)\n" , - __func__,fdt_strerror (ret)); ret =mmu_unmap_reserved_mem ("optee" , true);if (ret) printf("%s: Failed to unmap optee reserved mem (%d)\n",
@@ -463,8 +458,7 @@ void spl_perform_arch_fixups(struct spl_image_info *spl_image)if (!fdt)return ; -fdt_fixup_reserved (fdt,"tfa" ,CONFIG_K3_ATF_LOAD_ADDR ,0x80000 ); -fdt_fixup_reserved (fdt,"optee" ,CONFIG_K3_OPTEE_LOAD_ADDR ,0x1800000 ); +fdt_fixup_reserved (fdt); }void spl_board_prepare_for_boot (void )
arch/arm/mach-k3/common_fdt.c +16 -2
@@ -114,8 +114,9 @@ int fdt_del_node_path(void *blob, const char *path)return ret; } -int fdt_fixup_reserved (void *blob,const char *name, -unsigned int new_address,unsigned int new_size) +static int fdt_fixup_reserved_memory (void *blob,const char *name, +unsigned int new_address, +unsigned int new_size) {int nodeoffset, subnode;int ret;
@@ -167,6 +168,19 @@ add_carveout:return 0 ; } +int fdt_fixup_reserved (void *blob) +{ +int ret; + + ret =fdt_fixup_reserved_memory (blob,"tfa" ,CONFIG_K3_ATF_LOAD_ADDR , +0x80000 ); +if (ret) +return ret; + +return fdt_fixup_reserved_memory (blob,"optee" , +CONFIG_K3_OPTEE_LOAD_ADDR ,0x1800000 ); +} +static int fdt_fixup_critical_trips (void *blob,int zoneoffset,int maxc) {int node, trip;
arch/arm/mach-k3/include/mach/k3-common-fdt.h +1 -2
@@ -8,8 +8,7 @@int fdt_fixup_msmc_ram_k3 (void *blob);int fdt_del_node_path (void *blob,const char *path); -int fdt_fixup_reserved (void *blob,const char *name, -unsigned int new_address,unsigned int new_size); +int fdt_fixup_reserved (void *blob);void fdt_fixup_thermal_critical_trips_k3 (void *blob,int maxc);#endif /* _K3_COMMON_FDT_H */
arch/arm/mach-k3/j722s/j722s_fdt.c +1 -4
@@ -9,8 +9,5 @@int ft_system_setup (void *blob,struct bd_info *bd) { -fdt_fixup_reserved (blob,"tfa" ,CONFIG_K3_ATF_LOAD_ADDR ,0x80000 ); -fdt_fixup_reserved (blob,"optee" ,CONFIG_K3_OPTEE_LOAD_ADDR ,0x1800000 ); - -return 0 ; +return fdt_fixup_reserved (blob); }
---
base-commit: d300702c5be5a846032834abe4f01dcd3f50b3a8
change-id: 20251204-fdt_refactor-cf1d166a3ae7
Best regards,
Signature · 1 line
Anshul Dalal <[email protected]>
Quoted 11 lines · Anshul Dalal
The usage of
fdt_fixup_reservedis repeated for ATF and OP-TEE for multiple platforms, this patch creates a single fdt API for fixing up the reserved-memory node with added error handling.All k3 platforms already share a common tispl template which ensures binaries are loaded as per the respective CONFIG_*_LOAD_ADDR. And the provided
new_sizefor the fixup is overridden by the size from fdt node anyways. This allows for safe abstraction of the reserved memory fixups for all current platforms.[...]
Applied to u-boot/next, thanks!
[1/1] ti: k3: abstract common fdt api for reserved mem fixups
commit: 6c8dee07c346fcca8f851e18ea554c81f3483d09
Signature · 1 line
Tom