Skip to contentSkip to conversation

arm: mach-k3: use Kconfig options for ATF/OPTEE size

PATCH Superseded Anshul Dalal 6 participants 7 messages Mar 10 – Mar 12

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: mach-k3: use Kconfig options for ATF/OPTEE size

The reserved memory sizes for ATF and OPTEE were hard-coded for K3 devices, this patch replaces them with a Kconfig option allowing for easier modifications.

---
 arch/arm/dts/k3-binman.dtsi   |  4 ++--
 arch/arm/mach-k3/Kconfig      | 15 +++++++++++++++
 arch/arm/mach-k3/common_fdt.c |  5 +++--
 3 files changed, 20 insertions(+), 4 deletions(-)
arch/arm/dts/k3-binman.dtsi +2 -2
index 0fd93f9536a..ad127663d03 100644
@@ -477,7 +477,7 @@
 						FWPERM_SECURE_PRIV_RWCD |
 						FWPERM_SECURE_USER_RWCD)>;
 		start_address = <0x0 CONFIG_K3_ATF_LOAD_ADDR>;
-		end_address = <0x0 (CONFIG_K3_ATF_LOAD_ADDR + 0x1ffff)>;
+		end_address = <0x0 (CONFIG_K3_ATF_LOAD_ADDR + CONFIG_K3_ATF_RESERVED_SIZE - 1)>;
 	};
 	firewall_armv8_optee_fg: template-8 {
 		control = <(FWCTRL_EN | FWCTRL_LOCK |
@@ -486,7 +486,7 @@
 						FWPERM_SECURE_PRIV_RWCD |
 						FWPERM_SECURE_USER_RWCD)>;
 		start_address = <0x0 CONFIG_K3_OPTEE_LOAD_ADDR>;
-		end_address = <0x0 (CONFIG_K3_OPTEE_LOAD_ADDR + 0x17fffff)>;
+		end_address = <0x0 (CONFIG_K3_OPTEE_LOAD_ADDR + CONFIG_K3_OPTEE_RESERVED_SIZE - 1)>;
 	};
 
 	ti_falcon_template: template-9 {
arch/arm/mach-k3/Kconfig +15 -0
index 1b8c0b1eb96..ba1130a7996 100644
@@ -130,6 +130,14 @@ config K3_ATF_LOAD_ADDR
 	  The load address for the ATF image. This value is used to build the
 	  FIT image header that places ATF in memory where it will run.
 
+config K3_ATF_RESERVED_SIZE
+	hex "Reserved DDR size for ATF"
+	default 0x80000 if (SOC_K3_AM625 || SOC_K3_AM62A7 || SOC_K3_AM62P5 || SOC_K3_J722S)
+	default 0x20000
+	help
+	  The runtime DDR size reserved for ATF. This value is used to fixup the
+	  kernel device-tree's reserved-memory node for ATF.
+
 config K3_OPTEE_LOAD_ADDR
 	hex "Load address of OPTEE image"
 	default 0x9e800000
@@ -137,6 +145,13 @@ config K3_OPTEE_LOAD_ADDR
 	  The load address for the OPTEE image. This value defaults to 0x9e800000
 	  if not provided in the board defconfig file.
 
+config K3_OPTEE_RESERVED_SIZE
+	hex "Reserved DDR size for OPTEE"
+	default 0x1800000
+	help
+	  The runtime DDR size reserved for OPTEE. This value is used to fixup the
+	  kernel device-tree's reserved-memory node for OPTEE.
+
 config K3_DM_FW
 	bool "Separate DM firmware image"
 	depends on CPU_V7R && !SOC_K3_AM642 && !SOC_K3_AM654 && !CLK_TI_SCI && !TI_SCI_POWER_DOMAIN
arch/arm/mach-k3/common_fdt.c +3 -2
index cb0fb8274a5..39cb00c3f43 100644
@@ -173,12 +173,13 @@ int fdt_fixup_reserved(void *blob)
 	int ret;
 
 	ret = fdt_fixup_reserved_memory(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR,
-					0x80000);
+					CONFIG_K3_ATF_RESERVED_SIZE);
 	if (ret)
 		return ret;
 
 	return fdt_fixup_reserved_memory(blob, "optee",
-					 CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
+					 CONFIG_K3_OPTEE_LOAD_ADDR,
+					 CONFIG_K3_OPTEE_RESERVED_SIZE);
 }
 
 static int fdt_fixup_critical_trips(void *blob, int zoneoffset, int maxc)

---
base-commit: 1e240f7206fccde4ec73ea432ab8360d321c5fe5
change-id: 20260310-tfa_tee_addr_kconfig_refactor-2bf77949df0f

Best regards,

Signature · 1 line
Anshul Dalal <[email protected]>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Anshul Dalal

The reserved memory sizes for ATF and OPTEE were hard-coded for K3 devices, this patch replaces them with a Kconfig option allowing for easier modifications.

---

Looks good to me in general,

Quoted 89 lines
 arch/arm/dts/k3-binman.dtsi   |  4 ++--
 arch/arm/mach-k3/Kconfig      | 15 +++++++++++++++
 arch/arm/mach-k3/common_fdt.c |  5 +++--
 3 files changed, 20 insertions(+), 4 deletions(-)
arch/arm/dts/k3-binman.dtsi +2 -2
index 0fd93f9536a..ad127663d03 100644
@@ -477,7 +477,7 @@
 						FWPERM_SECURE_PRIV_RWCD |
 						FWPERM_SECURE_USER_RWCD)>;
 		start_address = <0x0 CONFIG_K3_ATF_LOAD_ADDR>;
-		end_address = <0x0 (CONFIG_K3_ATF_LOAD_ADDR + 0x1ffff)>;
+		end_address = <0x0 (CONFIG_K3_ATF_LOAD_ADDR + CONFIG_K3_ATF_RESERVED_SIZE - 1)>;
 	};
 	firewall_armv8_optee_fg: template-8 {
 		control = <(FWCTRL_EN | FWCTRL_LOCK |
@@ -486,7 +486,7 @@
 						FWPERM_SECURE_PRIV_RWCD |
 						FWPERM_SECURE_USER_RWCD)>;
 		start_address = <0x0 CONFIG_K3_OPTEE_LOAD_ADDR>;
-		end_address = <0x0 (CONFIG_K3_OPTEE_LOAD_ADDR + 0x17fffff)>;
+		end_address = <0x0 (CONFIG_K3_OPTEE_LOAD_ADDR + CONFIG_K3_OPTEE_RESERVED_SIZE - 1)>;
 	};
 
 	ti_falcon_template: template-9 {
arch/arm/mach-k3/Kconfig +15 -0
index 1b8c0b1eb96..ba1130a7996 100644
@@ -130,6 +130,14 @@ config K3_ATF_LOAD_ADDR
 	  The load address for the ATF image. This value is used to build the
 	  FIT image header that places ATF in memory where it will run.
 
+config K3_ATF_RESERVED_SIZE
+	hex "Reserved DDR size for ATF"
+	default 0x80000 if (SOC_K3_AM625 || SOC_K3_AM62A7 || SOC_K3_AM62P5 || SOC_K3_J722S)
+	default 0x20000
+	help
+	  The runtime DDR size reserved for ATF. This value is used to fixup the
+	  kernel device-tree's reserved-memory node for ATF.
+
 config K3_OPTEE_LOAD_ADDR
 	hex "Load address of OPTEE image"
 	default 0x9e800000
@@ -137,6 +145,13 @@ config K3_OPTEE_LOAD_ADDR
 	  The load address for the OPTEE image. This value defaults to 0x9e800000
 	  if not provided in the board defconfig file.
 
+config K3_OPTEE_RESERVED_SIZE
+	hex "Reserved DDR size for OPTEE"
+	default 0x1800000
+	help
+	  The runtime DDR size reserved for OPTEE. This value is used to fixup the
+	  kernel device-tree's reserved-memory node for OPTEE.
+
 config K3_DM_FW
 	bool "Separate DM firmware image"
 	depends on CPU_V7R && !SOC_K3_AM642 && !SOC_K3_AM654 && !CLK_TI_SCI && !TI_SCI_POWER_DOMAIN
arch/arm/mach-k3/common_fdt.c +3 -3
index cb0fb8274a5..39cb00c3f43 100644
@@ -173,12 +173,13 @@ int fdt_fixup_reserved(void *blob)
 	int ret;
 
 	ret = fdt_fixup_reserved_memory(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR,
-					0x80000);
+					CONFIG_K3_ATF_RESERVED_SIZE);
 	if (ret)
 		return ret;
 
 	return fdt_fixup_reserved_memory(blob, "optee",
-					 CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
+					 CONFIG_K3_OPTEE_LOAD_ADDR,
+					 CONFIG_K3_OPTEE_RESERVED_SIZE);
 }
 
 static int fdt_fixup_critical_trips(void *blob, int zoneoffset, int maxc)
 
---

base-commit: 1e240f7206fccde4ec73ea432ab8360d321c5fe5
change-id: 20260310-tfa_tee_addr_kconfig_refactor-2bf77949df0f

Best regards,

Signature · 1 line
Anshul Dalal <[email protected]>
Signature · 3 lines
Best regards,
Dhruva Gole
Texas Instruments Incorporated
Acked-by on v1 1/1
#2 lore raw
In reply to Anshul Dalal
Quoted 38 lines · Anshul Dalal

The reserved memory sizes for ATF and OPTEE were hard-coded for K3 devices, this patch replaces them with a Kconfig option allowing for easier modifications.

---
  arch/arm/dts/k3-binman.dtsi   |  4 ++--
  arch/arm/mach-k3/Kconfig      | 15 +++++++++++++++
  arch/arm/mach-k3/common_fdt.c |  5 +++--
  3 files changed, 20 insertions(+), 4 deletions(-)
arch/arm/dts/k3-binman.dtsi +2 -2
index 0fd93f9536a..ad127663d03 100644
@@ -477,7 +477,7 @@
  						FWPERM_SECURE_PRIV_RWCD |
  						FWPERM_SECURE_USER_RWCD)>;
  		start_address = <0x0 CONFIG_K3_ATF_LOAD_ADDR>;
-		end_address = <0x0 (CONFIG_K3_ATF_LOAD_ADDR + 0x1ffff)>;
+		end_address = <0x0 (CONFIG_K3_ATF_LOAD_ADDR + CONFIG_K3_ATF_RESERVED_SIZE - 1)>;
  	};
  	firewall_armv8_optee_fg: template-8 {
  		control = <(FWCTRL_EN | FWCTRL_LOCK |
@@ -486,7 +486,7 @@
  						FWPERM_SECURE_PRIV_RWCD |
  						FWPERM_SECURE_USER_RWCD)>;
  		start_address = <0x0 CONFIG_K3_OPTEE_LOAD_ADDR>;
-		end_address = <0x0 (CONFIG_K3_OPTEE_LOAD_ADDR + 0x17fffff)>;
+		end_address = <0x0 (CONFIG_K3_OPTEE_LOAD_ADDR + CONFIG_K3_OPTEE_RESERVED_SIZE - 1)>;
  	};
 
  	ti_falcon_template: template-9 {
arch/arm/mach-k3/Kconfig +0 -0
index 1b8c0b1eb96..ba1130a7996 100644

arch/arm/mach-k3/Kconfig config K3_ATF_LOAD_ADDR · line 139

Quoted 10 lines
arch/arm/mach-k3/Kconfig +7 -0
@@ -130,6 +130,14 @@ config K3_ATF_LOAD_ADDR
  	  The load address for the ATF image. This value is used to build the
  	  FIT image header that places ATF in memory where it will run.
 
+config K3_ATF_RESERVED_SIZE
+	hex "Reserved DDR size for ATF"
+	default 0x80000 if (SOC_K3_AM625 || SOC_K3_AM62A7 || SOC_K3_AM62P5 || SOC_K3_J722S)
+	default 0x20000
+	help
+	  The runtime DDR size reserved for ATF. This value is used to fixup the
+	  kernel device-tree's reserved-memory node for ATF.

This does more than just fixing up the DT. It also sets the size of the firewall in the boot certificate, which is much more important. If this is set smaller than the real size of ATF then some of it might remain un-firewalled.

Same below for OPTEE. Otherwise, LGTM,

Quoted 44 lines
arch/arm/mach-k3/Kconfig +8 -0
+
  config K3_OPTEE_LOAD_ADDR
  	hex "Load address of OPTEE image"
  	default 0x9e800000
@@ -137,6 +145,13 @@ config K3_OPTEE_LOAD_ADDR
  	  The load address for the OPTEE image. This value defaults to 0x9e800000
  	  if not provided in the board defconfig file.
 
+config K3_OPTEE_RESERVED_SIZE
+	hex "Reserved DDR size for OPTEE"
+	default 0x1800000
+	help
+	  The runtime DDR size reserved for OPTEE. This value is used to fixup the
+	  kernel device-tree's reserved-memory node for OPTEE.
+
  config K3_DM_FW
  	bool "Separate DM firmware image"
  	depends on CPU_V7R && !SOC_K3_AM642 && !SOC_K3_AM654 && !CLK_TI_SCI && !TI_SCI_POWER_DOMAIN
arch/arm/mach-k3/common_fdt.c +3 -3
index cb0fb8274a5..39cb00c3f43 100644
@@ -173,12 +173,13 @@ int fdt_fixup_reserved(void *blob)
  	int ret;
 
  	ret = fdt_fixup_reserved_memory(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR,
-					0x80000);
+					CONFIG_K3_ATF_RESERVED_SIZE);
  	if (ret)
  		return ret;
 
  	return fdt_fixup_reserved_memory(blob, "optee",
-					 CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
+					 CONFIG_K3_OPTEE_LOAD_ADDR,
+					 CONFIG_K3_OPTEE_RESERVED_SIZE);
  }
 
  static int fdt_fixup_critical_trips(void *blob, int zoneoffset, int maxc)
 
---

base-commit: 1e240f7206fccde4ec73ea432ab8360d321c5fe5
change-id: 20260310-tfa_tee_addr_kconfig_refactor-2bf77949df0f

Best regards,

#3 lore raw
Quoted 52 lines · Andrew Davis
Quoted 37 lines · Anshul Dalal

The reserved memory sizes for ATF and OPTEE were hard-coded for K3 devices, this patch replaces them with a Kconfig option allowing for easier modifications.

---
  arch/arm/dts/k3-binman.dtsi   |  4 ++--
  arch/arm/mach-k3/Kconfig      | 15 +++++++++++++++
  arch/arm/mach-k3/common_fdt.c |  5 +++--
  3 files changed, 20 insertions(+), 4 deletions(-)
arch/arm/dts/k3-binman.dtsi +2 -2
index 0fd93f9536a..ad127663d03 100644
@@ -477,7 +477,7 @@
  						FWPERM_SECURE_PRIV_RWCD |
  						FWPERM_SECURE_USER_RWCD)>;
  		start_address = <0x0 CONFIG_K3_ATF_LOAD_ADDR>;
-		end_address = <0x0 (CONFIG_K3_ATF_LOAD_ADDR + 0x1ffff)>;
+		end_address = <0x0 (CONFIG_K3_ATF_LOAD_ADDR + CONFIG_K3_ATF_RESERVED_SIZE - 1)>;
  	};
  	firewall_armv8_optee_fg: template-8 {
  		control = <(FWCTRL_EN | FWCTRL_LOCK |
@@ -486,7 +486,7 @@
  						FWPERM_SECURE_PRIV_RWCD |
  						FWPERM_SECURE_USER_RWCD)>;
  		start_address = <0x0 CONFIG_K3_OPTEE_LOAD_ADDR>;
-		end_address = <0x0 (CONFIG_K3_OPTEE_LOAD_ADDR + 0x17fffff)>;
+		end_address = <0x0 (CONFIG_K3_OPTEE_LOAD_ADDR + CONFIG_K3_OPTEE_RESERVED_SIZE - 1)>;
  	};
  	ti_falcon_template: template-9 {
arch/arm/mach-k3/Kconfig +0 -0
index 1b8c0b1eb96..ba1130a7996 100644

arch/arm/mach-k3/Kconfig config K3_ATF_LOAD_ADDR · line 138

Quoted 9 lines
arch/arm/mach-k3/Kconfig +7 -0
@@ -130,6 +130,14 @@ config K3_ATF_LOAD_ADDR
  	  The load address for the ATF image. This value is used to build the
  	  FIT image header that places ATF in memory where it will run.
+config K3_ATF_RESERVED_SIZE
+	hex "Reserved DDR size for ATF"
+	default 0x80000 if (SOC_K3_AM625 || SOC_K3_AM62A7 || SOC_K3_AM62P5 || SOC_K3_J722S)
+	default 0x20000
+	help
+	  The runtime DDR size reserved for ATF. This value is used to fixup the
+	  kernel device-tree's reserved-memory node for ATF.

This does more than just fixing up the DT. It also sets the size of the firewall in the boot certificate, which is much more important. If this is set smaller than the real size of ATF then some of it might remain un-firewalled.

Quoted 3 lines

Same below for OPTEE. Otherwise, LGTM,

To be clear, I'll expect a v2 that at least updates the help text and also updates anything relevant under doc/board/ as well. Thanks!

Signature · 1 line
Tom
#4 lore raw
In reply to Anshul Dalal
Quoted 5 lines · Anshul Dalal

The reserved memory sizes for ATF and OPTEE were hard-coded for K3 devices, this patch replaces them with a Kconfig option allowing for easier modifications.

...

arch/arm/mach-k3/Kconfig config K3_ATF_LOAD_ADDR · line 136

Quoted 12 lines
arch/arm/mach-k3/Kconfig +4 -0
index 1b8c0b1eb96..ba1130a7996 100644
@@ -130,6 +130,14 @@ config K3_ATF_LOAD_ADDR
 	  The load address for the ATF image. This value is used to build the
 	  FIT image header that places ATF in memory where it will run.
 
+config K3_ATF_RESERVED_SIZE
+	hex "Reserved DDR size for ATF"
+	default 0x80000 if (SOC_K3_AM625 || SOC_K3_AM62A7 || SOC_K3_AM62P5 || SOC_K3_J722S)
+	default 0x20000

This means that J784S4 has 0x20000? Is this wanted?

Francesco

#5 lore raw
Quoted 17 lines · Francesco Dolcini
Quoted 5 lines · Anshul Dalal

The reserved memory sizes for ATF and OPTEE were hard-coded for K3 devices, this patch replaces them with a Kconfig option allowing for easier modifications.

...

Quoted 8 lines
arch/arm/mach-k3/Kconfig +0 -0
index 1b8c0b1eb96..ba1130a7996 100644
@@ -130,6 +130,14 @@ config K3_ATF_LOAD_ADDR
 	  The load address for the ATF image. This value is used to build the
 	  FIT image header that places ATF in memory where it will run.
 
Quoted 6 lines

arch/arm/mach-k3/Kconfig config K3_ATF_LOAD_ADDR · line 136

Quoted 4 lines
arch/arm/mach-k3/Kconfig +4 -0
+config K3_ATF_RESERVED_SIZE
+	hex "Reserved DDR size for ATF"
+	default 0x80000 if (SOC_K3_AM625 || SOC_K3_AM62A7 || SOC_K3_AM62P5 || SOC_K3_J722S)
+	default 0x20000

This means that J784S4 has 0x20000? Is this wanted?

As per the DT[1], J784S4 also has 0x20000 bytes reserved for TFA.

[1]: https://github.com/torvalds/linux/blob/b29fb8829bff243512bb8c8908fd39406f9fd4c3/arch/arm64/boot/dts/ti/k3-j784s4-j742s2-main-common.dtsi#L36

Quoted 2 lines

Francesco

#6 lore raw
In reply to Anshul Dalal

On March 10, 2026 thus sayeth Anshul Dalal:

Quoted 53 lines

The reserved memory sizes for ATF and OPTEE were hard-coded for K3 devices, this patch replaces them with a Kconfig option allowing for easier modifications.

---
 arch/arm/dts/k3-binman.dtsi   |  4 ++--
 arch/arm/mach-k3/Kconfig      | 15 +++++++++++++++
 arch/arm/mach-k3/common_fdt.c |  5 +++--
 3 files changed, 20 insertions(+), 4 deletions(-)
arch/arm/dts/k3-binman.dtsi +2 -2
index 0fd93f9536a..ad127663d03 100644
@@ -477,7 +477,7 @@
 						FWPERM_SECURE_PRIV_RWCD |
 						FWPERM_SECURE_USER_RWCD)>;
 		start_address = <0x0 CONFIG_K3_ATF_LOAD_ADDR>;
-		end_address = <0x0 (CONFIG_K3_ATF_LOAD_ADDR + 0x1ffff)>;
+		end_address = <0x0 (CONFIG_K3_ATF_LOAD_ADDR + CONFIG_K3_ATF_RESERVED_SIZE - 1)>;
 	};
 	firewall_armv8_optee_fg: template-8 {
 		control = <(FWCTRL_EN | FWCTRL_LOCK |
@@ -486,7 +486,7 @@
 						FWPERM_SECURE_PRIV_RWCD |
 						FWPERM_SECURE_USER_RWCD)>;
 		start_address = <0x0 CONFIG_K3_OPTEE_LOAD_ADDR>;
-		end_address = <0x0 (CONFIG_K3_OPTEE_LOAD_ADDR + 0x17fffff)>;
+		end_address = <0x0 (CONFIG_K3_OPTEE_LOAD_ADDR + CONFIG_K3_OPTEE_RESERVED_SIZE - 1)>;
 	};
 
 	ti_falcon_template: template-9 {
arch/arm/mach-k3/Kconfig +8 -0
index 1b8c0b1eb96..ba1130a7996 100644
@@ -130,6 +130,14 @@ config K3_ATF_LOAD_ADDR
 	  The load address for the ATF image. This value is used to build the
 	  FIT image header that places ATF in memory where it will run.
 
+config K3_ATF_RESERVED_SIZE
+	hex "Reserved DDR size for ATF"
+	default 0x80000 if (SOC_K3_AM625 || SOC_K3_AM62A7 || SOC_K3_AM62P5 || SOC_K3_J722S)
+	default 0x20000
+	help
+	  The runtime DDR size reserved for ATF. This value is used to fixup the
+	  kernel device-tree's reserved-memory node for ATF.
+
 config K3_OPTEE_LOAD_ADDR
 	hex "Load address of OPTEE image"
 	default 0x9e800000

arch/arm/mach-k3/Kconfig config K3_OPTEE_LOAD_ADDR · line 152

Quoted 8 lines
arch/arm/mach-k3/Kconfig +5 -0
@@ -137,6 +145,13 @@ config K3_OPTEE_LOAD_ADDR
 	  The load address for the OPTEE image. This value defaults to 0x9e800000
 	  if not provided in the board defconfig file.
 
+config K3_OPTEE_RESERVED_SIZE
+	hex "Reserved DDR size for OPTEE"
+	default 0x1800000
+	help
+	  The runtime DDR size reserved for OPTEE. This value is used to fixup the

Only the devices which do not have enough on chip RAM (AM62*) will put TFA and OP-TEE in DDR.

~Bryan