cpufreq: Default governor initialisation before use
PATCH 1/1 cpufreq: Default governor initialisation before use
Ensure that the selected default cpufreq governor is initialised before used by the cpufreq driver on boot by using fs_initcall() instead of module_init().
Signed-off-by Johannes Weiner <[email protected]>
---
On boot, speedstep_init() calls into cpufreq_gov_dbs(). The driver has not yet been initialised by cpufreq_gov_dbs_init() and kondemand_wq is still NULL when it is dereferenced.
Changing the drivers module_init() to fs_initcall() fixed it. The same is already done in the performance and userspace governor drivers.
The patch migrates all governors to use fs_initcall() when being the default governor.
drivers/cpufreq/cpufreq_conservative.c | 4 ++++ drivers/cpufreq/cpufreq_ondemand.c | 5 ++++- drivers/cpufreq/cpufreq_performance.c | 4 ++++ drivers/cpufreq/cpufreq_userspace.c | 4 ++++ 4 files changed, 16 insertions(+), 1 deletions(-)
drivers/cpufreq/cpufreq_conservative.c +4 -0
@@ -603,5 +603,9 @@ MODULE_DESCRIPTION ("'cpufreq_conservative' - A dynamic cpufreq governor for " "optimised for use in a battery environment");MODULE_LICENSE ("GPL" ); +#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE +fs_initcall (cpufreq_gov_dbs_init); +#else module_init (cpufreq_gov_dbs_init); +#endif module_exit (cpufreq_gov_dbs_exit);
drivers/cpufreq/cpufreq_ondemand.c +4 -1
@@ -610,6 +610,9 @@ MODULE_DESCRIPTION("'cpufreq_ondemand' - A dynamic cpufreq governor for " "Low Latency Frequency Transition capable processors");MODULE_LICENSE ("GPL" ); +#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND +fs_initcall (cpufreq_gov_dbs_init); +#else module_init (cpufreq_gov_dbs_init); +#endif module_exit (cpufreq_gov_dbs_exit); -
drivers/cpufreq/cpufreq_performance.c +4 -0
@@ -60,5 +60,9 @@ MODULE_AUTHOR("Dominik Brodowski <[email protected]>");MODULE_DESCRIPTION ("CPUfreq policy governor 'performance'" );MODULE_LICENSE ("GPL" ); +#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE fs_initcall (cpufreq_gov_performance_init); +#else +module_init (cpufreq_gov_performance_init); +#endif module_exit (cpufreq_gov_performance_exit);
drivers/cpufreq/cpufreq_userspace.c +4 -0
@@ -231,5 +231,9 @@ MODULE_AUTHOR ("Dominik Brodowski <[email protected]>, Russell King <[email protected].MODULE_DESCRIPTION ("CPUfreq policy governor 'userspace'" );MODULE_LICENSE ("GPL" ); +#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE fs_initcall (cpufreq_gov_userspace_init); +#else +module_init (cpufreq_gov_userspace_init); +#endif module_exit (cpufreq_gov_userspace_exit);