Skip to contentSkip to conversation

board: stm32mp1: fix handling of DT OP-TEE reserved memory nodes

PATCH New Patrick Delaunay 2 participants 6 messages Jun 5, 2020 – Jun 16, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 board: stm32mp1: fix handling of DT OP-TEE reserved memory nodes

From: Etienne Carriere <[email protected]>

Fix the sequence in stm32mp1 fdt.c that disables OP-TEE resources defined in FDT when U-boot detects OP-TEE firmware is not present.

Before this change, helper function stm32_fdt_disable_optee() set property status to "disabled" for the OP-TEE reserved memory nodes but this has no impact since Linux kernel does not consider the status property for reserved-memory subnodes. This change make U-Boot to attempt to delete the node instead.

Fixes 4a1b975dac02 ("board: stm32mp1: reserve memory for OP-TEE in device tree")

---

 arch/arm/mach-stm32mp/fdt.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
arch/arm/mach-stm32mp/fdt.c +9 -5
index c723b223e0..959f12efe1 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
 /*
- * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
+ * Copyright (C) 2019-2020, STMicroelectronics - All Rights Reserved
  */
 
 #include <common.h>
@@ -224,19 +224,23 @@ static void stm32_fdt_disable_optee(void *blob)
 {
 	int off, node;
 
+	/* Delete "optee" firmware node */
 	off = fdt_node_offset_by_compatible(blob, -1, "linaro,optee-tz");
 	if (off >= 0 && fdtdec_get_is_enabled(blob, off))
-		fdt_status_disabled(blob, off);
+		fdt_del_node(blob, off);
 
-	/* Disabled "optee at ..." reserved-memory node */
+	/* Delete "optee at ..." reserved-memory node */
 	off = fdt_path_offset(blob, "/reserved-memory/");
 	if (off < 0)
 		return;
 	for (node = fdt_first_subnode(blob, off);
 	     node >= 0;
 	     node = fdt_next_subnode(blob, node)) {
-		if (!strncmp(fdt_get_name(blob, node, NULL), "optee@", 6))
-			fdt_status_disabled(blob, node);
+		if (strncmp(fdt_get_name(blob, node, NULL), "optee@", 6))
+			continue;
+
+		if (fdt_del_node(blob, node))
+			printf("Failed to remove optee reserved-memory node\n");
 	}
 }
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 board: stm32mp1: fix handling of DT OP-TEE reserved memory nodes

Hi,

Quoted 13 lines

From: Patrick DELAUNAY <[email protected]>
Sent: vendredi 5 juin 2020 09:24

From: Etienne Carriere <[email protected]>

Fix the sequence in stm32mp1 fdt.c that disables OP-TEE resources defined in FDT when U-boot detects OP-TEE firmware is not present.

Before this change, helper function stm32_fdt_disable_optee() set property status to "disabled" for the OP-TEE reserved memory nodes but this has no impact since Linux kernel does not consider the status property for reserved-memory subnodes. This change make U-Boot to attempt to delete the node instead.

Quoted 6 lines
Fixes 4a1b975dac02 ("board: stm32mp1: reserve memory for OP-TEE in device

tree")

---

Applied to u-boot-stm/master, thanks!

Regards

Patrick

#2 lore raw

PATCH 1/2 board: stm32mp1: fix handling of DT OP-TEE reserved memory nodes

In reply to Patrick Delaunay

Hi

Quoted 49 lines · Patrick Delaunay

From: Etienne Carriere <[email protected]>

Fix the sequence in stm32mp1 fdt.c that disables OP-TEE resources defined in FDT when U-boot detects OP-TEE firmware is not present.

Before this change, helper function stm32_fdt_disable_optee() set property status to "disabled" for the OP-TEE reserved memory nodes but this has no impact since Linux kernel does not consider the status property for reserved-memory subnodes. This change make U-Boot to attempt to delete the node instead.

Fixes 4a1b975dac02 ("board: stm32mp1: reserve memory for OP-TEE in device tree")

---

 arch/arm/mach-stm32mp/fdt.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
arch/arm/mach-stm32mp/fdt.c +4 -3
index c723b223e0..959f12efe1 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
 /*
- * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
+ * Copyright (C) 2019-2020, STMicroelectronics - All Rights Reserved
  */
 
 #include <common.h>
@@ -224,19 +224,23 @@ static void stm32_fdt_disable_optee(void *blob)
 {
 	int off, node;
 
+	/* Delete "optee" firmware node */
 	off = fdt_node_offset_by_compatible(blob, -1, "linaro,optee-tz");
 	if (off >= 0 && fdtdec_get_is_enabled(blob, off))
-		fdt_status_disabled(blob, off);
+		fdt_del_node(blob, off);
 
-	/* Disabled "optee at ..." reserved-memory node */
+	/* Delete "optee at ..." reserved-memory node */
 	off = fdt_path_offset(blob, "/reserved-memory/");
 	if (off < 0)
 		return;
 	for (node = fdt_first_subnode(blob, off);
 	     node >= 0;
 	     node = fdt_next_subnode(blob, node)) {

arch/arm/mach-stm32mp/fdt.c static void stm32_fdt_disable_optee(void *blob) · line 246

Quoted 10 lines
arch/arm/mach-stm32mp/fdt.c +5 -2
-		if (!strncmp(fdt_get_name(blob, node, NULL), "optee@", 6))
-			fdt_status_disabled(blob, node);
+		if (strncmp(fdt_get_name(blob, node, NULL), "optee@", 6))
+			continue;
+
+		if (fdt_del_node(blob, node))
+			printf("Failed to remove optee reserved-memory node\n");
 	}
 }
 

Thanks

#3 lore raw

PATCH 2/2 dts: ARM: stm32mp15: add OP-TEE node in u-boot DTSI

In reply to Patrick Delaunay

From: Etienne Carriere <[email protected]>

Add OP-TEE firmware node in stm32mp15 U-Boot DTSI. This node is needed since commit [1] that changed U-Boot/stm32mp15 to detect OP-TEE availability by probing the resource instead of relying on U-Boot configuration. The software sequence implemented by [1] is fine but U-Boot DTS/DTSI files were not updated accordingly since, hence OP-TEE presence is never detected by U-Boot, preventing Linux kernel from using OP-TEE resources.

For consistency and to synchronize stm32mp15 DTSI files (excluding U-Boot specific DTSI files) with the Linux kernel ones, this change also moves the OP-TEE reserved memory nodes from board generic DTSI files to U-Boot specific board DTSI files.

Link [1] commit 43df0a159df6 ("stm32mp1: dynamically detect op-tee presence")

---

 arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi | 15 +++++++++++++++
 arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi | 14 ++++++++++++++
 arch/arm/dts/stm32mp157c-ed1.dts         |  5 -----
 arch/arm/dts/stm32mp15xx-dkx.dtsi        |  5 -----
 4 files changed, 29 insertions(+), 10 deletions(-)
arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi +15 -0
index c52abeb1e7..3fedb6f1e1 100644
@@ -20,6 +20,21 @@
 		st,fastboot-gpios = <&gpioa 13 GPIO_ACTIVE_LOW>;
 		st,stm32prog-gpios = <&gpioa 14 GPIO_ACTIVE_LOW>;
 	};
+
+	firmware {
+		optee {
+			compatible = "linaro,optee-tz";
+			method = "smc";
+		};
+	};
+
+	reserved-memory {
+		optee at de000000 {
+			reg = <0xde000000 0x02000000>;
+			no-map;
+		};
+	};
+
 	led {
 		red {
 			label = "error";
arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi +14 -0
index 84af7fa47b..a07c585415 100644
@@ -21,6 +21,20 @@
 		st,stm32prog-gpios = <&gpioa 14 GPIO_ACTIVE_LOW>;
 	};
 
+	firmware {
+		optee {
+			compatible = "linaro,optee-tz";
+			method = "smc";
+		};
+	};
+
+	reserved-memory {
+		optee at fe000000 {
+			reg = <0xfe000000 0x02000000>;
+			no-map;
+		};
+	};
+
 	led {
 		red {
 			label = "error";
arch/arm/dts/stm32mp157c-ed1.dts +0 -5
index 4fb71100f5..186dc46754 100644
@@ -70,11 +70,6 @@
 			reg = <0xe8000000 0x8000000>;
 			no-map;
 		};
-
-		optee at fe000000 {
-			reg = <0xfe000000 0x02000000>;
-			no-map;
-		};
 	};
 
 	aliases {
arch/arm/dts/stm32mp15xx-dkx.dtsi +0 -5
index 812e370ee4..7589c6f9dc 100644
@@ -58,11 +58,6 @@
 			reg = <0xd4000000 0x4000000>;
 			no-map;
 		};
-
-		optee at de000000 {
-			reg = <0xde000000 0x02000000>;
-			no-map;
-		};
 	};
 
 	led {
Signature · 1 line
2.17.1
#4 lore raw

PATCH 2/2 dts: ARM: stm32mp15: add OP-TEE node in u-boot DTSI

Hi

Quoted 99 lines · Patrick Delaunay

From: Etienne Carriere <[email protected]>

Add OP-TEE firmware node in stm32mp15 U-Boot DTSI. This node is needed since commit [1] that changed U-Boot/stm32mp15 to detect OP-TEE availability by probing the resource instead of relying on U-Boot configuration. The software sequence implemented by [1] is fine but U-Boot DTS/DTSI files were not updated accordingly since, hence OP-TEE presence is never detected by U-Boot, preventing Linux kernel from using OP-TEE resources.

For consistency and to synchronize stm32mp15 DTSI files (excluding U-Boot specific DTSI files) with the Linux kernel ones, this change also moves the OP-TEE reserved memory nodes from board generic DTSI files to U-Boot specific board DTSI files.

Link [1] commit 43df0a159df6 ("stm32mp1: dynamically detect op-tee presence")

---

 arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi | 15 +++++++++++++++
 arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi | 14 ++++++++++++++
 arch/arm/dts/stm32mp157c-ed1.dts         |  5 -----
 arch/arm/dts/stm32mp15xx-dkx.dtsi        |  5 -----
 4 files changed, 29 insertions(+), 10 deletions(-)
arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi +15 -0
index c52abeb1e7..3fedb6f1e1 100644
@@ -20,6 +20,21 @@
 		st,fastboot-gpios = <&gpioa 13 GPIO_ACTIVE_LOW>;
 		st,stm32prog-gpios = <&gpioa 14 GPIO_ACTIVE_LOW>;
 	};
+
+	firmware {
+		optee {
+			compatible = "linaro,optee-tz";
+			method = "smc";
+		};
+	};
+
+	reserved-memory {
+		optee at de000000 {
+			reg = <0xde000000 0x02000000>;
+			no-map;
+		};
+	};
+
 	led {
 		red {
 			label = "error";
arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi +14 -0
index 84af7fa47b..a07c585415 100644
@@ -21,6 +21,20 @@
 		st,stm32prog-gpios = <&gpioa 14 GPIO_ACTIVE_LOW>;
 	};
 
+	firmware {
+		optee {
+			compatible = "linaro,optee-tz";
+			method = "smc";
+		};
+	};
+
+	reserved-memory {
+		optee at fe000000 {
+			reg = <0xfe000000 0x02000000>;
+			no-map;
+		};
+	};
+
 	led {
 		red {
 			label = "error";
arch/arm/dts/stm32mp157c-ed1.dts +0 -5
index 4fb71100f5..186dc46754 100644
@@ -70,11 +70,6 @@
 			reg = <0xe8000000 0x8000000>;
 			no-map;
 		};
-
-		optee at fe000000 {
-			reg = <0xfe000000 0x02000000>;
-			no-map;
-		};
 	};
 
 	aliases {
arch/arm/dts/stm32mp15xx-dkx.dtsi +0 -0
index 812e370ee4..7589c6f9dc 100644
@@ -58,11 +58,6 @@
 			reg = <0xd4000000 0x4000000>;

arch/arm/dts/stm32mp15xx-dkx.dtsi line 63

Quoted 10 lines
arch/arm/dts/stm32mp15xx-dkx.dtsi +0 -5
 			no-map;
 		};
-
-		optee at de000000 {
-			reg = <0xde000000 0x02000000>;
-			no-map;
-		};
 	};
 
 	led {

Thanks

#5 lore raw

PATCH 2/2 dts: ARM: stm32mp15: add OP-TEE node in u-boot DTSI

In reply to Patrick Delaunay

Hi,

Quoted 20 lines

From: Patrick DELAUNAY <[email protected]>
Sent: vendredi 5 juin 2020 09:25

From: Etienne Carriere <[email protected]>

Add OP-TEE firmware node in stm32mp15 U-Boot DTSI. This node is needed since commit [1] that changed U-Boot/stm32mp15 to detect OP-TEE availability by probing the resource instead of relying on U-Boot configuration. The software sequence implemented by [1] is fine but U-Boot DTS/DTSI files were not updated accordingly since, hence OP-TEE presence is never detected by U-Boot, preventing Linux kernel from using OP-TEE resources.

For consistency and to synchronize stm32mp15 DTSI files (excluding U-Boot specific DTSI files) with the Linux kernel ones, this change also moves the OP- TEE reserved memory nodes from board generic DTSI files to U-Boot specific board DTSI files.

Link [1] commit 43df0a159df6 ("stm32mp1: dynamically detect op-tee presence")
Quoted 8 lines

---

 arch/arm/dts/stm32mp157a-dk1-u-boot.dtsi | 15 +++++++++++++++
arch/arm/dts/stm32mp157c-ed1-u-boot.dtsi | 14 ++++++++++++++
 arch/arm/dts/stm32mp157c-ed1.dts         |  5 -----
 arch/arm/dts/stm32mp15xx-dkx.dtsi        |  5 -----
 4 files changed, 29 insertions(+), 10 deletions(-)

Applied to u-boot-stm/master, thanks!

Regards

Patrick