On Wed, Mar 15, 2023 at 07:27:14AM -0500, Shanker Donthineni wrote: > Hi Marc, > > On 3/15/23 03:34, Marc Zyngier wrote: > > Please don't duplicate existing code. There is already the required > > infrastructure in drivers/firmware/smccc/soc_id.c. All you need to do > > is: > > > > - disassociate the SMCCC probing from the device registration > > > > - probe the SOC_ID early > > > > - add accessors for the relevant data > > > > - select ARM_SMCCC_SOD_ID/ARM_SMCCC_DISCOVERY from the GICv3 Kconfig > > > I have not modified soc_id.c as it expects to be loaded as a module with > the use of module_init() and module_exit() functions. The exported symbols > in soc_id driver cannot be accessed from the built-in code. > > Agree, the SOD-ID discovery code was duplicated. > > Please guide me if the below approach is okay? > > 1) Probe the SOC-ID in arm_smccc_version_init() and export two functions > arm_smccc_get_soc_id_version() and arm_smccc_get_soc_id_revision(). > > --- a/drivers/firmware/smccc/smccc.c > +++ b/drivers/firmware/smccc/smccc.c > @@ -17,9 +17,13 @@ static enum arm_smccc_conduit smccc_conduit = SMCCC_CONDUIT_NONE; > > bool __ro_after_init smccc_trng_available = false; > u64 __ro_after_init smccc_has_sve_hint = false; > +s32 __ro_after_init smccc_soc_id_version = SMCCC_RET_NOT_SUPPORTED; > +s32 __ro_after_init smccc_soc_id_revision = SMCCC_RET_NOT_SUPPORTED; > > void __init arm_smccc_version_init(u32 version, enum arm_smccc_conduit conduit) > { > + struct arm_smccc_res res; > + > smccc_version = version; > smccc_conduit = conduit; > > @@ -27,6 +31,18 @@ void __init arm_smccc_version_init(u32 version, enum arm_smccc_conduit conduit) > if (IS_ENABLED(CONFIG_ARM64_SVE) && > smccc_version >= ARM_SMCCC_VERSION_1_3) > smccc_has_sve_hint = true; > + > + if ((smccc_version >= ARM_SMCCC_VERSION_1_2) && > + (smccc_conduit != SMCCC_CONDUIT_NONE)) { > + arm_smccc_1_1_invoke(ARM_SMCCC_ARCH_FEATURES_FUNC_ID, > + ARM_SMCCC_ARCH_SOC_ID, &res); > + if ((s32)res.a0 >= 0) { > + arm_smccc_1_1_invoke(ARM_SMCCC_ARCH_SOC_ID, 0, &res); > + smccc_soc_id_version = (s32)res.a0; > + arm_smccc_1_1_invoke(ARM_SMCCC_ARCH_SOC_ID, 1, &res); > + smccc_soc_id_revision = (s32)res.a0; > + } > + } > } > > > +s32 arm_smccc_get_soc_id_version(void) > +{ > + return smccc_soc_id_version; > +} > +EXPORT_SYMBOL_GPL(arm_smccc_get_soc_id_version); > + > +s32 arm_smccc_get_soc_id_revision(void) > +{ > + return smccc_soc_id_revision; > +} > +EXPORT_SYMBOL_GPL(arm_smccc_get_soc_id_revision); > > Overall, it looks OK to me. However I see neither the gic nor the soc_id can be build as module atm. So do we really need the export symbols if no other modules are using it ? -- Regards, Sudeep