From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3567E3E3C7A for ; Wed, 29 Apr 2026 10:36:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777458967; cv=none; b=Wx7GnwxcbV084+XsaFsdOqTuYDxaZuTSf+MufROSEpuhUlHf4gRM/RfmdG0cg4RTCLbxYpev5jhsnIERBNPYWDj/w3Kjsfu3BfLkqAC064ryJs7dEyvTJrbbvQI+v3q6+BWAghqQWSj6AEprFG3a8OUYyrsJWainYbVcxria0Rc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777458967; c=relaxed/simple; bh=Xuvp4LNkPrZpjDlqGpQ4sGF4Ii5mNXQnM6ZUP+x7rAw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uu2it+bB0IQP3/I/CYkU1hFYKv7JDMPVLGTLiFhNXQanGFF92UJTlsKH61YggiIO9q3+d+OxwbhdG85kWcfO/dcVuoFFn8STNca/44ndF1MsULqlsQ1/rJzgFM/JcqcZ6opcSDgySPbFRzzs67/oOLTW81O1nzXFHawnvdelRdM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=EGRsAkAE; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="EGRsAkAE" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 05CE132F9; Wed, 29 Apr 2026 03:35:59 -0700 (PDT) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DF5853F763; Wed, 29 Apr 2026 03:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1777458964; bh=Xuvp4LNkPrZpjDlqGpQ4sGF4Ii5mNXQnM6ZUP+x7rAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EGRsAkAEtEL6D8j4oVGATbOY7qy0bDb1NVvsBnE4M3aCdRr0qb1SMyafsCV6q4XMp xyag85G3d3WXY2d9UqhlS8z6G5FRBcs8VDHLBm/c1P9/Iqd0ZY43BO1YLMri2fuqhr ZkurDQG3CCKLg85k3EPvfn1IYdt/YNn7gPX4LZR0= From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, ardb@kernel.org, lpieralisi@kernel.org, mark.rutland@arm.com, steven.price@arm.com, aneesh.kumar@kernel.org, sudeep.holla@arm.com, robh@kernel.org, maz@kernel.org, Suzuki K Poulose Subject: [RFC PATCH 2/4] psci: Add support for Early detection and init Date: Wed, 29 Apr 2026 11:35:33 +0100 Message-ID: <20260429103535.266728-3-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429103535.266728-1-suzuki.poulose@arm.com> References: <20260429103535.266728-1-suzuki.poulose@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Allow early detection of the PSCI conduit and presence of SMCCC. Primary motive is to detect if we are a Realm as early as possible to make better decisions 1. For mapping the memory without BBML2_NOABORT 2. Making use of the earlycon, to be able to debug problems at early boot. Add a new psci_early_init_conduit() which can probe the PSCI and SMCCC. This is optional, and could really fallback to the normal if the architecture cannot reliably detect the conduit. Later patches will make use of this. Signed-off-by: Suzuki K Poulose --- drivers/firmware/psci/psci.c | 49 ++++++++++++++++++++++++++++++++++-- include/linux/psci.h | 2 ++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 38ca190d4a22..fa0839513d64 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -80,6 +80,11 @@ static u32 psci_cpu_suspend_feature; static bool psci_system_reset2_supported; static bool psci_system_off2_hibernate_supported; +static inline bool psci_probed(void) +{ + return psci_ops.get_version != NULL; +} + static inline bool psci_has_ext_power_state(void) { return psci_cpu_suspend_feature & @@ -270,6 +275,15 @@ static unsigned long psci_migrate_info_up_cpu(void) static void set_conduit(enum arm_smccc_conduit conduit) { + /* + * If we have set the conduit already, make sure + * it is the same as we have found. + */ + if (psci_conduit != SMCCC_CONDUIT_NONE) { + WARN_ON(conduit != psci_conduit); + return; + } + switch (conduit) { case SMCCC_CONDUIT_HVC: invoke_psci_fn = __invoke_psci_fn_hvc; @@ -679,7 +693,16 @@ static void __init psci_0_2_set_functions(void) */ static int __init psci_probe(void) { - u32 ver = psci_0_2_get_version(); + u32 ver; + + /* Make sure we have a set CONDUIT */ + if (WARN_ON(psci_conduit == SMCCC_CONDUIT_NONE)) + return -ENODEV; + + if (WARN_ON(psci_probed())) + return 0; + + ver = psci_0_2_get_version(); pr_info("PSCIv%d.%d detected in firmware.\n", PSCI_VERSION_MAJOR(ver), @@ -717,10 +740,12 @@ static int __init psci_0_2_init(const struct device_node *np) { int err; + if (psci_probed()) + return 0; + err = get_set_conduit_method(np); if (err) return err; - /* * Starting with v0.2, the PSCI specification introduced a call * (PSCI_VERSION) that allows probing the firmware version, so @@ -739,6 +764,9 @@ static int __init psci_0_1_init(const struct device_node *np) u32 id; int err; + if (psci_probed()) + return 0; + err = get_set_conduit_method(np); if (err) return err; @@ -816,6 +844,20 @@ int __init psci_dt_init(void) return ret; } +int __init psci_early_init_conduit(enum arm_smccc_conduit conduit) +{ + switch (conduit) { + case SMCCC_CONDUIT_HVC: + case SMCCC_CONDUIT_SMC: + set_conduit(conduit); + break; + default: + WARN_ON(1); + return -EINVAL; + } + return psci_probe(); +} + #ifdef CONFIG_ACPI /* * We use PSCI 0.2+ when ACPI is deployed on ARM64 and it's @@ -823,6 +865,9 @@ int __init psci_dt_init(void) */ int __init psci_acpi_init(void) { + if (psci_probed()) + return 0; + if (!acpi_psci_present()) { pr_info("is not implemented in ACPI.\n"); return -EOPNOTSUPP; diff --git a/include/linux/psci.h b/include/linux/psci.h index 4ca0060a3fc4..8f98d61a69e4 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -59,4 +59,6 @@ static inline bool acpi_psci_present(void) { return false; } static inline bool acpi_psci_use_hvc(void) {return false; } #endif +int __init psci_early_init_conduit(enum arm_smccc_conduit); + #endif /* __LINUX_PSCI_H */ -- 2.43.0