summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2021-10-10 16:20:38 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2021-10-10 16:20:38 +0000
commitf7948f85defce0b8ea5cf7ac0145268fde4add92 (patch)
tree00265e8ff3663f863f394f660636b82420fdddd0
parent3e831905ec040594fa9e5f2d940b028e598d25dc (diff)
Apparently it is possible for firmware to indicate that SMCCC_VERSION is
implemented but have that call return NOT_SUPPORTED. Makes no sense, but the SMCCC standard documents this and tells us to treat this as v1.0. Change the code accordingly. Turn a few checks that should always be true into KASSERTs to keep the control flow simple. ok patrick@
-rw-r--r--sys/dev/fdt/psci.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/sys/dev/fdt/psci.c b/sys/dev/fdt/psci.c
index f0e37c50880..26c328f47eb 100644
--- a/sys/dev/fdt/psci.c
+++ b/sys/dev/fdt/psci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: psci.c,v 1.8 2018/05/23 09:12:34 kettenis Exp $ */
+/* $OpenBSD: psci.c,v 1.9 2021/10/10 16:20:37 kettenis Exp $ */
/*
* Copyright (c) 2016 Jonathan Gray <jsg@openbsd.org>
@@ -208,11 +208,15 @@ int32_t
smccc_version(void)
{
struct psci_softc *sc = psci_sc;
+ int32_t version;
- if (sc && sc->sc_callfn)
- return (*sc->sc_callfn)(SMCCC_VERSION, 0, 0, 0);
+ KASSERT(sc && sc->sc_callfn);
+ version = (*sc->sc_callfn)(SMCCC_VERSION, 0, 0, 0);
+ if (version != PSCI_NOT_SUPPORTED)
+ return version;
- return PSCI_NOT_SUPPORTED;
+ /* Treat NOT_SUPPORTED as 1.0 */
+ return 0x10000;
}
int32_t
@@ -220,10 +224,8 @@ smccc_arch_features(uint32_t arch_func_id)
{
struct psci_softc *sc = psci_sc;
- if (sc && sc->sc_callfn)
- return (*sc->sc_callfn)(SMCCC_ARCH_FEATURES, arch_func_id, 0, 0);
-
- return PSCI_NOT_SUPPORTED;
+ KASSERT(sc && sc->sc_callfn);
+ return (*sc->sc_callfn)(SMCCC_ARCH_FEATURES, arch_func_id, 0, 0);
}
uint32_t