aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/imx6q-cpufreq.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2013-06-19 01:48:20 -0400
committerViresh Kumar <viresh.kumar@linaro.org>2013-06-24 08:49:00 -0400
commit5a571c352db1eb0aa6325d71807bb40b972faa3b (patch)
treedca3248b7307c87f177ed69cd95ac0abb2a41856 /drivers/cpufreq/imx6q-cpufreq.c
parentc3aca6b1ce17a2e866788bc2bd40e25ef6e5ba58 (diff)
cpufreq: imx6q: call CPUFREQ_POSTCHANGE notfier in error cases
PRECHANGE and POSTCHANGE notifiers must be called in groups, i.e either both should be called or both shouldn't be. In case we have started PRECHANGE notifier and found an error, we must call POSTCHANGE notifier with freqs.new = freqs.old to guarantee that sequence of calling notifiers is complete. This patch fixes it. This also moves PRECHANGE notifier down so that we call it just before starting frequency transition. Acked-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'drivers/cpufreq/imx6q-cpufreq.c')
-rw-r--r--drivers/cpufreq/imx6q-cpufreq.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index b78bc35973ba..e37cdaedbb5b 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -68,8 +68,6 @@ static int imx6q_set_target(struct cpufreq_policy *policy,
68 if (freqs.old == freqs.new) 68 if (freqs.old == freqs.new)
69 return 0; 69 return 0;
70 70
71 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
72
73 rcu_read_lock(); 71 rcu_read_lock();
74 opp = opp_find_freq_ceil(cpu_dev, &freq_hz); 72 opp = opp_find_freq_ceil(cpu_dev, &freq_hz);
75 if (IS_ERR(opp)) { 73 if (IS_ERR(opp)) {
@@ -86,13 +84,16 @@ static int imx6q_set_target(struct cpufreq_policy *policy,
86 freqs.old / 1000, volt_old / 1000, 84 freqs.old / 1000, volt_old / 1000,
87 freqs.new / 1000, volt / 1000); 85 freqs.new / 1000, volt / 1000);
88 86
87 cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
88
89 /* scaling up? scale voltage before frequency */ 89 /* scaling up? scale voltage before frequency */
90 if (freqs.new > freqs.old) { 90 if (freqs.new > freqs.old) {
91 ret = regulator_set_voltage_tol(arm_reg, volt, 0); 91 ret = regulator_set_voltage_tol(arm_reg, volt, 0);
92 if (ret) { 92 if (ret) {
93 dev_err(cpu_dev, 93 dev_err(cpu_dev,
94 "failed to scale vddarm up: %d\n", ret); 94 "failed to scale vddarm up: %d\n", ret);
95 return ret; 95 freqs.new = freqs.old;
96 goto post_notify;
96 } 97 }
97 98
98 /* 99 /*
@@ -145,15 +146,18 @@ static int imx6q_set_target(struct cpufreq_policy *policy,
145 if (ret) { 146 if (ret) {
146 dev_err(cpu_dev, "failed to set clock rate: %d\n", ret); 147 dev_err(cpu_dev, "failed to set clock rate: %d\n", ret);
147 regulator_set_voltage_tol(arm_reg, volt_old, 0); 148 regulator_set_voltage_tol(arm_reg, volt_old, 0);
148 return ret; 149 freqs.new = freqs.old;
150 goto post_notify;
149 } 151 }
150 152
151 /* scaling down? scale voltage after frequency */ 153 /* scaling down? scale voltage after frequency */
152 if (freqs.new < freqs.old) { 154 if (freqs.new < freqs.old) {
153 ret = regulator_set_voltage_tol(arm_reg, volt, 0); 155 ret = regulator_set_voltage_tol(arm_reg, volt, 0);
154 if (ret) 156 if (ret) {
155 dev_warn(cpu_dev, 157 dev_warn(cpu_dev,
156 "failed to scale vddarm down: %d\n", ret); 158 "failed to scale vddarm down: %d\n", ret);
159 ret = 0;
160 }
157 161
158 if (freqs.old == FREQ_1P2_GHZ / 1000) { 162 if (freqs.old == FREQ_1P2_GHZ / 1000) {
159 regulator_set_voltage_tol(pu_reg, 163 regulator_set_voltage_tol(pu_reg,
@@ -163,9 +167,10 @@ static int imx6q_set_target(struct cpufreq_policy *policy,
163 } 167 }
164 } 168 }
165 169
170post_notify:
166 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); 171 cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
167 172
168 return 0; 173 return ret;
169} 174}
170 175
171static int imx6q_cpufreq_init(struct cpufreq_policy *policy) 176static int imx6q_cpufreq_init(struct cpufreq_policy *policy)