[PATCH 14/19] firmware/psci: Cache PSCI v0.2+ version number to avoid redundant SMCs
Jinjie Ruan
ruanjinjie at huawei.com
Tue Sep 8 04:57:35 PDT 2026
在 2026/9/8 0:40, Will Deacon 写道:
> Secure monitor calls to EL3 aren't necessarily cheap, so cache the
> PSCI version number in memory to avoid asking firmware the same question
> over and over again.
>
> Signed-off-by: Will Deacon <will at kernel.org>
> ---
> drivers/firmware/psci/psci.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
> index e73bae6cb23a..8bb3f7c37678 100644
> --- a/drivers/firmware/psci/psci.c
> +++ b/drivers/firmware/psci/psci.c
> @@ -155,7 +155,12 @@ static u32 psci_0_1_get_version(void)
>
> static u32 psci_0_2_get_version(void)
> {
> - return invoke_psci_fn(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
> + static u32 version;
> +
> + if (unlikely(!version))
> + version = invoke_psci_fn(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
> +
> + return version;
Reviewed-by: Jinjie Ruan <ruanjinjie at huawei.com>
> }
>
> int psci_set_osi_mode(bool enable)
More information about the linux-arm-kernel
mailing list