diff mbox series

[v2,1/2] arm-bsp/u-boot: corstone1000: fix SMCCC_ARCH_FEATURES detection in the PSCI driver

Message ID 20240314110457.230569-2-bence.balogh@arm.com
State New
Headers show
Series [v2,1/2] arm-bsp/u-boot: corstone1000: fix SMCCC_ARCH_FEATURES detection in the PSCI driver | expand

Commit Message

bence.balogh@arm.com March 14, 2024, 11:04 a.m. UTC
From: Bence Balogh <bence.balogh@arm.com>

The u-boot PSCI driver was not compliant with the PSCI specifications so
this patch had to be added.

Signed-off-by: Bence Balogh <bence.balogh@arm.com>
---
 .../u-boot/u-boot-corstone1000.inc            |  1 +
 ...i-Fix-bind_smccc_features-psci-check.patch | 60 +++++++++++++++++++
 2 files changed, 61 insertions(+)
 create mode 100644 meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0043-firmware-psci-Fix-bind_smccc_features-psci-check.patch
diff mbox series

Patch

diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot-corstone1000.inc b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-corstone1000.inc
index 2585ff25..c7172d6f 100644
--- a/meta-arm-bsp/recipes-bsp/u-boot/u-boot-corstone1000.inc
+++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot-corstone1000.inc
@@ -58,6 +58,7 @@  SRC_URI:append = " \
     file://0040-fix-runtime-capsule-update-flags-checks.patch		  \
     file://0041-scatter-gather-flag-workaround.patch			  \
     file://0042-corstone1000-enable-virtio-net-support.patch		  \
+    file://0043-firmware-psci-Fix-bind_smccc_features-psci-check.patch		  \
     "
 
 do_configure:append() {
diff --git a/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0043-firmware-psci-Fix-bind_smccc_features-psci-check.patch b/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0043-firmware-psci-Fix-bind_smccc_features-psci-check.patch
new file mode 100644
index 00000000..70d684b5
--- /dev/null
+++ b/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0043-firmware-psci-Fix-bind_smccc_features-psci-check.patch
@@ -0,0 +1,60 @@ 
+Subject: [PATCH v4 1/3] firmware: psci: Fix bind_smccc_features psci check
+Date: Mon,  4 Mar 2024 14:42:40 +0000	[thread overview]
+Message-ID: <20240304144242.11666-2-o451686892@gmail.com> (raw)
+In-Reply-To: <20240304144242.11666-1-o451686892@gmail.com>
+
+According to PSCI specification DEN0022F, PSCI_FEATURES is used to check
+whether the SMCCC is implemented by discovering SMCCC_VERSION.
+
+Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
+Signed-off-by: Bence Balogh <bence.balogh@arm.com>
+Upstream-Status: Submitted [https://lore.kernel.org/all/20240304144242.11666-2-o451686892@gmail.com/]
+---
+v3: remove fallback smc call
+v2: check SMCCC_ARCH_FEATURES
+---
+ drivers/firmware/psci.c   | 5 ++++-
+ include/linux/arm-smccc.h | 6 ++++++
+ 2 files changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
+index c6b9efab41..03544d76ed 100644
+--- a/drivers/firmware/psci.c
++++ b/drivers/firmware/psci.c
+@@ -135,10 +135,13 @@ static int bind_smccc_features(struct udevice *dev, int psci_method)
+ 	    PSCI_VERSION_MAJOR(psci_0_2_get_version()) == 0)
+ 		return 0;
+ 
+-	if (request_psci_features(ARM_SMCCC_ARCH_FEATURES) ==
++	if (request_psci_features(ARM_SMCCC_VERSION) ==
+ 	    PSCI_RET_NOT_SUPPORTED)
+ 		return 0;
+ 
++	if (invoke_psci_fn(ARM_SMCCC_VERSION, 0, 0, 0) < ARM_SMCCC_VERSION_1_1)
++		return 0;
++
+ 	if (psci_method == PSCI_METHOD_HVC)
+ 		pdata->invoke_fn = smccc_invoke_hvc;
+ 	else
+diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h
+index f44e9e8f93..da3d29aabe 100644
+--- a/include/linux/arm-smccc.h
++++ b/include/linux/arm-smccc.h
+@@ -55,8 +55,14 @@
+ #define ARM_SMCCC_QUIRK_NONE		0
+ #define ARM_SMCCC_QUIRK_QCOM_A6		1 /* Save/restore register a6 */
+ 
++#define ARM_SMCCC_VERSION		0x80000000
+ #define ARM_SMCCC_ARCH_FEATURES		0x80000001
+ 
++#define ARM_SMCCC_VERSION_1_0		0x10000
++#define ARM_SMCCC_VERSION_1_1		0x10001
++#define ARM_SMCCC_VERSION_1_2		0x10002
++#define ARM_SMCCC_VERSION_1_3		0x10003
++
+ #define ARM_SMCCC_RET_NOT_SUPPORTED	((unsigned long)-1)
+ 
+ #ifndef __ASSEMBLY__
+-- 
+2.40.1
+