mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 1/4] ARM: psci: of: fixup only version if node already exists
Date: Tue,  1 Nov 2022 07:26:39 +0100	[thread overview]
Message-ID: <20221101062642.3207113-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20221101062642.3207113-1-a.fatoum@pengutronix.de>

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@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




  reply	other threads:[~2022-11-01  6:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-01  6:26 [PATCH master 0/4] ARM: psci: client: unbreak hypervisor boot Ahmad Fatoum
2022-11-01  6:26 ` Ahmad Fatoum [this message]
2022-11-01  6:26 ` [PATCH master 2/4] ARM: psci: client: match most specific compatible first Ahmad Fatoum
2022-11-01  6:26 ` [PATCH master 3/4] ARM: psci: client: always register OF fixup Ahmad Fatoum
2022-11-01  6:26 ` [PATCH master 4/4] ARM: psci: keep older PSCI versions in compatible fixup Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221101062642.3207113-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox