aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r--drivers/cpufreq/cpufreq.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index d976e222f10f..6a015ada5285 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -312,6 +312,12 @@ static void __cpufreq_notify_transition(struct cpufreq_policy *policy,
312 switch (state) { 312 switch (state) {
313 313
314 case CPUFREQ_PRECHANGE: 314 case CPUFREQ_PRECHANGE:
315 if (WARN(policy->transition_ongoing,
316 "In middle of another frequency transition\n"))
317 return;
318
319 policy->transition_ongoing = true;
320
315 /* detect if the driver reported a value as "old frequency" 321 /* detect if the driver reported a value as "old frequency"
316 * which is not equal to what the cpufreq core thinks is 322 * which is not equal to what the cpufreq core thinks is
317 * "old frequency". 323 * "old frequency".
@@ -331,6 +337,12 @@ static void __cpufreq_notify_transition(struct cpufreq_policy *policy,
331 break; 337 break;
332 338
333 case CPUFREQ_POSTCHANGE: 339 case CPUFREQ_POSTCHANGE:
340 if (WARN(!policy->transition_ongoing,
341 "No frequency transition in progress\n"))
342 return;
343
344 policy->transition_ongoing = false;
345
334 adjust_jiffies(CPUFREQ_POSTCHANGE, freqs); 346 adjust_jiffies(CPUFREQ_POSTCHANGE, freqs);
335 pr_debug("FREQ: %lu - CPU: %lu", (unsigned long)freqs->new, 347 pr_debug("FREQ: %lu - CPU: %lu", (unsigned long)freqs->new,
336 (unsigned long)freqs->cpu); 348 (unsigned long)freqs->cpu);
@@ -573,7 +585,7 @@ out:
573 return i; 585 return i;
574} 586}
575 587
576static ssize_t show_cpus(const struct cpumask *mask, char *buf) 588ssize_t cpufreq_show_cpus(const struct cpumask *mask, char *buf)
577{ 589{
578 ssize_t i = 0; 590 ssize_t i = 0;
579 unsigned int cpu; 591 unsigned int cpu;
@@ -588,6 +600,7 @@ static ssize_t show_cpus(const struct cpumask *mask, char *buf)
588 i += sprintf(&buf[i], "\n"); 600 i += sprintf(&buf[i], "\n");
589 return i; 601 return i;
590} 602}
603EXPORT_SYMBOL_GPL(cpufreq_show_cpus);
591 604
592/** 605/**
593 * show_related_cpus - show the CPUs affected by each transition even if 606 * show_related_cpus - show the CPUs affected by each transition even if
@@ -595,7 +608,7 @@ static ssize_t show_cpus(const struct cpumask *mask, char *buf)
595 */ 608 */
596static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf) 609static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf)
597{ 610{
598 return show_cpus(policy->related_cpus, buf); 611 return cpufreq_show_cpus(policy->related_cpus, buf);
599} 612}
600 613
601/** 614/**
@@ -603,7 +616,7 @@ static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf)
603 */ 616 */
604static ssize_t show_affected_cpus(struct cpufreq_policy *policy, char *buf) 617static ssize_t show_affected_cpus(struct cpufreq_policy *policy, char *buf)
605{ 618{
606 return show_cpus(policy->cpus, buf); 619 return cpufreq_show_cpus(policy->cpus, buf);
607} 620}
608 621
609static ssize_t store_scaling_setspeed(struct cpufreq_policy *policy, 622static ssize_t store_scaling_setspeed(struct cpufreq_policy *policy,
@@ -1539,6 +1552,8 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
1539 1552
1540 if (cpufreq_disabled()) 1553 if (cpufreq_disabled())
1541 return -ENODEV; 1554 return -ENODEV;
1555 if (policy->transition_ongoing)
1556 return -EBUSY;
1542 1557
1543 /* Make sure that target_freq is within supported range */ 1558 /* Make sure that target_freq is within supported range */
1544 if (target_freq > policy->max) 1559 if (target_freq > policy->max)