diff options
Diffstat (limited to 'drivers/cpufreq/cpufreq_conservative.c')
| -rw-r--r-- | drivers/cpufreq/cpufreq_conservative.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index 39543a2bed0f..ac38766b2583 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
| @@ -28,7 +28,7 @@ | |||
| 28 | #include <linux/jiffies.h> | 28 | #include <linux/jiffies.h> |
| 29 | #include <linux/kernel_stat.h> | 29 | #include <linux/kernel_stat.h> |
| 30 | #include <linux/percpu.h> | 30 | #include <linux/percpu.h> |
| 31 | 31 | #include <linux/mutex.h> | |
| 32 | /* | 32 | /* |
| 33 | * dbs is used in this file as a shortform for demandbased switching | 33 | * dbs is used in this file as a shortform for demandbased switching |
| 34 | * It helps to keep variable names smaller, simpler | 34 | * It helps to keep variable names smaller, simpler |
| @@ -71,7 +71,7 @@ static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); | |||
| 71 | 71 | ||
| 72 | static unsigned int dbs_enable; /* number of CPUs using this policy */ | 72 | static unsigned int dbs_enable; /* number of CPUs using this policy */ |
| 73 | 73 | ||
| 74 | static DECLARE_MUTEX (dbs_sem); | 74 | static DEFINE_MUTEX (dbs_mutex); |
| 75 | static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); | 75 | static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); |
| 76 | 76 | ||
| 77 | struct dbs_tuners { | 77 | struct dbs_tuners { |
| @@ -139,9 +139,9 @@ static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, | |||
| 139 | if (ret != 1 ) | 139 | if (ret != 1 ) |
| 140 | return -EINVAL; | 140 | return -EINVAL; |
| 141 | 141 | ||
| 142 | down(&dbs_sem); | 142 | mutex_lock(&dbs_mutex); |
| 143 | dbs_tuners_ins.sampling_down_factor = input; | 143 | dbs_tuners_ins.sampling_down_factor = input; |
| 144 | up(&dbs_sem); | 144 | mutex_unlock(&dbs_mutex); |
| 145 | 145 | ||
| 146 | return count; | 146 | return count; |
| 147 | } | 147 | } |
| @@ -153,14 +153,14 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused, | |||
| 153 | int ret; | 153 | int ret; |
| 154 | ret = sscanf (buf, "%u", &input); | 154 | ret = sscanf (buf, "%u", &input); |
| 155 | 155 | ||
| 156 | down(&dbs_sem); | 156 | mutex_lock(&dbs_mutex); |
| 157 | if (ret != 1 || input > MAX_SAMPLING_RATE || input < MIN_SAMPLING_RATE) { | 157 | if (ret != 1 || input > MAX_SAMPLING_RATE || input < MIN_SAMPLING_RATE) { |
| 158 | up(&dbs_sem); | 158 | mutex_unlock(&dbs_mutex); |
| 159 | return -EINVAL; | 159 | return -EINVAL; |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | dbs_tuners_ins.sampling_rate = input; | 162 | dbs_tuners_ins.sampling_rate = input; |
| 163 | up(&dbs_sem); | 163 | mutex_unlock(&dbs_mutex); |
| 164 | 164 | ||
| 165 | return count; | 165 | return count; |
| 166 | } | 166 | } |
| @@ -172,16 +172,16 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused, | |||
| 172 | int ret; | 172 | int ret; |
| 173 | ret = sscanf (buf, "%u", &input); | 173 | ret = sscanf (buf, "%u", &input); |
| 174 | 174 | ||
| 175 | down(&dbs_sem); | 175 | mutex_lock(&dbs_mutex); |
| 176 | if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD || | 176 | if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD || |
| 177 | input < MIN_FREQUENCY_UP_THRESHOLD || | 177 | input < MIN_FREQUENCY_UP_THRESHOLD || |
| 178 | input <= dbs_tuners_ins.down_threshold) { | 178 | input <= dbs_tuners_ins.down_threshold) { |
| 179 | up(&dbs_sem); | 179 | mutex_unlock(&dbs_mutex); |
| 180 | return -EINVAL; | 180 | return -EINVAL; |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | dbs_tuners_ins.up_threshold = input; | 183 | dbs_tuners_ins.up_threshold = input; |
| 184 | up(&dbs_sem); | 184 | mutex_unlock(&dbs_mutex); |
| 185 | 185 | ||
| 186 | return count; | 186 | return count; |
| 187 | } | 187 | } |
| @@ -193,16 +193,16 @@ static ssize_t store_down_threshold(struct cpufreq_policy *unused, | |||
| 193 | int ret; | 193 | int ret; |
| 194 | ret = sscanf (buf, "%u", &input); | 194 | ret = sscanf (buf, "%u", &input); |
| 195 | 195 | ||
| 196 | down(&dbs_sem); | 196 | mutex_lock(&dbs_mutex); |
| 197 | if (ret != 1 || input > MAX_FREQUENCY_DOWN_THRESHOLD || | 197 | if (ret != 1 || input > MAX_FREQUENCY_DOWN_THRESHOLD || |
| 198 | input < MIN_FREQUENCY_DOWN_THRESHOLD || | 198 | input < MIN_FREQUENCY_DOWN_THRESHOLD || |
| 199 | input >= dbs_tuners_ins.up_threshold) { | 199 | input >= dbs_tuners_ins.up_threshold) { |
| 200 | up(&dbs_sem); | 200 | mutex_unlock(&dbs_mutex); |
| 201 | return -EINVAL; | 201 | return -EINVAL; |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | dbs_tuners_ins.down_threshold = input; | 204 | dbs_tuners_ins.down_threshold = input; |
| 205 | up(&dbs_sem); | 205 | mutex_unlock(&dbs_mutex); |
| 206 | 206 | ||
| 207 | return count; | 207 | return count; |
| 208 | } | 208 | } |
| @@ -222,9 +222,9 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy, | |||
| 222 | if ( input > 1 ) | 222 | if ( input > 1 ) |
| 223 | input = 1; | 223 | input = 1; |
| 224 | 224 | ||
| 225 | down(&dbs_sem); | 225 | mutex_lock(&dbs_mutex); |
| 226 | if ( input == dbs_tuners_ins.ignore_nice ) { /* nothing to do */ | 226 | if ( input == dbs_tuners_ins.ignore_nice ) { /* nothing to do */ |
| 227 | up(&dbs_sem); | 227 | mutex_unlock(&dbs_mutex); |
| 228 | return count; | 228 | return count; |
| 229 | } | 229 | } |
| 230 | dbs_tuners_ins.ignore_nice = input; | 230 | dbs_tuners_ins.ignore_nice = input; |
| @@ -236,7 +236,7 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy, | |||
| 236 | j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j); | 236 | j_dbs_info->prev_cpu_idle_up = get_cpu_idle_time(j); |
| 237 | j_dbs_info->prev_cpu_idle_down = j_dbs_info->prev_cpu_idle_up; | 237 | j_dbs_info->prev_cpu_idle_down = j_dbs_info->prev_cpu_idle_up; |
| 238 | } | 238 | } |
| 239 | up(&dbs_sem); | 239 | mutex_unlock(&dbs_mutex); |
| 240 | 240 | ||
| 241 | return count; | 241 | return count; |
| 242 | } | 242 | } |
| @@ -257,9 +257,9 @@ static ssize_t store_freq_step(struct cpufreq_policy *policy, | |||
| 257 | 257 | ||
| 258 | /* no need to test here if freq_step is zero as the user might actually | 258 | /* no need to test here if freq_step is zero as the user might actually |
| 259 | * want this, they would be crazy though :) */ | 259 | * want this, they would be crazy though :) */ |
| 260 | down(&dbs_sem); | 260 | mutex_lock(&dbs_mutex); |
| 261 | dbs_tuners_ins.freq_step = input; | 261 | dbs_tuners_ins.freq_step = input; |
| 262 | up(&dbs_sem); | 262 | mutex_unlock(&dbs_mutex); |
| 263 | 263 | ||
| 264 | return count; | 264 | return count; |
| 265 | } | 265 | } |
| @@ -444,12 +444,12 @@ static void dbs_check_cpu(int cpu) | |||
| 444 | static void do_dbs_timer(void *data) | 444 | static void do_dbs_timer(void *data) |
| 445 | { | 445 | { |
| 446 | int i; | 446 | int i; |
| 447 | down(&dbs_sem); | 447 | mutex_lock(&dbs_mutex); |
| 448 | for_each_online_cpu(i) | 448 | for_each_online_cpu(i) |
| 449 | dbs_check_cpu(i); | 449 | dbs_check_cpu(i); |
| 450 | schedule_delayed_work(&dbs_work, | 450 | schedule_delayed_work(&dbs_work, |
| 451 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); | 451 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); |
| 452 | up(&dbs_sem); | 452 | mutex_unlock(&dbs_mutex); |
| 453 | } | 453 | } |
| 454 | 454 | ||
| 455 | static inline void dbs_timer_init(void) | 455 | static inline void dbs_timer_init(void) |
| @@ -487,7 +487,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
| 487 | if (this_dbs_info->enable) /* Already enabled */ | 487 | if (this_dbs_info->enable) /* Already enabled */ |
| 488 | break; | 488 | break; |
| 489 | 489 | ||
| 490 | down(&dbs_sem); | 490 | mutex_lock(&dbs_mutex); |
| 491 | for_each_cpu_mask(j, policy->cpus) { | 491 | for_each_cpu_mask(j, policy->cpus) { |
| 492 | struct cpu_dbs_info_s *j_dbs_info; | 492 | struct cpu_dbs_info_s *j_dbs_info; |
| 493 | j_dbs_info = &per_cpu(cpu_dbs_info, j); | 493 | j_dbs_info = &per_cpu(cpu_dbs_info, j); |
| @@ -521,11 +521,11 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
| 521 | dbs_timer_init(); | 521 | dbs_timer_init(); |
| 522 | } | 522 | } |
| 523 | 523 | ||
| 524 | up(&dbs_sem); | 524 | mutex_unlock(&dbs_mutex); |
| 525 | break; | 525 | break; |
| 526 | 526 | ||
| 527 | case CPUFREQ_GOV_STOP: | 527 | case CPUFREQ_GOV_STOP: |
| 528 | down(&dbs_sem); | 528 | mutex_lock(&dbs_mutex); |
| 529 | this_dbs_info->enable = 0; | 529 | this_dbs_info->enable = 0; |
| 530 | sysfs_remove_group(&policy->kobj, &dbs_attr_group); | 530 | sysfs_remove_group(&policy->kobj, &dbs_attr_group); |
| 531 | dbs_enable--; | 531 | dbs_enable--; |
| @@ -536,12 +536,12 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
| 536 | if (dbs_enable == 0) | 536 | if (dbs_enable == 0) |
| 537 | dbs_timer_exit(); | 537 | dbs_timer_exit(); |
| 538 | 538 | ||
| 539 | up(&dbs_sem); | 539 | mutex_unlock(&dbs_mutex); |
| 540 | 540 | ||
| 541 | break; | 541 | break; |
| 542 | 542 | ||
| 543 | case CPUFREQ_GOV_LIMITS: | 543 | case CPUFREQ_GOV_LIMITS: |
| 544 | down(&dbs_sem); | 544 | mutex_lock(&dbs_mutex); |
| 545 | if (policy->max < this_dbs_info->cur_policy->cur) | 545 | if (policy->max < this_dbs_info->cur_policy->cur) |
| 546 | __cpufreq_driver_target( | 546 | __cpufreq_driver_target( |
| 547 | this_dbs_info->cur_policy, | 547 | this_dbs_info->cur_policy, |
| @@ -550,7 +550,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
| 550 | __cpufreq_driver_target( | 550 | __cpufreq_driver_target( |
| 551 | this_dbs_info->cur_policy, | 551 | this_dbs_info->cur_policy, |
| 552 | policy->min, CPUFREQ_RELATION_L); | 552 | policy->min, CPUFREQ_RELATION_L); |
| 553 | up(&dbs_sem); | 553 | mutex_unlock(&dbs_mutex); |
| 554 | break; | 554 | break; |
| 555 | } | 555 | } |
| 556 | return 0; | 556 | return 0; |
