[PATCH 1/3] firmware: psci: Fix bind_smccc_features psci check

Abdellatif El Khlifi abdellatif.elkhlifi at arm.com
Fri Jan 26 12:20:28 CET 2024


Hi Weizhao,

On Thu, Jan 25, 2024 at 02:05:00PM +0000, Weizhao Ouyang wrote:
> 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 at gmail.com>
> ---
>  drivers/firmware/psci.c   | 2 +-
>  include/linux/arm-smccc.h | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
> index c6b9efab41..894be8128d 100644
> --- a/drivers/firmware/psci.c
> +++ b/drivers/firmware/psci.c
> @@ -135,7 +135,7 @@ 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;

I suggest we add checks on the SMCCC version like this:

    if SMCCC_VERSION >= 1.1
       assume SMCCC_ARCH_FEATURES is supported
       discover arch features and bind drivers/devices
    else
       error


For more details [1][2].


[1]: SMC Calling Convention 1.5 (https://developer.arm.com/documentation/den0028/latest/)

SMCCC_ARCH_FEATURES MANDATORY from SMCCC v1.1

The implementation of this function can be detected by checking the SMCCC version. This function is mandatory
if SMCCC_VERSION indicates that version 1.1 or later is implemented.

[2]: Linux checks SMCCC v1.1: https://elixir.bootlin.com/linux/latest/source/drivers/firmware/psci/psci.c#L597

Cheers,
Abdellatif


More information about the U-Boot mailing list