Commit 5ae4a4b4 authored by Viresh Kumar's avatar Viresh Kumar Committed by Rafael J. Wysocki

cpufreq: Remove CPUFREQ_STICKY flag

During cpufreq driver's registration, if the ->init() callback for all
the CPUs fail then there is not much point in keeping the driver around
as it will only account for more of unnecessary noise, for example
cpufreq core will try to suspend/resume the driver which never got
registered properly.

The removal of such a driver is avoided if the driver carries the
CPUFREQ_STICKY flag. This was added way back [1] in 2004 and perhaps no
one should ever need it now. A lot of drivers do set this flag, probably
because they just copied it from other drivers.

This was added earlier for some platforms [2] because their cpufreq
drivers were getting registered before the CPUs were registered with
subsys framework. And hence they used to fail.

The same isn't true anymore though. The current code flow in the kernel
is:

start_kernel()
-> kernel_init()
   -> kernel_init_freeable()
      -> do_basic_setup()
         -> driver_init()
            -> cpu_dev_init()
               -> subsys_system_register() //For CPUs

         -> do_initcalls()
            -> cpufreq_register_driver()

Clearly, the CPUs will always get registered with subsys framework
before any cpufreq driver can get probed. Remove the flag and update the
relevant drivers.

Link: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/include/linux/cpufreq.h?id=7cc9f0d9a1ab04cedc60d64fd8dcf7df224a3b4d # [1]
Link: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/arch/arm/mach-sa1100/cpu-sa1100.c?id=f59d3bbe35f6268d729f51be82af8325d62f20f5 # [2]
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 75a8d877
...@@ -175,7 +175,7 @@ static int cpufreq_exit(struct cpufreq_policy *policy) ...@@ -175,7 +175,7 @@ static int cpufreq_exit(struct cpufreq_policy *policy)
} }
static struct cpufreq_driver dt_cpufreq_driver = { static struct cpufreq_driver dt_cpufreq_driver = {
.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK | .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK |
CPUFREQ_IS_COOLING_DEV, CPUFREQ_IS_COOLING_DEV,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
.target_index = set_target, .target_index = set_target,
......
...@@ -2810,8 +2810,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) ...@@ -2810,8 +2810,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
if (ret) if (ret)
goto err_boost_unreg; goto err_boost_unreg;
if (!(cpufreq_driver->flags & CPUFREQ_STICKY) && if (unlikely(list_empty(&cpufreq_policy_list))) {
list_empty(&cpufreq_policy_list)) {
/* if all ->init() calls failed, unregister */ /* if all ->init() calls failed, unregister */
ret = -ENODEV; ret = -ENODEV;
pr_debug("%s: No CPU initialized for driver %s\n", __func__, pr_debug("%s: No CPU initialized for driver %s\n", __func__,
......
...@@ -95,7 +95,7 @@ static int davinci_cpu_init(struct cpufreq_policy *policy) ...@@ -95,7 +95,7 @@ static int davinci_cpu_init(struct cpufreq_policy *policy)
} }
static struct cpufreq_driver davinci_driver = { static struct cpufreq_driver davinci_driver = {
.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK, .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
.target_index = davinci_target, .target_index = davinci_target,
.get = cpufreq_generic_get, .get = cpufreq_generic_get,
......
...@@ -116,7 +116,7 @@ static int ls1x_cpufreq_exit(struct cpufreq_policy *policy) ...@@ -116,7 +116,7 @@ static int ls1x_cpufreq_exit(struct cpufreq_policy *policy)
static struct cpufreq_driver ls1x_cpufreq_driver = { static struct cpufreq_driver ls1x_cpufreq_driver = {
.name = "cpufreq-ls1x", .name = "cpufreq-ls1x",
.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK, .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
.target_index = ls1x_cpufreq_target, .target_index = ls1x_cpufreq_target,
.get = cpufreq_generic_get, .get = cpufreq_generic_get,
......
...@@ -463,7 +463,7 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy) ...@@ -463,7 +463,7 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy)
} }
static struct cpufreq_driver mtk_cpufreq_driver = { static struct cpufreq_driver mtk_cpufreq_driver = {
.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK | .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK |
CPUFREQ_HAVE_GOVERNOR_PER_POLICY | CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
CPUFREQ_IS_COOLING_DEV, CPUFREQ_IS_COOLING_DEV,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
......
...@@ -144,7 +144,7 @@ static int omap_cpu_exit(struct cpufreq_policy *policy) ...@@ -144,7 +144,7 @@ static int omap_cpu_exit(struct cpufreq_policy *policy)
} }
static struct cpufreq_driver omap_driver = { static struct cpufreq_driver omap_driver = {
.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK, .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
.target_index = omap_target, .target_index = omap_target,
.get = cpufreq_generic_get, .get = cpufreq_generic_get,
......
...@@ -374,7 +374,7 @@ static struct freq_attr *qcom_cpufreq_hw_attr[] = { ...@@ -374,7 +374,7 @@ static struct freq_attr *qcom_cpufreq_hw_attr[] = {
}; };
static struct cpufreq_driver cpufreq_qcom_hw_driver = { static struct cpufreq_driver cpufreq_qcom_hw_driver = {
.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK | .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK |
CPUFREQ_HAVE_GOVERNOR_PER_POLICY | CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
CPUFREQ_IS_COOLING_DEV, CPUFREQ_IS_COOLING_DEV,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
......
...@@ -420,7 +420,7 @@ static int s3c_cpufreq_resume(struct cpufreq_policy *policy) ...@@ -420,7 +420,7 @@ static int s3c_cpufreq_resume(struct cpufreq_policy *policy)
#endif #endif
static struct cpufreq_driver s3c24xx_driver = { static struct cpufreq_driver s3c24xx_driver = {
.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK, .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
.target = s3c_cpufreq_target, .target = s3c_cpufreq_target,
.get = cpufreq_generic_get, .get = cpufreq_generic_get,
.init = s3c_cpufreq_init, .init = s3c_cpufreq_init,
......
...@@ -574,7 +574,7 @@ static int s5pv210_cpufreq_reboot_notifier_event(struct notifier_block *this, ...@@ -574,7 +574,7 @@ static int s5pv210_cpufreq_reboot_notifier_event(struct notifier_block *this,
} }
static struct cpufreq_driver s5pv210_driver = { static struct cpufreq_driver s5pv210_driver = {
.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK, .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
.target_index = s5pv210_target, .target_index = s5pv210_target,
.get = cpufreq_generic_get, .get = cpufreq_generic_get,
......
...@@ -186,7 +186,7 @@ static int __init sa1100_cpu_init(struct cpufreq_policy *policy) ...@@ -186,7 +186,7 @@ static int __init sa1100_cpu_init(struct cpufreq_policy *policy)
} }
static struct cpufreq_driver sa1100_driver __refdata = { static struct cpufreq_driver sa1100_driver __refdata = {
.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK | .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK |
CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING, CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
.target_index = sa1100_target, .target_index = sa1100_target,
......
...@@ -310,7 +310,7 @@ static int __init sa1110_cpu_init(struct cpufreq_policy *policy) ...@@ -310,7 +310,7 @@ static int __init sa1110_cpu_init(struct cpufreq_policy *policy)
/* sa1110_driver needs __refdata because it must remain after init registers /* sa1110_driver needs __refdata because it must remain after init registers
* it with cpufreq_register_driver() */ * it with cpufreq_register_driver() */
static struct cpufreq_driver sa1110_driver __refdata = { static struct cpufreq_driver sa1110_driver __refdata = {
.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK | .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK |
CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING, CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
.target_index = sa1110_target, .target_index = sa1110_target,
......
...@@ -217,7 +217,7 @@ static int scmi_cpufreq_exit(struct cpufreq_policy *policy) ...@@ -217,7 +217,7 @@ static int scmi_cpufreq_exit(struct cpufreq_policy *policy)
static struct cpufreq_driver scmi_cpufreq_driver = { static struct cpufreq_driver scmi_cpufreq_driver = {
.name = "scmi", .name = "scmi",
.flags = CPUFREQ_STICKY | CPUFREQ_HAVE_GOVERNOR_PER_POLICY | .flags = CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
CPUFREQ_NEED_INITIAL_FREQ_CHECK | CPUFREQ_NEED_INITIAL_FREQ_CHECK |
CPUFREQ_IS_COOLING_DEV, CPUFREQ_IS_COOLING_DEV,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
......
...@@ -191,7 +191,7 @@ static int scpi_cpufreq_exit(struct cpufreq_policy *policy) ...@@ -191,7 +191,7 @@ static int scpi_cpufreq_exit(struct cpufreq_policy *policy)
static struct cpufreq_driver scpi_cpufreq_driver = { static struct cpufreq_driver scpi_cpufreq_driver = {
.name = "scpi-cpufreq", .name = "scpi-cpufreq",
.flags = CPUFREQ_STICKY | CPUFREQ_HAVE_GOVERNOR_PER_POLICY | .flags = CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
CPUFREQ_NEED_INITIAL_FREQ_CHECK | CPUFREQ_NEED_INITIAL_FREQ_CHECK |
CPUFREQ_IS_COOLING_DEV, CPUFREQ_IS_COOLING_DEV,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
......
...@@ -160,7 +160,7 @@ static int spear_cpufreq_init(struct cpufreq_policy *policy) ...@@ -160,7 +160,7 @@ static int spear_cpufreq_init(struct cpufreq_policy *policy)
static struct cpufreq_driver spear_cpufreq_driver = { static struct cpufreq_driver spear_cpufreq_driver = {
.name = "cpufreq-spear", .name = "cpufreq-spear",
.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK, .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
.target_index = spear_cpufreq_target, .target_index = spear_cpufreq_target,
.get = cpufreq_generic_get, .get = cpufreq_generic_get,
......
...@@ -117,7 +117,7 @@ static unsigned int tegra186_cpufreq_get(unsigned int cpu) ...@@ -117,7 +117,7 @@ static unsigned int tegra186_cpufreq_get(unsigned int cpu)
static struct cpufreq_driver tegra186_cpufreq_driver = { static struct cpufreq_driver tegra186_cpufreq_driver = {
.name = "tegra186", .name = "tegra186",
.flags = CPUFREQ_STICKY | CPUFREQ_HAVE_GOVERNOR_PER_POLICY | .flags = CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
CPUFREQ_NEED_INITIAL_FREQ_CHECK, CPUFREQ_NEED_INITIAL_FREQ_CHECK,
.get = tegra186_cpufreq_get, .get = tegra186_cpufreq_get,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
......
...@@ -272,8 +272,7 @@ static int tegra194_cpufreq_set_target(struct cpufreq_policy *policy, ...@@ -272,8 +272,7 @@ static int tegra194_cpufreq_set_target(struct cpufreq_policy *policy,
static struct cpufreq_driver tegra194_cpufreq_driver = { static struct cpufreq_driver tegra194_cpufreq_driver = {
.name = "tegra194", .name = "tegra194",
.flags = CPUFREQ_STICKY | CPUFREQ_CONST_LOOPS | .flags = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
CPUFREQ_NEED_INITIAL_FREQ_CHECK,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
.target_index = tegra194_cpufreq_set_target, .target_index = tegra194_cpufreq_set_target,
.get = tegra194_get_speed, .get = tegra194_get_speed,
......
...@@ -486,8 +486,7 @@ static void ve_spc_cpufreq_ready(struct cpufreq_policy *policy) ...@@ -486,8 +486,7 @@ static void ve_spc_cpufreq_ready(struct cpufreq_policy *policy)
static struct cpufreq_driver ve_spc_cpufreq_driver = { static struct cpufreq_driver ve_spc_cpufreq_driver = {
.name = "vexpress-spc", .name = "vexpress-spc",
.flags = CPUFREQ_STICKY | .flags = CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
CPUFREQ_NEED_INITIAL_FREQ_CHECK, CPUFREQ_NEED_INITIAL_FREQ_CHECK,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
.target_index = ve_spc_cpufreq_set_target, .target_index = ve_spc_cpufreq_set_target,
......
...@@ -387,8 +387,13 @@ struct cpufreq_driver { ...@@ -387,8 +387,13 @@ struct cpufreq_driver {
/* flags */ /* flags */
/* driver isn't removed even if all ->init() calls failed */ /*
#define CPUFREQ_STICKY BIT(0) * Set by drivers that need to update internale upper and lower boundaries along
* with the target frequency and so the core and governors should also invoke
* the diver if the target frequency does not change, but the policy min or max
* may have changed.
*/
#define CPUFREQ_NEED_UPDATE_LIMITS BIT(0)
/* loops_per_jiffy or other kernel "constants" aren't affected by frequency transitions */ /* loops_per_jiffy or other kernel "constants" aren't affected by frequency transitions */
#define CPUFREQ_CONST_LOOPS BIT(1) #define CPUFREQ_CONST_LOOPS BIT(1)
...@@ -432,14 +437,6 @@ struct cpufreq_driver { ...@@ -432,14 +437,6 @@ struct cpufreq_driver {
*/ */
#define CPUFREQ_IS_COOLING_DEV BIT(7) #define CPUFREQ_IS_COOLING_DEV BIT(7)
/*
* Set by drivers that need to update internale upper and lower boundaries along
* with the target frequency and so the core and governors should also invoke
* the diver if the target frequency does not change, but the policy min or max
* may have changed.
*/
#define CPUFREQ_NEED_UPDATE_LIMITS BIT(8)
int cpufreq_register_driver(struct cpufreq_driver *driver_data); int cpufreq_register_driver(struct cpufreq_driver *driver_data);
int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment