diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-09-20 14:24:58 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-09-20 14:25:03 -0400 |
commit | bfefb7a0c6e08736f2d5917c468467f134bf28bb (patch) | |
tree | 7aa7084114dc083fe5b4d7b532901bdeb67188e7 /drivers/cpufreq/cpufreq_ondemand.c | |
parent | 8d0cc631f6dd0a9283ceb7d61d8b85ecbcd355ea (diff) | |
parent | 78f28b7c555359c67c2a0d23f7436e915329421e (diff) |
Merge branch 'linus' into x86/urgent
Merge reason: Bring in changes that the next patch will depend on.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers/cpufreq/cpufreq_ondemand.c')
-rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.c | 139 |
1 files changed, 113 insertions, 26 deletions
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index d7a528c80de8..071699de50ee 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -55,6 +55,18 @@ static unsigned int min_sampling_rate; | |||
55 | #define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) | 55 | #define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) |
56 | 56 | ||
57 | static void do_dbs_timer(struct work_struct *work); | 57 | static void do_dbs_timer(struct work_struct *work); |
58 | static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | ||
59 | unsigned int event); | ||
60 | |||
61 | #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND | ||
62 | static | ||
63 | #endif | ||
64 | struct cpufreq_governor cpufreq_gov_ondemand = { | ||
65 | .name = "ondemand", | ||
66 | .governor = cpufreq_governor_dbs, | ||
67 | .max_transition_latency = TRANSITION_LATENCY_LIMIT, | ||
68 | .owner = THIS_MODULE, | ||
69 | }; | ||
58 | 70 | ||
59 | /* Sampling types */ | 71 | /* Sampling types */ |
60 | enum {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE}; | 72 | enum {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE}; |
@@ -207,20 +219,23 @@ static void ondemand_powersave_bias_init(void) | |||
207 | } | 219 | } |
208 | 220 | ||
209 | /************************** sysfs interface ************************/ | 221 | /************************** sysfs interface ************************/ |
210 | static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf) | 222 | |
223 | static ssize_t show_sampling_rate_max(struct kobject *kobj, | ||
224 | struct attribute *attr, char *buf) | ||
211 | { | 225 | { |
212 | printk_once(KERN_INFO "CPUFREQ: ondemand sampling_rate_max " | 226 | printk_once(KERN_INFO "CPUFREQ: ondemand sampling_rate_max " |
213 | "sysfs file is deprecated - used by: %s\n", current->comm); | 227 | "sysfs file is deprecated - used by: %s\n", current->comm); |
214 | return sprintf(buf, "%u\n", -1U); | 228 | return sprintf(buf, "%u\n", -1U); |
215 | } | 229 | } |
216 | 230 | ||
217 | static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) | 231 | static ssize_t show_sampling_rate_min(struct kobject *kobj, |
232 | struct attribute *attr, char *buf) | ||
218 | { | 233 | { |
219 | return sprintf(buf, "%u\n", min_sampling_rate); | 234 | return sprintf(buf, "%u\n", min_sampling_rate); |
220 | } | 235 | } |
221 | 236 | ||
222 | #define define_one_ro(_name) \ | 237 | #define define_one_ro(_name) \ |
223 | static struct freq_attr _name = \ | 238 | static struct global_attr _name = \ |
224 | __ATTR(_name, 0444, show_##_name, NULL) | 239 | __ATTR(_name, 0444, show_##_name, NULL) |
225 | 240 | ||
226 | define_one_ro(sampling_rate_max); | 241 | define_one_ro(sampling_rate_max); |
@@ -229,7 +244,7 @@ define_one_ro(sampling_rate_min); | |||
229 | /* cpufreq_ondemand Governor Tunables */ | 244 | /* cpufreq_ondemand Governor Tunables */ |
230 | #define show_one(file_name, object) \ | 245 | #define show_one(file_name, object) \ |
231 | static ssize_t show_##file_name \ | 246 | static ssize_t show_##file_name \ |
232 | (struct cpufreq_policy *unused, char *buf) \ | 247 | (struct kobject *kobj, struct attribute *attr, char *buf) \ |
233 | { \ | 248 | { \ |
234 | return sprintf(buf, "%u\n", dbs_tuners_ins.object); \ | 249 | return sprintf(buf, "%u\n", dbs_tuners_ins.object); \ |
235 | } | 250 | } |
@@ -238,8 +253,38 @@ show_one(up_threshold, up_threshold); | |||
238 | show_one(ignore_nice_load, ignore_nice); | 253 | show_one(ignore_nice_load, ignore_nice); |
239 | show_one(powersave_bias, powersave_bias); | 254 | show_one(powersave_bias, powersave_bias); |
240 | 255 | ||
241 | static ssize_t store_sampling_rate(struct cpufreq_policy *unused, | 256 | /*** delete after deprecation time ***/ |
242 | const char *buf, size_t count) | 257 | |
258 | #define DEPRECATION_MSG(file_name) \ | ||
259 | printk_once(KERN_INFO "CPUFREQ: Per core ondemand sysfs " \ | ||
260 | "interface is deprecated - " #file_name "\n"); | ||
261 | |||
262 | #define show_one_old(file_name) \ | ||
263 | static ssize_t show_##file_name##_old \ | ||
264 | (struct cpufreq_policy *unused, char *buf) \ | ||
265 | { \ | ||
266 | printk_once(KERN_INFO "CPUFREQ: Per core ondemand sysfs " \ | ||
267 | "interface is deprecated - " #file_name "\n"); \ | ||
268 | return show_##file_name(NULL, NULL, buf); \ | ||
269 | } | ||
270 | show_one_old(sampling_rate); | ||
271 | show_one_old(up_threshold); | ||
272 | show_one_old(ignore_nice_load); | ||
273 | show_one_old(powersave_bias); | ||
274 | show_one_old(sampling_rate_min); | ||
275 | show_one_old(sampling_rate_max); | ||
276 | |||
277 | #define define_one_ro_old(object, _name) \ | ||
278 | static struct freq_attr object = \ | ||
279 | __ATTR(_name, 0444, show_##_name##_old, NULL) | ||
280 | |||
281 | define_one_ro_old(sampling_rate_min_old, sampling_rate_min); | ||
282 | define_one_ro_old(sampling_rate_max_old, sampling_rate_max); | ||
283 | |||
284 | /*** delete after deprecation time ***/ | ||
285 | |||
286 | static ssize_t store_sampling_rate(struct kobject *a, struct attribute *b, | ||
287 | const char *buf, size_t count) | ||
243 | { | 288 | { |
244 | unsigned int input; | 289 | unsigned int input; |
245 | int ret; | 290 | int ret; |
@@ -254,8 +299,8 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused, | |||
254 | return count; | 299 | return count; |
255 | } | 300 | } |
256 | 301 | ||
257 | static ssize_t store_up_threshold(struct cpufreq_policy *unused, | 302 | static ssize_t store_up_threshold(struct kobject *a, struct attribute *b, |
258 | const char *buf, size_t count) | 303 | const char *buf, size_t count) |
259 | { | 304 | { |
260 | unsigned int input; | 305 | unsigned int input; |
261 | int ret; | 306 | int ret; |
@@ -273,8 +318,8 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused, | |||
273 | return count; | 318 | return count; |
274 | } | 319 | } |
275 | 320 | ||
276 | static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy, | 321 | static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b, |
277 | const char *buf, size_t count) | 322 | const char *buf, size_t count) |
278 | { | 323 | { |
279 | unsigned int input; | 324 | unsigned int input; |
280 | int ret; | 325 | int ret; |
@@ -310,8 +355,8 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy, | |||
310 | return count; | 355 | return count; |
311 | } | 356 | } |
312 | 357 | ||
313 | static ssize_t store_powersave_bias(struct cpufreq_policy *unused, | 358 | static ssize_t store_powersave_bias(struct kobject *a, struct attribute *b, |
314 | const char *buf, size_t count) | 359 | const char *buf, size_t count) |
315 | { | 360 | { |
316 | unsigned int input; | 361 | unsigned int input; |
317 | int ret; | 362 | int ret; |
@@ -332,7 +377,7 @@ static ssize_t store_powersave_bias(struct cpufreq_policy *unused, | |||
332 | } | 377 | } |
333 | 378 | ||
334 | #define define_one_rw(_name) \ | 379 | #define define_one_rw(_name) \ |
335 | static struct freq_attr _name = \ | 380 | static struct global_attr _name = \ |
336 | __ATTR(_name, 0644, show_##_name, store_##_name) | 381 | __ATTR(_name, 0644, show_##_name, store_##_name) |
337 | 382 | ||
338 | define_one_rw(sampling_rate); | 383 | define_one_rw(sampling_rate); |
@@ -355,6 +400,47 @@ static struct attribute_group dbs_attr_group = { | |||
355 | .name = "ondemand", | 400 | .name = "ondemand", |
356 | }; | 401 | }; |
357 | 402 | ||
403 | /*** delete after deprecation time ***/ | ||
404 | |||
405 | #define write_one_old(file_name) \ | ||
406 | static ssize_t store_##file_name##_old \ | ||
407 | (struct cpufreq_policy *unused, const char *buf, size_t count) \ | ||
408 | { \ | ||
409 | printk_once(KERN_INFO "CPUFREQ: Per core ondemand sysfs " \ | ||
410 | "interface is deprecated - " #file_name "\n"); \ | ||
411 | return store_##file_name(NULL, NULL, buf, count); \ | ||
412 | } | ||
413 | write_one_old(sampling_rate); | ||
414 | write_one_old(up_threshold); | ||
415 | write_one_old(ignore_nice_load); | ||
416 | write_one_old(powersave_bias); | ||
417 | |||
418 | #define define_one_rw_old(object, _name) \ | ||
419 | static struct freq_attr object = \ | ||
420 | __ATTR(_name, 0644, show_##_name##_old, store_##_name##_old) | ||
421 | |||
422 | define_one_rw_old(sampling_rate_old, sampling_rate); | ||
423 | define_one_rw_old(up_threshold_old, up_threshold); | ||
424 | define_one_rw_old(ignore_nice_load_old, ignore_nice_load); | ||
425 | define_one_rw_old(powersave_bias_old, powersave_bias); | ||
426 | |||
427 | static struct attribute *dbs_attributes_old[] = { | ||
428 | &sampling_rate_max_old.attr, | ||
429 | &sampling_rate_min_old.attr, | ||
430 | &sampling_rate_old.attr, | ||
431 | &up_threshold_old.attr, | ||
432 | &ignore_nice_load_old.attr, | ||
433 | &powersave_bias_old.attr, | ||
434 | NULL | ||
435 | }; | ||
436 | |||
437 | static struct attribute_group dbs_attr_group_old = { | ||
438 | .attrs = dbs_attributes_old, | ||
439 | .name = "ondemand", | ||
440 | }; | ||
441 | |||
442 | /*** delete after deprecation time ***/ | ||
443 | |||
358 | /************************** sysfs end ************************/ | 444 | /************************** sysfs end ************************/ |
359 | 445 | ||
360 | static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | 446 | static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) |
@@ -545,7 +631,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
545 | 631 | ||
546 | mutex_lock(&dbs_mutex); | 632 | mutex_lock(&dbs_mutex); |
547 | 633 | ||
548 | rc = sysfs_create_group(&policy->kobj, &dbs_attr_group); | 634 | rc = sysfs_create_group(&policy->kobj, &dbs_attr_group_old); |
549 | if (rc) { | 635 | if (rc) { |
550 | mutex_unlock(&dbs_mutex); | 636 | mutex_unlock(&dbs_mutex); |
551 | return rc; | 637 | return rc; |
@@ -566,13 +652,20 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
566 | } | 652 | } |
567 | this_dbs_info->cpu = cpu; | 653 | this_dbs_info->cpu = cpu; |
568 | ondemand_powersave_bias_init_cpu(cpu); | 654 | ondemand_powersave_bias_init_cpu(cpu); |
569 | mutex_init(&this_dbs_info->timer_mutex); | ||
570 | /* | 655 | /* |
571 | * Start the timerschedule work, when this governor | 656 | * Start the timerschedule work, when this governor |
572 | * is used for first time | 657 | * is used for first time |
573 | */ | 658 | */ |
574 | if (dbs_enable == 1) { | 659 | if (dbs_enable == 1) { |
575 | unsigned int latency; | 660 | unsigned int latency; |
661 | |||
662 | rc = sysfs_create_group(cpufreq_global_kobject, | ||
663 | &dbs_attr_group); | ||
664 | if (rc) { | ||
665 | mutex_unlock(&dbs_mutex); | ||
666 | return rc; | ||
667 | } | ||
668 | |||
576 | /* policy latency is in nS. Convert it to uS first */ | 669 | /* policy latency is in nS. Convert it to uS first */ |
577 | latency = policy->cpuinfo.transition_latency / 1000; | 670 | latency = policy->cpuinfo.transition_latency / 1000; |
578 | if (latency == 0) | 671 | if (latency == 0) |
@@ -586,6 +679,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
586 | } | 679 | } |
587 | mutex_unlock(&dbs_mutex); | 680 | mutex_unlock(&dbs_mutex); |
588 | 681 | ||
682 | mutex_init(&this_dbs_info->timer_mutex); | ||
589 | dbs_timer_init(this_dbs_info); | 683 | dbs_timer_init(this_dbs_info); |
590 | break; | 684 | break; |
591 | 685 | ||
@@ -593,10 +687,13 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
593 | dbs_timer_exit(this_dbs_info); | 687 | dbs_timer_exit(this_dbs_info); |
594 | 688 | ||
595 | mutex_lock(&dbs_mutex); | 689 | mutex_lock(&dbs_mutex); |
596 | sysfs_remove_group(&policy->kobj, &dbs_attr_group); | 690 | sysfs_remove_group(&policy->kobj, &dbs_attr_group_old); |
597 | mutex_destroy(&this_dbs_info->timer_mutex); | 691 | mutex_destroy(&this_dbs_info->timer_mutex); |
598 | dbs_enable--; | 692 | dbs_enable--; |
599 | mutex_unlock(&dbs_mutex); | 693 | mutex_unlock(&dbs_mutex); |
694 | if (!dbs_enable) | ||
695 | sysfs_remove_group(cpufreq_global_kobject, | ||
696 | &dbs_attr_group); | ||
600 | 697 | ||
601 | break; | 698 | break; |
602 | 699 | ||
@@ -614,16 +711,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
614 | return 0; | 711 | return 0; |
615 | } | 712 | } |
616 | 713 | ||
617 | #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND | ||
618 | static | ||
619 | #endif | ||
620 | struct cpufreq_governor cpufreq_gov_ondemand = { | ||
621 | .name = "ondemand", | ||
622 | .governor = cpufreq_governor_dbs, | ||
623 | .max_transition_latency = TRANSITION_LATENCY_LIMIT, | ||
624 | .owner = THIS_MODULE, | ||
625 | }; | ||
626 | |||
627 | static int __init cpufreq_gov_dbs_init(void) | 714 | static int __init cpufreq_gov_dbs_init(void) |
628 | { | 715 | { |
629 | int err; | 716 | int err; |