drivers/firmware/psci: Hide ACPI state during initialization
Subsystems (2)
PATCH 1/1 drivers/firmware/psci: Hide ACPI state during initialization
Either psci_dt_init() or psci_acpi_init() s called depends on ACPI enablement state, which isn't so nice. In this case, two functions have to be exported from PSCI module.
This hides the ACPI enablement state insides PSCI module so that we only need to export a function, to make the code a bit simplified.
--- arch/arm64/kernel/setup.c | 7 +------ drivers/firmware/psci/psci.c | 20 +++++++++++++++++--- include/linux/psci.h | 8 +++----- 3 files changed, 21 insertions(+), 14 deletions(-)
arch/arm64/kernel/setup.c +1 -6
@@ -338,12 +338,7 @@ void __init setup_arch(char **cmdline_p)request_standard_resources ();early_ioremap_reset (); - -if (acpi_disabled) -psci_dt_init (); -else -psci_acpi_init (); - +psci_init ();cpu_read_bootcpu_ops ();smp_init_cpus ();smp_build_mpidr_hash ();
drivers/firmware/psci/psci.c +17 -3
@@ -557,7 +557,7 @@ static const struct of_device_id psci_of_match[] __initconst = { {}, }; -int __init psci_dt_init (void ) +static int __init psci_dt_init (void ) {struct device_node *np;const struct of_device_id *matched_np;
@@ -581,7 +581,7 @@ int __init psci_dt_init(void)* We use PSCI 0.2+ when ACPI is deployed on ARM64 and it's * explicitly clarified in SBBR */ -int __init psci_acpi_init (void ) +static int __init psci_acpi_init (void ) {if (!acpi_psci_present ()) {pr_info ("is not implemented in ACPI.\n" );
@@ -597,4 +597,18 @@ int __init psci_acpi_init(void) return psci_probe(); } -#endif + +#else +static inline int psci_acpi_init (void ) +{ +return 0 ; +} +#endif /* CONFIG_ACPI */ + +int __init psci_init (void ) +{ +if (acpi_disabled) +return psci_dt_init (); + +return psci_acpi_init (); +}
include/linux/psci.h +3 -5
@@ -39,18 +39,16 @@ struct psci_operations {extern struct psci_operations psci_ops; -#if defined(CONFIG_ARM_PSCI_FW ) -int __init psci_dt_init (void ); +#ifdef CONFIG_ARM_PSCI_FW +int __init psci_init (void );#else -static inline int psci_dt_init (void ) {return 0 ; } +static inline int psci_init (void ) {return 0 ; }#endif #if defined(CONFIG_ARM_PSCI_FW ) && defined(CONFIG_ACPI ) -int __init psci_acpi_init (void );bool __init acpi_psci_present (void );bool acpi_psci_use_hvc (void );#else -static inline int psci_acpi_init (void ) {return 0 ; }static inline bool acpi_psci_present (void ) {return false; }static inline bool acpi_psci_use_hvc (void ) {return false; }#endif
Signature · 7 lines
2.23.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 4 lines · Gavin Shan
Either
psci_dt_init()orpsci_acpi_init()s called depends on ACPI enablement state, which isn't so nice. In this case, two functions have to be exported from PSCI module.
I am confused, we don't export any functions as you mention and both are __init functions which can't be exported.
Quoted 3 lines
This hides the ACPI enablement state insides PSCI module so that we only need to export a function, to make the code a bit simplified.
For me it's just the preference. I will leave it to maintainers' taste.
--
Regards,
Sudeep
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Sudeep,
Quoted 5 lines · Sudeep Holla
Quoted 4 lines · Gavin Shan
Either
psci_dt_init()orpsci_acpi_init()s called depends on ACPI enablement state, which isn't so nice. In this case, two functions have to be exported from PSCI module.
I missed your reply and sorry for late catchup.
Quoted 3 lines
I am confused, we don't export any functions as you mention and both are
__initfunctions which can't be exported.
The words "export" here means "declared". Two functons (psci_{dt,acpi}_init()) are declared and one of them is called depending on ACPI is enabled or not. If we hide the ACPI enablement state inside the driver/module, we just need to declare one function (psci_init()), to make the code a bit cleaner.
Quoted 6 lines
Quoted 3 lines
This hides the ACPI enablement state insides PSCI module so that we only need to export a function, to make the code a bit simplified.
For me it's just the preference. I will leave it to maintainers' taste.
Sure, lets see what comments Mark will have then. It's not bad to make the code cleaner, even just a bit :)
Thank you for your time on this.
Thanks,
Gavin
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Tue, Feb 11, 2020 at 01:02:44PM +1100, Gavin Shan wrote:
[...]
Quoted 10 lines
The words "export" here means "declared". Two functons (psci_{dt,acpi}_init()) are declared and one of them is called depending on ACPI is enabled or not. If we hide the ACPI enablement state inside the driver/module, we just need to declare one function (
psci_init()), to make the code a bit cleaner.Quoted 5 lines
Quoted 3 lines
This hides the ACPI enablement state insides PSCI module so that we only need to export a function, to make the code a bit simplified.
For me it's just the preference. I will leave it to maintainers' taste.
I am not too fussed either way. As code is now though at least we know acpi_disabled was {set/clear} before PSCI is initialized. Hiding the ACPI/DT switch in PSCI code can be a problem if we move the boot code around.
I don't necessarily see this patch as an improvement, again it is no big deal regardless.
Thanks,
Lorenzo
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 13 lines · Lorenzo Pieralisi
On Tue, Feb 11, 2020 at 01:02:44PM +1100, Gavin Shan wrote:
[...]
Quoted 9 lines
The words "export" here means "declared". Two functons (psci_{dt,acpi}_init()) are declared and one of them is called depending on ACPI is enabled or not. If we hide the ACPI enablement state inside the driver/module, we just need to declare one function (
psci_init()), to make the code a bit cleaner.Quoted 3 lines
Quoted 3 lines
This hides the ACPI enablement state insides PSCI module so that we only need to export a function, to make the code a bit simplified.
Quoted 9 lines
Quoted 1 line
Quoted 1 line
For me it's just the preference. I will leave it to maintainers' taste.
I am not too fussed either way. As code is now though at least we know
acpi_disabledwas {set/clear} before PSCI is initialized. Hiding the ACPI/DT switch in PSCI code can be a problem if we move the boot code around.I don't necessarily see this patch as an improvement, again it is no big deal regardless.
Lorenzo, thanks a lot for the explanation. I'm fine with either way. Please pick it if it's fine to you. Otherwise, please drop this :)
Thanks,
Gavin
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel