diff options
Diffstat (limited to 'drivers/cpufreq/cpufreq_ondemand.c')
| -rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 3e6ffcaa5af4..693e540481b4 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include <linux/types.h> | 21 | #include <linux/types.h> |
| 22 | #include <linux/fs.h> | 22 | #include <linux/fs.h> |
| 23 | #include <linux/sysfs.h> | 23 | #include <linux/sysfs.h> |
| 24 | #include <linux/cpu.h> | ||
| 24 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
| 25 | #include <linux/kmod.h> | 26 | #include <linux/kmod.h> |
| 26 | #include <linux/workqueue.h> | 27 | #include <linux/workqueue.h> |
| @@ -71,6 +72,14 @@ static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); | |||
| 71 | 72 | ||
| 72 | static unsigned int dbs_enable; /* number of CPUs using this policy */ | 73 | static unsigned int dbs_enable; /* number of CPUs using this policy */ |
| 73 | 74 | ||
| 75 | /* | ||
| 76 | * DEADLOCK ALERT! There is a ordering requirement between cpu_hotplug | ||
| 77 | * lock and dbs_mutex. cpu_hotplug lock should always be held before | ||
| 78 | * dbs_mutex. If any function that can potentially take cpu_hotplug lock | ||
| 79 | * (like __cpufreq_driver_target()) is being called with dbs_mutex taken, then | ||
| 80 | * cpu_hotplug lock should be taken before that. Note that cpu_hotplug lock | ||
| 81 | * is recursive for the same process. -Venki | ||
| 82 | */ | ||
| 74 | static DEFINE_MUTEX (dbs_mutex); | 83 | static DEFINE_MUTEX (dbs_mutex); |
| 75 | static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); | 84 | static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); |
| 76 | 85 | ||
| @@ -363,12 +372,14 @@ static void dbs_check_cpu(int cpu) | |||
| 363 | static void do_dbs_timer(void *data) | 372 | static void do_dbs_timer(void *data) |
| 364 | { | 373 | { |
| 365 | int i; | 374 | int i; |
| 375 | lock_cpu_hotplug(); | ||
| 366 | mutex_lock(&dbs_mutex); | 376 | mutex_lock(&dbs_mutex); |
| 367 | for_each_online_cpu(i) | 377 | for_each_online_cpu(i) |
| 368 | dbs_check_cpu(i); | 378 | dbs_check_cpu(i); |
| 369 | queue_delayed_work(dbs_workq, &dbs_work, | 379 | queue_delayed_work(dbs_workq, &dbs_work, |
| 370 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); | 380 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); |
| 371 | mutex_unlock(&dbs_mutex); | 381 | mutex_unlock(&dbs_mutex); |
| 382 | unlock_cpu_hotplug(); | ||
| 372 | } | 383 | } |
| 373 | 384 | ||
| 374 | static inline void dbs_timer_init(void) | 385 | static inline void dbs_timer_init(void) |
| @@ -469,6 +480,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
| 469 | break; | 480 | break; |
| 470 | 481 | ||
| 471 | case CPUFREQ_GOV_LIMITS: | 482 | case CPUFREQ_GOV_LIMITS: |
| 483 | lock_cpu_hotplug(); | ||
| 472 | mutex_lock(&dbs_mutex); | 484 | mutex_lock(&dbs_mutex); |
| 473 | if (policy->max < this_dbs_info->cur_policy->cur) | 485 | if (policy->max < this_dbs_info->cur_policy->cur) |
| 474 | __cpufreq_driver_target( | 486 | __cpufreq_driver_target( |
| @@ -479,6 +491,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
| 479 | this_dbs_info->cur_policy, | 491 | this_dbs_info->cur_policy, |
| 480 | policy->min, CPUFREQ_RELATION_L); | 492 | policy->min, CPUFREQ_RELATION_L); |
| 481 | mutex_unlock(&dbs_mutex); | 493 | mutex_unlock(&dbs_mutex); |
| 494 | unlock_cpu_hotplug(); | ||
| 482 | break; | 495 | break; |
| 483 | } | 496 | } |
| 484 | return 0; | 497 | return 0; |
