diff options
Diffstat (limited to 'drivers/cpufreq/cpufreq_conservative.c')
| -rw-r--r-- | drivers/cpufreq/cpufreq_conservative.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index e07a35487bde..b3ebc8f01975 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include <linux/types.h> | 22 | #include <linux/types.h> |
| 23 | #include <linux/fs.h> | 23 | #include <linux/fs.h> |
| 24 | #include <linux/sysfs.h> | 24 | #include <linux/sysfs.h> |
| 25 | #include <linux/cpu.h> | ||
| 25 | #include <linux/sched.h> | 26 | #include <linux/sched.h> |
| 26 | #include <linux/kmod.h> | 27 | #include <linux/kmod.h> |
| 27 | #include <linux/workqueue.h> | 28 | #include <linux/workqueue.h> |
| @@ -72,6 +73,14 @@ static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); | |||
| 72 | 73 | ||
| 73 | static unsigned int dbs_enable; /* number of CPUs using this policy */ | 74 | static unsigned int dbs_enable; /* number of CPUs using this policy */ |
| 74 | 75 | ||
| 76 | /* | ||
| 77 | * DEADLOCK ALERT! There is a ordering requirement between cpu_hotplug | ||
| 78 | * lock and dbs_mutex. cpu_hotplug lock should always be held before | ||
| 79 | * dbs_mutex. If any function that can potentially take cpu_hotplug lock | ||
| 80 | * (like __cpufreq_driver_target()) is being called with dbs_mutex taken, then | ||
| 81 | * cpu_hotplug lock should be taken before that. Note that cpu_hotplug lock | ||
| 82 | * is recursive for the same process. -Venki | ||
| 83 | */ | ||
| 75 | static DEFINE_MUTEX (dbs_mutex); | 84 | static DEFINE_MUTEX (dbs_mutex); |
| 76 | static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); | 85 | static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); |
| 77 | 86 | ||
| @@ -414,12 +423,14 @@ static void dbs_check_cpu(int cpu) | |||
| 414 | static void do_dbs_timer(void *data) | 423 | static void do_dbs_timer(void *data) |
| 415 | { | 424 | { |
| 416 | int i; | 425 | int i; |
| 426 | lock_cpu_hotplug(); | ||
| 417 | mutex_lock(&dbs_mutex); | 427 | mutex_lock(&dbs_mutex); |
| 418 | for_each_online_cpu(i) | 428 | for_each_online_cpu(i) |
| 419 | dbs_check_cpu(i); | 429 | dbs_check_cpu(i); |
| 420 | schedule_delayed_work(&dbs_work, | 430 | schedule_delayed_work(&dbs_work, |
| 421 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); | 431 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); |
| 422 | mutex_unlock(&dbs_mutex); | 432 | mutex_unlock(&dbs_mutex); |
| 433 | unlock_cpu_hotplug(); | ||
| 423 | } | 434 | } |
| 424 | 435 | ||
| 425 | static inline void dbs_timer_init(void) | 436 | static inline void dbs_timer_init(void) |
| @@ -514,6 +525,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
| 514 | break; | 525 | break; |
| 515 | 526 | ||
| 516 | case CPUFREQ_GOV_LIMITS: | 527 | case CPUFREQ_GOV_LIMITS: |
| 528 | lock_cpu_hotplug(); | ||
| 517 | mutex_lock(&dbs_mutex); | 529 | mutex_lock(&dbs_mutex); |
| 518 | if (policy->max < this_dbs_info->cur_policy->cur) | 530 | if (policy->max < this_dbs_info->cur_policy->cur) |
| 519 | __cpufreq_driver_target( | 531 | __cpufreq_driver_target( |
| @@ -524,6 +536,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
| 524 | this_dbs_info->cur_policy, | 536 | this_dbs_info->cur_policy, |
| 525 | policy->min, CPUFREQ_RELATION_L); | 537 | policy->min, CPUFREQ_RELATION_L); |
| 526 | mutex_unlock(&dbs_mutex); | 538 | mutex_unlock(&dbs_mutex); |
| 539 | unlock_cpu_hotplug(); | ||
| 527 | break; | 540 | break; |
| 528 | } | 541 | } |
| 529 | return 0; | 542 | return 0; |
