[PATCH master 1/4] ARM: psci: of: fixup only version if node already exists

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Oct 31 23:26:39 PDT 2022


When barebox is booted as QEMU -kernel, PSCI will have method = "hvc",
because QEMU will act as Hypervisor. barebox handles this correctly and
will use hvc instead of smc, but of_psci_fixup() always fixes up
method = "smc" thereby breaking kernel boot.

Fix this by only updating version if the node already exists and
omitting everything else.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 arch/arm/cpu/psci-of.c | 39 +++++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/arch/arm/cpu/psci-of.c b/arch/arm/cpu/psci-of.c
index ef83b0edee69..e08a04b36d05 100644
--- a/arch/arm/cpu/psci-of.c
+++ b/arch/arm/cpu/psci-of.c
@@ -7,16 +7,10 @@
 #include <asm/psci.h>
 #include <linux/arm-smccc.h>
 
-int of_psci_fixup(struct device_node *root, unsigned long psci_version)
+static int of_psci_version_fixup(struct device_node *psci,
+				 unsigned long psci_version)
 {
-	struct device_node *psci;
-	int ret;
 	const char *compat;
-	struct device_node *cpus, *cpu;
-
-	psci = of_create_node(root, "/psci");
-	if (!psci)
-		return -EINVAL;
 
 	if (psci_version >= ARM_PSCI_VER_1_0) {
 		compat = "arm,psci-1.0";
@@ -27,6 +21,27 @@ int of_psci_fixup(struct device_node *root, unsigned long psci_version)
 		return -EINVAL;
 	}
 
+	return of_property_write_string(psci, "compatible", compat);
+}
+
+int of_psci_fixup(struct device_node *root, unsigned long psci_version)
+{
+	struct device_node *psci;
+	int ret;
+	struct device_node *cpus, *cpu;
+
+	psci = of_find_node_by_path_from(root, "/psci");
+	if (psci)
+		return of_psci_version_fixup(psci, psci_version);
+
+	psci = of_create_node(root, "/psci");
+	if (!psci)
+		return -EINVAL;
+
+	ret = of_property_write_string(psci, "method", "smc");
+	if (ret)
+		return ret;
+
 	cpus = of_find_node_by_path_from(root, "/cpus");
 	if (!cpus) {
 		pr_err("Cannot find /cpus node, PSCI fixup aborting\n");
@@ -42,13 +57,5 @@ int of_psci_fixup(struct device_node *root, unsigned long psci_version)
 		pr_debug("Fixed %s\n", cpu->full_name);
 	}
 
-	ret = of_property_write_string(psci, "compatible", compat);
-	if (ret)
-		return ret;
-
-	ret = of_property_write_string(psci, "method", "smc");
-	if (ret)
-		return ret;
-
 	return 0;
 }
-- 
2.30.2




More information about the barebox mailing list