aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-10-12 14:24:24 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-10-12 14:24:24 -0400
commit51ec005a94b7da34434211f23465d3b7dc841148 (patch)
treeae93bb6ff58a7d80e1063638fb3efd1f92e49e0a
parent55582bccdc1e89ecc973c260d46e247df675d4df (diff)
parentd43b1b6f8e5b3219d4d02ea7fadcf67fecf78b1a (diff)
Merge back earlier cpufreq material for v4.4.
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c31
-rw-r--r--drivers/cpufreq/cpufreq_governor.c12
-rw-r--r--drivers/cpufreq/cpufreq_governor.h1
-rw-r--r--drivers/cpufreq/imx6q-cpufreq.c50
-rw-r--r--drivers/cpufreq/integrator-cpufreq.c2
-rw-r--r--drivers/cpufreq/powernv-cpufreq.c10
-rw-r--r--drivers/cpufreq/tegra20-cpufreq.c2
7 files changed, 74 insertions, 34 deletions
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index 84a1506950a7..1fa1deb6e91f 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -23,6 +23,19 @@
23 23
24static DEFINE_PER_CPU(struct cs_cpu_dbs_info_s, cs_cpu_dbs_info); 24static DEFINE_PER_CPU(struct cs_cpu_dbs_info_s, cs_cpu_dbs_info);
25 25
26static int cs_cpufreq_governor_dbs(struct cpufreq_policy *policy,
27 unsigned int event);
28
29#ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE
30static
31#endif
32struct cpufreq_governor cpufreq_gov_conservative = {
33 .name = "conservative",
34 .governor = cs_cpufreq_governor_dbs,
35 .max_transition_latency = TRANSITION_LATENCY_LIMIT,
36 .owner = THIS_MODULE,
37};
38
26static inline unsigned int get_freq_target(struct cs_dbs_tuners *cs_tuners, 39static inline unsigned int get_freq_target(struct cs_dbs_tuners *cs_tuners,
27 struct cpufreq_policy *policy) 40 struct cpufreq_policy *policy)
28{ 41{
@@ -119,12 +132,14 @@ static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
119 struct cpufreq_freqs *freq = data; 132 struct cpufreq_freqs *freq = data;
120 struct cs_cpu_dbs_info_s *dbs_info = 133 struct cs_cpu_dbs_info_s *dbs_info =
121 &per_cpu(cs_cpu_dbs_info, freq->cpu); 134 &per_cpu(cs_cpu_dbs_info, freq->cpu);
122 struct cpufreq_policy *policy; 135 struct cpufreq_policy *policy = cpufreq_cpu_get_raw(freq->cpu);
123 136
124 if (!dbs_info->enable) 137 if (!policy)
125 return 0; 138 return 0;
126 139
127 policy = dbs_info->cdbs.shared->policy; 140 /* policy isn't governed by conservative governor */
141 if (policy->governor != &cpufreq_gov_conservative)
142 return 0;
128 143
129 /* 144 /*
130 * we only care if our internally tracked freq moves outside the 'valid' 145 * we only care if our internally tracked freq moves outside the 'valid'
@@ -367,16 +382,6 @@ static int cs_cpufreq_governor_dbs(struct cpufreq_policy *policy,
367 return cpufreq_governor_dbs(policy, &cs_dbs_cdata, event); 382 return cpufreq_governor_dbs(policy, &cs_dbs_cdata, event);
368} 383}
369 384
370#ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE
371static
372#endif
373struct cpufreq_governor cpufreq_gov_conservative = {
374 .name = "conservative",
375 .governor = cs_cpufreq_governor_dbs,
376 .max_transition_latency = TRANSITION_LATENCY_LIMIT,
377 .owner = THIS_MODULE,
378};
379
380static int __init cpufreq_gov_dbs_init(void) 385static int __init cpufreq_gov_dbs_init(void)
381{ 386{
382 return cpufreq_register_governor(&cpufreq_gov_conservative); 387 return cpufreq_register_governor(&cpufreq_gov_conservative);
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
index 939197ffa4ac..750626d8fb03 100644
--- a/drivers/cpufreq/cpufreq_governor.c
+++ b/drivers/cpufreq/cpufreq_governor.c
@@ -463,7 +463,6 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy,
463 cdata->get_cpu_dbs_info_s(cpu); 463 cdata->get_cpu_dbs_info_s(cpu);
464 464
465 cs_dbs_info->down_skip = 0; 465 cs_dbs_info->down_skip = 0;
466 cs_dbs_info->enable = 1;
467 cs_dbs_info->requested_freq = policy->cur; 466 cs_dbs_info->requested_freq = policy->cur;
468 } else { 467 } else {
469 struct od_ops *od_ops = cdata->gov_ops; 468 struct od_ops *od_ops = cdata->gov_ops;
@@ -482,9 +481,7 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy,
482static int cpufreq_governor_stop(struct cpufreq_policy *policy, 481static int cpufreq_governor_stop(struct cpufreq_policy *policy,
483 struct dbs_data *dbs_data) 482 struct dbs_data *dbs_data)
484{ 483{
485 struct common_dbs_data *cdata = dbs_data->cdata; 484 struct cpu_dbs_info *cdbs = dbs_data->cdata->get_cpu_cdbs(policy->cpu);
486 unsigned int cpu = policy->cpu;
487 struct cpu_dbs_info *cdbs = cdata->get_cpu_cdbs(cpu);
488 struct cpu_common_dbs_info *shared = cdbs->shared; 485 struct cpu_common_dbs_info *shared = cdbs->shared;
489 486
490 /* State should be equivalent to START */ 487 /* State should be equivalent to START */
@@ -493,13 +490,6 @@ static int cpufreq_governor_stop(struct cpufreq_policy *policy,
493 490
494 gov_cancel_work(dbs_data, policy); 491 gov_cancel_work(dbs_data, policy);
495 492
496 if (cdata->governor == GOV_CONSERVATIVE) {
497 struct cs_cpu_dbs_info_s *cs_dbs_info =
498 cdata->get_cpu_dbs_info_s(cpu);
499
500 cs_dbs_info->enable = 0;
501 }
502
503 shared->policy = NULL; 493 shared->policy = NULL;
504 mutex_destroy(&shared->timer_mutex); 494 mutex_destroy(&shared->timer_mutex);
505 return 0; 495 return 0;
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
index 50f171796632..5621bb03e874 100644
--- a/drivers/cpufreq/cpufreq_governor.h
+++ b/drivers/cpufreq/cpufreq_governor.h
@@ -170,7 +170,6 @@ struct cs_cpu_dbs_info_s {
170 struct cpu_dbs_info cdbs; 170 struct cpu_dbs_info cdbs;
171 unsigned int down_skip; 171 unsigned int down_skip;
172 unsigned int requested_freq; 172 unsigned int requested_freq;
173 unsigned int enable:1;
174}; 173};
175 174
176/* Per policy Governors sysfs tunables */ 175/* Per policy Governors sysfs tunables */
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index 380a90d3c57e..9b4a7bd04dea 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -30,6 +30,10 @@ static struct clk *pll1_sw_clk;
30static struct clk *step_clk; 30static struct clk *step_clk;
31static struct clk *pll2_pfd2_396m_clk; 31static struct clk *pll2_pfd2_396m_clk;
32 32
33/* clk used by i.MX6UL */
34static struct clk *pll2_bus_clk;
35static struct clk *secondary_sel_clk;
36
33static struct device *cpu_dev; 37static struct device *cpu_dev;
34static bool free_opp; 38static bool free_opp;
35static struct cpufreq_frequency_table *freq_table; 39static struct cpufreq_frequency_table *freq_table;
@@ -91,16 +95,36 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
91 * The setpoints are selected per PLL/PDF frequencies, so we need to 95 * The setpoints are selected per PLL/PDF frequencies, so we need to
92 * reprogram PLL for frequency scaling. The procedure of reprogramming 96 * reprogram PLL for frequency scaling. The procedure of reprogramming
93 * PLL1 is as below. 97 * PLL1 is as below.
94 * 98 * For i.MX6UL, it has a secondary clk mux, the cpu frequency change
99 * flow is slightly different from other i.MX6 OSC.
100 * The cpu frequeny change flow for i.MX6(except i.MX6UL) is as below:
95 * - Enable pll2_pfd2_396m_clk and reparent pll1_sw_clk to it 101 * - Enable pll2_pfd2_396m_clk and reparent pll1_sw_clk to it
96 * - Reprogram pll1_sys_clk and reparent pll1_sw_clk back to it 102 * - Reprogram pll1_sys_clk and reparent pll1_sw_clk back to it
97 * - Disable pll2_pfd2_396m_clk 103 * - Disable pll2_pfd2_396m_clk
98 */ 104 */
99 clk_set_parent(step_clk, pll2_pfd2_396m_clk); 105 if (of_machine_is_compatible("fsl,imx6ul")) {
100 clk_set_parent(pll1_sw_clk, step_clk); 106 /*
101 if (freq_hz > clk_get_rate(pll2_pfd2_396m_clk)) { 107 * When changing pll1_sw_clk's parent to pll1_sys_clk,
102 clk_set_rate(pll1_sys_clk, new_freq * 1000); 108 * CPU may run at higher than 528MHz, this will lead to
109 * the system unstable if the voltage is lower than the
110 * voltage of 528MHz, so lower the CPU frequency to one
111 * half before changing CPU frequency.
112 */
113 clk_set_rate(arm_clk, (old_freq >> 1) * 1000);
103 clk_set_parent(pll1_sw_clk, pll1_sys_clk); 114 clk_set_parent(pll1_sw_clk, pll1_sys_clk);
115 if (freq_hz > clk_get_rate(pll2_pfd2_396m_clk))
116 clk_set_parent(secondary_sel_clk, pll2_bus_clk);
117 else
118 clk_set_parent(secondary_sel_clk, pll2_pfd2_396m_clk);
119 clk_set_parent(step_clk, secondary_sel_clk);
120 clk_set_parent(pll1_sw_clk, step_clk);
121 } else {
122 clk_set_parent(step_clk, pll2_pfd2_396m_clk);
123 clk_set_parent(pll1_sw_clk, step_clk);
124 if (freq_hz > clk_get_rate(pll2_pfd2_396m_clk)) {
125 clk_set_rate(pll1_sys_clk, new_freq * 1000);
126 clk_set_parent(pll1_sw_clk, pll1_sys_clk);
127 }
104 } 128 }
105 129
106 /* Ensure the arm clock divider is what we expect */ 130 /* Ensure the arm clock divider is what we expect */
@@ -186,6 +210,16 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
186 goto put_clk; 210 goto put_clk;
187 } 211 }
188 212
213 if (of_machine_is_compatible("fsl,imx6ul")) {
214 pll2_bus_clk = clk_get(cpu_dev, "pll2_bus");
215 secondary_sel_clk = clk_get(cpu_dev, "secondary_sel");
216 if (IS_ERR(pll2_bus_clk) || IS_ERR(secondary_sel_clk)) {
217 dev_err(cpu_dev, "failed to get clocks specific to imx6ul\n");
218 ret = -ENOENT;
219 goto put_clk;
220 }
221 }
222
189 arm_reg = regulator_get(cpu_dev, "arm"); 223 arm_reg = regulator_get(cpu_dev, "arm");
190 pu_reg = regulator_get_optional(cpu_dev, "pu"); 224 pu_reg = regulator_get_optional(cpu_dev, "pu");
191 soc_reg = regulator_get(cpu_dev, "soc"); 225 soc_reg = regulator_get(cpu_dev, "soc");
@@ -331,6 +365,10 @@ put_clk:
331 clk_put(step_clk); 365 clk_put(step_clk);
332 if (!IS_ERR(pll2_pfd2_396m_clk)) 366 if (!IS_ERR(pll2_pfd2_396m_clk))
333 clk_put(pll2_pfd2_396m_clk); 367 clk_put(pll2_pfd2_396m_clk);
368 if (!IS_ERR(pll2_bus_clk))
369 clk_put(pll2_bus_clk);
370 if (!IS_ERR(secondary_sel_clk))
371 clk_put(secondary_sel_clk);
334 of_node_put(np); 372 of_node_put(np);
335 return ret; 373 return ret;
336} 374}
@@ -350,6 +388,8 @@ static int imx6q_cpufreq_remove(struct platform_device *pdev)
350 clk_put(pll1_sw_clk); 388 clk_put(pll1_sw_clk);
351 clk_put(step_clk); 389 clk_put(step_clk);
352 clk_put(pll2_pfd2_396m_clk); 390 clk_put(pll2_pfd2_396m_clk);
391 clk_put(pll2_bus_clk);
392 clk_put(secondary_sel_clk);
353 393
354 return 0; 394 return 0;
355} 395}
diff --git a/drivers/cpufreq/integrator-cpufreq.c b/drivers/cpufreq/integrator-cpufreq.c
index 2faa4216bf2a..79e3ff2771a6 100644
--- a/drivers/cpufreq/integrator-cpufreq.c
+++ b/drivers/cpufreq/integrator-cpufreq.c
@@ -221,6 +221,8 @@ static const struct of_device_id integrator_cpufreq_match[] = {
221 { }, 221 { },
222}; 222};
223 223
224MODULE_DEVICE_TABLE(of, integrator_cpufreq_match);
225
224static struct platform_driver integrator_cpufreq_driver = { 226static struct platform_driver integrator_cpufreq_driver = {
225 .driver = { 227 .driver = {
226 .name = "integrator-cpufreq", 228 .name = "integrator-cpufreq",
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 64994e10638e..cb501386eb6e 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -327,8 +327,14 @@ static void powernv_cpufreq_throttle_check(void *data)
327 if (chips[i].throttled) 327 if (chips[i].throttled)
328 goto next; 328 goto next;
329 chips[i].throttled = true; 329 chips[i].throttled = true;
330 pr_info("CPU %d on Chip %u has Pmax reduced to %d\n", cpu, 330 if (pmsr_pmax < powernv_pstate_info.nominal)
331 chips[i].id, pmsr_pmax); 331 pr_crit("CPU %d on Chip %u has Pmax reduced below nominal frequency (%d < %d)\n",
332 cpu, chips[i].id, pmsr_pmax,
333 powernv_pstate_info.nominal);
334 else
335 pr_info("CPU %d on Chip %u has Pmax reduced below turbo frequency (%d < %d)\n",
336 cpu, chips[i].id, pmsr_pmax,
337 powernv_pstate_info.max);
332 } else if (chips[i].throttled) { 338 } else if (chips[i].throttled) {
333 chips[i].throttled = false; 339 chips[i].throttled = false;
334 pr_info("CPU %d on Chip %u has Pmax restored to %d\n", cpu, 340 pr_info("CPU %d on Chip %u has Pmax restored to %d\n", cpu,
diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
index 8084c7f7e206..2bd62845e9d5 100644
--- a/drivers/cpufreq/tegra20-cpufreq.c
+++ b/drivers/cpufreq/tegra20-cpufreq.c
@@ -175,9 +175,7 @@ static struct cpufreq_driver tegra_cpufreq_driver = {
175 .exit = tegra_cpu_exit, 175 .exit = tegra_cpu_exit,
176 .name = "tegra", 176 .name = "tegra",
177 .attr = cpufreq_generic_attr, 177 .attr = cpufreq_generic_attr,
178#ifdef CONFIG_PM
179 .suspend = cpufreq_generic_suspend, 178 .suspend = cpufreq_generic_suspend,
180#endif
181}; 179};
182 180
183static int __init tegra_cpufreq_init(void) 181static int __init tegra_cpufreq_init(void)