cpufreq: Mark ARM drivers with CPUFREQ_NEED_INITIAL_FREQ_CHECK flag
authorViresh Kumar <viresh.kumar@linaro.org>
Tue, 3 Dec 2013 05:50:45 +0000 (11:20 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 6 Jan 2014 13:17:25 +0000 (14:17 +0100)
Sometimes boot loaders set CPU frequency to a value outside of frequency table
present with cpufreq core. In such cases CPU might be unstable if it has to run
on that frequency for long duration of time and so its better to set it to a
frequency which is specified in frequency table.

On some systems we can't really say what frequency we're running at the moment
and so for these we shouldn't check if we are running at a frequency present in
frequency table. And so we really can't force this for all the cpufreq drivers.

Hence we are created another flag here: CPUFREQ_NEED_INITIAL_FREQ_CHECK that
will be marked by platforms which want to go for this check at boot time.

Initially this is done for all ARM platforms but others may follow if required.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
20 files changed:
drivers/cpufreq/arm_big_little.c
drivers/cpufreq/davinci-cpufreq.c
drivers/cpufreq/dbx500-cpufreq.c
drivers/cpufreq/exynos-cpufreq.c
drivers/cpufreq/exynos5440-cpufreq.c
drivers/cpufreq/imx6q-cpufreq.c
drivers/cpufreq/integrator-cpufreq.c
drivers/cpufreq/kirkwood-cpufreq.c
drivers/cpufreq/omap-cpufreq.c
drivers/cpufreq/pxa2xx-cpufreq.c
drivers/cpufreq/pxa3xx-cpufreq.c
drivers/cpufreq/s3c2416-cpufreq.c
drivers/cpufreq/s3c24xx-cpufreq.c
drivers/cpufreq/s3c64xx-cpufreq.c
drivers/cpufreq/s5pv210-cpufreq.c
drivers/cpufreq/sa1100-cpufreq.c
drivers/cpufreq/sa1110-cpufreq.c
drivers/cpufreq/spear-cpufreq.c
drivers/cpufreq/tegra-cpufreq.c
include/linux/cpufreq.h

index 5519933813ea4996c4dd7b378a1c22d00810811d..72f87e9317e31057525b0785b36d78467890a34c 100644 (file)
@@ -488,7 +488,8 @@ static int bL_cpufreq_exit(struct cpufreq_policy *policy)
 static struct cpufreq_driver bL_cpufreq_driver = {
        .name                   = "arm-big-little",
        .flags                  = CPUFREQ_STICKY |
-                                       CPUFREQ_HAVE_GOVERNOR_PER_POLICY,
+                                       CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
+                                       CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify                 = cpufreq_generic_frequency_table_verify,
        .target_index           = bL_cpufreq_set_target,
        .get                    = bL_cpufreq_get_rate,
index 5e8a854381b781876eb6ae3658e0a40ce632195a..04f3390a7a2cdd0e5cde595d1a38fe745d381c49 100644 (file)
@@ -126,7 +126,7 @@ static int davinci_cpu_init(struct cpufreq_policy *policy)
 }
 
 static struct cpufreq_driver davinci_driver = {
-       .flags          = CPUFREQ_STICKY,
+       .flags          = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify         = davinci_verify_speed,
        .target_index   = davinci_target,
        .get            = davinci_getspeed,
index 0e67ab96321a7aa999802de779d6a65c16a468b0..21d9898e000ca6b0727c9d6ed60a382b45d66365 100644 (file)
@@ -48,7 +48,8 @@ static int dbx500_cpufreq_init(struct cpufreq_policy *policy)
 }
 
 static struct cpufreq_driver dbx500_cpufreq_driver = {
-       .flags  = CPUFREQ_STICKY | CPUFREQ_CONST_LOOPS,
+       .flags  = CPUFREQ_STICKY | CPUFREQ_CONST_LOOPS |
+                       CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify = cpufreq_generic_frequency_table_verify,
        .target_index = dbx500_cpufreq_target,
        .get    = dbx500_cpufreq_getspeed,
index f3c22874da753c07dd5f12d58f4b85a6438a2de3..85e67dc6d0727a2aac8a460eb2313637da4f5ce3 100644 (file)
@@ -218,7 +218,7 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
 }
 
 static struct cpufreq_driver exynos_driver = {
-       .flags          = CPUFREQ_STICKY,
+       .flags          = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify         = cpufreq_generic_frequency_table_verify,
        .target_index   = exynos_target,
        .get            = exynos_getspeed,
index 76bef8b078cbfa7c2d1364375063c344ae00fcd0..ffe6faea3a5fe4b69887b01a1c0317f93305207b 100644 (file)
@@ -312,7 +312,8 @@ static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy)
 }
 
 static struct cpufreq_driver exynos_driver = {
-       .flags          = CPUFREQ_STICKY | CPUFREQ_ASYNC_NOTIFICATION,
+       .flags          = CPUFREQ_STICKY | CPUFREQ_ASYNC_NOTIFICATION |
+                               CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify         = cpufreq_generic_frequency_table_verify,
        .target_index   = exynos_target,
        .get            = exynos_getspeed,
index 564a26523ebc74103197686c2af25e0fd9b2bc92..2938257b8c196e184ebd23d18f63d584e4884e3a 100644 (file)
@@ -143,6 +143,7 @@ static int imx6q_cpufreq_init(struct cpufreq_policy *policy)
 }
 
 static struct cpufreq_driver imx6q_cpufreq_driver = {
+       .flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify = cpufreq_generic_frequency_table_verify,
        .target_index = imx6q_set_target,
        .get = imx6q_get_speed,
index 7d8ab000d3172eb677f0344932cb151cbb2c6b44..0e27844e8c2d91742679580b8596e45d0cfdb6a9 100644 (file)
@@ -190,6 +190,7 @@ static int integrator_cpufreq_init(struct cpufreq_policy *policy)
 }
 
 static struct cpufreq_driver integrator_driver = {
+       .flags          = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify         = integrator_verify_policy,
        .target         = integrator_set_target,
        .get            = integrator_get,
index 0767a4e29dfe2cc3f27ec691558657b7c342d0df..eb7abe345b50dd147351d8f9c22d6be892e5ad0a 100644 (file)
@@ -97,6 +97,7 @@ static int kirkwood_cpufreq_cpu_init(struct cpufreq_policy *policy)
 }
 
 static struct cpufreq_driver kirkwood_cpufreq_driver = {
+       .flags  = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .get    = kirkwood_cpufreq_get_cpu_frequency,
        .verify = cpufreq_generic_frequency_table_verify,
        .target_index = kirkwood_cpufreq_target,
index a0acd0bfba40a361f3ea9eaafc42db928968dea7..5de1e5f73eca349d356a684f31016e0c2b15b2d3 100644 (file)
@@ -162,7 +162,7 @@ static int omap_cpu_exit(struct cpufreq_policy *policy)
 }
 
 static struct cpufreq_driver omap_driver = {
-       .flags          = CPUFREQ_STICKY,
+       .flags          = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify         = cpufreq_generic_frequency_table_verify,
        .target_index   = omap_target,
        .get            = omap_getspeed,
index 0a0f4369636a6e14938e728bba38a3323658e7df..a9195a86b069806e0c54e694a1c15e76b6bb56e2 100644 (file)
@@ -423,6 +423,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)
 }
 
 static struct cpufreq_driver pxa_cpufreq_driver = {
+       .flags  = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify = cpufreq_generic_frequency_table_verify,
        .target_index = pxa_set_target,
        .init   = pxa_cpufreq_init,
index 93840048dd110c5130af9d930b2576562d9f8f1c..3785687e9d70f2d04dc16769e7188a1b2e8e6326 100644 (file)
@@ -201,6 +201,7 @@ static int pxa3xx_cpufreq_init(struct cpufreq_policy *policy)
 }
 
 static struct cpufreq_driver pxa3xx_cpufreq_driver = {
+       .flags          = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify         = cpufreq_generic_frequency_table_verify,
        .target_index   = pxa3xx_cpufreq_set,
        .init           = pxa3xx_cpufreq_init,
index 8d904a00027b5fc5ca3a364ffb2c6be7e298c5fd..826b8be2309942a2b43548806516aa43bca183aa 100644 (file)
@@ -481,7 +481,7 @@ err_hclk:
 }
 
 static struct cpufreq_driver s3c2416_cpufreq_driver = {
-       .flags          = 0,
+       .flags          = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify         = cpufreq_generic_frequency_table_verify,
        .target_index   = s3c2416_cpufreq_set_target,
        .get            = s3c2416_cpufreq_get_speed,
index 35fa697e615a4e251aa52eb1d6de3c25bdf8387c..6a1bf96deec010725081b7942c7789f5755bf6f0 100644 (file)
@@ -448,7 +448,7 @@ static int s3c_cpufreq_resume(struct cpufreq_policy *policy)
 #endif
 
 static struct cpufreq_driver s3c24xx_driver = {
-       .flags          = CPUFREQ_STICKY,
+       .flags          = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .target         = s3c_cpufreq_target,
        .get            = s3c_cpufreq_get,
        .init           = s3c_cpufreq_init,
index 67e302eeefec14abbc30bc5fd3b67773b93b0c18..8435f45d7e9d5985fe5757c556409aeec1ed4416 100644 (file)
@@ -226,7 +226,7 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)
 }
 
 static struct cpufreq_driver s3c64xx_cpufreq_driver = {
-       .flags          = 0,
+       .flags          = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify         = cpufreq_generic_frequency_table_verify,
        .target_index   = s3c64xx_cpufreq_set_target,
        .get            = s3c64xx_cpufreq_get_speed,
index e3973dae28a744a87c80fcea8aef2bd85446d796..ccd548c6f0c19660a3678b6f2724b203f5a163a5 100644 (file)
@@ -560,7 +560,7 @@ static int s5pv210_cpufreq_reboot_notifier_event(struct notifier_block *this,
 }
 
 static struct cpufreq_driver s5pv210_driver = {
-       .flags          = CPUFREQ_STICKY,
+       .flags          = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify         = cpufreq_generic_frequency_table_verify,
        .target_index   = s5pv210_target,
        .get            = s5pv210_getspeed,
index 623da742f8e7fc6890510101b99f110e2a470292..728eab77e8e080457bca09f1ad8d7e69d936e6d1 100644 (file)
@@ -201,7 +201,7 @@ static int __init sa1100_cpu_init(struct cpufreq_policy *policy)
 }
 
 static struct cpufreq_driver sa1100_driver __refdata = {
-       .flags          = CPUFREQ_STICKY,
+       .flags          = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify         = cpufreq_generic_frequency_table_verify,
        .target_index   = sa1100_target,
        .get            = sa11x0_getspeed,
index 2c2b2e601d132f0f40e86c1c37a47a1f82fd5544..546376719d8f317407444419204344c94cd7a853 100644 (file)
@@ -312,7 +312,7 @@ static int __init sa1110_cpu_init(struct cpufreq_policy *policy)
 /* sa1110_driver needs __refdata because it must remain after init registers
  * it with cpufreq_register_driver() */
 static struct cpufreq_driver sa1110_driver __refdata = {
-       .flags          = CPUFREQ_STICKY,
+       .flags          = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify         = cpufreq_generic_frequency_table_verify,
        .target_index   = sa1110_target,
        .get            = sa11x0_getspeed,
index 45ea4c094542d677bf2edd83f642b0173ed90541..c7525fe334077459e3f3df1df6e2ba98c9c69bf6 100644 (file)
@@ -162,7 +162,7 @@ static int spear_cpufreq_init(struct cpufreq_policy *policy)
 
 static struct cpufreq_driver spear_cpufreq_driver = {
        .name           = "cpufreq-spear",
-       .flags          = CPUFREQ_STICKY,
+       .flags          = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify         = cpufreq_generic_frequency_table_verify,
        .target_index   = spear_cpufreq_target,
        .get            = spear_cpufreq_get,
index b7309c37033d57b64d37ca3b93354f0b2848102d..01b5578ffecf8043c6c5175ae09d2e8094a25c7d 100644 (file)
@@ -214,6 +214,7 @@ static int tegra_cpu_exit(struct cpufreq_policy *policy)
 }
 
 static struct cpufreq_driver tegra_cpufreq_driver = {
+       .flags          = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
        .verify         = cpufreq_generic_frequency_table_verify,
        .target_index   = tegra_target,
        .get            = tegra_getspeed,
index 88aa0f342e857a00a579df08a5d28a878c9f657c..91b8c84e8cd0edf4640ee487e8eda21cfad2abd3 100644 (file)
@@ -252,6 +252,15 @@ struct cpufreq_driver {
  */
 #define CPUFREQ_ASYNC_NOTIFICATION  (1 << 4)
 
+/*
+ * Set by drivers which want cpufreq core to check if CPU is running at a
+ * frequency present in freq-table exposed by the driver. For these drivers if
+ * CPU is found running at an out of table freq, we will try to set it to a freq
+ * from the table. And if that fails, we will stop further boot process by
+ * issuing a BUG_ON().
+ */
+#define CPUFREQ_NEED_INITIAL_FREQ_CHECK        (1 << 5)
+
 int cpufreq_register_driver(struct cpufreq_driver *driver_data);
 int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);