diff mbox series

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

Message ID 20200605092427.1.I393865d4202eca31c111da33b792596f130b73d2@changeid
State Accepted
Commit 164873a0c02ddbc9a59ad3a0670f17684fc00737
Delegated to: Patrick Delaunay
Headers show
Series [1/2] board: stm32mp1: fix handling of DT OP-TEE reserved memory nodes | expand

Commit Message

Patrick DELAUNAY June 5, 2020, 7:24 a.m. UTC
From: Etienne Carriere <etienne.carriere@linaro.org>

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")
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 arch/arm/mach-stm32mp/fdt.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Comments

Patrice CHOTARD June 16, 2020, 8:07 a.m. UTC | #1
Hi

On 6/5/20 9:24 AM, Patrick Delaunay wrote:
> From: Etienne Carriere <etienne.carriere@linaro.org>
>
> 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")
> Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
>  arch/arm/mach-stm32mp/fdt.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/mach-stm32mp/fdt.c b/arch/arm/mach-stm32mp/fdt.c
> index c723b223e0..959f12efe1 100644
> --- a/arch/arm/mach-stm32mp/fdt.c
> +++ b/arch/arm/mach-stm32mp/fdt.c
> @@ -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@..." reserved-memory node */
> +	/* Delete "optee@..." 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");
>  	}
>  }
>  

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

Thanks
Patrick DELAUNAY June 16, 2020, 9:18 a.m. UTC | #2
Hi,

> From: Patrick DELAUNAY <patrick.delaunay@st.com>
> Sent: vendredi 5 juin 2020 09:24
> 
> From: Etienne Carriere <etienne.carriere@linaro.org>
> 
> 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")
> Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
> 

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

Regards

Patrick
diff mbox series

Patch

diff --git a/arch/arm/mach-stm32mp/fdt.c b/arch/arm/mach-stm32mp/fdt.c
index c723b223e0..959f12efe1 100644
--- a/arch/arm/mach-stm32mp/fdt.c
+++ b/arch/arm/mach-stm32mp/fdt.c
@@ -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@..." reserved-memory node */
+	/* Delete "optee@..." 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");
 	}
 }