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

Weizhao Ouyang o451686892 at gmail.com
Wed Jan 31 14:35:14 CET 2024


On Wed, Jan 31, 2024 at 8:27 PM Heinrich Schuchardt <xypron.glpk at gmx.de> wrote:
>
> On 31.01.24 12:12, 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>
> > ---
> > v2: check SMCCC_ARCH_FEATURES
> > ---
> >   drivers/firmware/psci.c   | 9 ++++++++-
> >   include/linux/arm-smccc.h | 6 ++++++
> >   2 files changed, 14 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
> > index c6b9efab41..ed701cd1e4 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;
> >
> > @@ -144,6 +144,13 @@ static int bind_smccc_features(struct udevice *dev, int psci_method)
> >       else
> >               pdata->invoke_fn = smccc_invoke_smc;
> >
> > +     /*
> > +      * SMCCC_ARCH_FEATURES is MANDATORY from SMCCC v1.1, but we still remain
> > +      * the invoke_fn() even the SMCCC version is v1.0.
>
> This sentence is a bit hard to understand. Did you mean,
>
> "but we keep calling invoke_fn() even if the SMCC version is v1.0" ?
>
> > +      */
> > +     if (invoke_psci_fn(ARM_SMCCC_VERSION, 0, 0, 0) < ARM_SMCCC_VERSION_1_1)
> > +             return 0;
>
>
> Why do we leave the function for
> invoke_psci_fn(ARM_SMCCC_VERSION, 0, 0, 0) == ARM_SMCCC_VERSION_1_0
> despite the comment above?
>

Previously I was trying to leave the driver a fallback SMC call for
SMCCC v1.0, but since the arm-ffa driver not use the legacy SMC invoke
function and also we can directly call invoke_psci_fn(), so maybe we can
drop this fallback function. Will update in v3.

BR,
Weizhao

> Best regards
>
> Heinrich
>
> > +
> >       feature_cnt = ll_entry_count(struct arm_smccc_feature, arm_smccc_feature);
> >       feature = ll_entry_start(struct arm_smccc_feature, arm_smccc_feature);
> >
> > 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__
>


More information about the U-Boot mailing list