diff options
Diffstat (limited to 'drivers/cpufreq')
-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 d6ba14276bb1..1a3e5c7252ff 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}; |
@@ -206,20 +218,23 @@ static void ondemand_powersave_bias_init(void) | |||
206 | } | 218 | } |
207 | 219 | ||
208 | /************************** sysfs interface ************************/ | 220 | /************************** sysfs interface ************************/ |
209 | static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf) | 221 | |
222 | static ssize_t show_sampling_rate_max(struct kobject *kobj, | ||
223 | struct attribute *attr, char *buf) | ||
210 | { | 224 | { |
211 | printk_once(KERN_INFO "CPUFREQ: ondemand sampling_rate_max " | 225 | printk_once(KERN_INFO "CPUFREQ: ondemand sampling_rate_max " |
212 | "sysfs file is deprecated - used by: %s\n", current->comm); | 226 | "sysfs file is deprecated - used by: %s\n", current->comm); |
213 | return sprintf(buf, "%u\n", -1U); | 227 | return sprintf(buf, "%u\n", -1U); |
214 | } | 228 | } |
215 | 229 | ||
216 | static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) | 230 | static ssize_t show_sampling_rate_min(struct kobject *kobj, |
231 | struct attribute *attr, char *buf) | ||
217 | { | 232 | { |
218 | return sprintf(buf, "%u\n", min_sampling_rate); | 233 | return sprintf(buf, "%u\n", min_sampling_rate); |
219 | } | 234 | } |
220 | 235 | ||
221 | #define define_one_ro(_name) \ | 236 | #define define_one_ro(_name) \ |
222 | static struct freq_attr _name = \ | 237 | static struct global_attr _name = \ |
223 | __ATTR(_name, 0444, show_##_name, NULL) | 238 | __ATTR(_name, 0444, show_##_name, NULL) |
224 | 239 | ||
225 | define_one_ro(sampling_rate_max); | 240 | define_one_ro(sampling_rate_max); |
@@ -228,7 +243,7 @@ define_one_ro(sampling_rate_min); | |||
228 | /* cpufreq_ondemand Governor Tunables */ | 243 | /* cpufreq_ondemand Governor Tunables */ |
229 | #define show_one(file_name, object) \ | 244 | #define show_one(file_name, object) \ |
230 | static ssize_t show_##file_name \ | 245 | static ssize_t show_##file_name \ |
231 | (struct cpufreq_policy *unused, char *buf) \ | 246 | (struct kobject *kobj, struct attribute *attr, char *buf) \ |
232 | { \ | 247 | { \ |
233 | return sprintf(buf, "%u\n", dbs_tuners_ins.object); \ | 248 | return sprintf(buf, "%u\n", dbs_tuners_ins.object); \ |
234 | } | 249 | } |
@@ -237,8 +252,38 @@ show_one(up_threshold, up_threshold); | |||
237 | show_one(ignore_nice_load, ignore_nice); | 252 | show_one(ignore_nice_load, ignore_nice); |
238 | show_one(powersave_bias, powersave_bias); | 253 | show_one(powersave_bias, powersave_bias); |
239 | 254 | ||
240 | static ssize_t store_sampling_rate(struct cpufreq_policy *unused, | 255 | /*** delete after deprecation time ***/ |
241 | const char *buf, size_t count) | 256 | |
257 | #define DEPRECATION_MSG(file_name) \ | ||
258 | printk_once(KERN_INFO "CPUFREQ: Per core ondemand sysfs " \ | ||
259 | "interface is deprecated - " #file_name "\n"); | ||
260 | |||
261 | #define show_one_old(file_name) \ | ||
262 | static ssize_t show_##file_name##_old \ | ||
263 | (struct cpufreq_policy *unused, char *buf) \ | ||
264 | { \ | ||
265 | printk_once(KERN_INFO "CPUFREQ: Per core ondemand sysfs " \ | ||
266 | "interface is deprecated - " #file_name "\n"); \ | ||
267 | return show_##file_name(NULL, NULL, buf); \ | ||
268 | } | ||
269 | show_one_old(sampling_rate); | ||
270 | show_one_old(up_threshold); | ||
271 | show_one_old(ignore_nice_load); | ||
272 | show_one_old(powersave_bias); | ||
273 | show_one_old(sampling_rate_min); | ||
274 | show_one_old(sampling_rate_max); | ||
275 | |||
276 | #define define_one_ro_old(object, _name) \ | ||
277 | static struct freq_attr object = \ | ||
278 | __ATTR(_name, 0444, show_##_name##_old, NULL) | ||
279 | |||
280 | define_one_ro_old(sampling_rate_min_old, sampling_rate_min); | ||
281 | define_one_ro_old(sampling_rate_max_old, sampling_rate_max); | ||
282 | |||
283 | /*** delete after deprecation time ***/ | ||
284 | |||
285 | static ssize_t store_sampling_rate(struct kobject *a, struct attribute *b, | ||
286 | const char *buf, size_t count) | ||
242 | { | 287 | { |
243 | unsigned int input; | 288 | unsigned int input; |
244 | int ret; | 289 | int ret; |
@@ -253,8 +298,8 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused, | |||
253 | return count; | 298 | return count; |
254 | } | 299 | } |
255 | 300 | ||
256 | static ssize_t store_up_threshold(struct cpufreq_policy *unused, | 301 | static ssize_t store_up_threshold(struct kobject *a, struct attribute *b, |
257 | const char *buf, size_t count) | 302 | const char *buf, size_t count) |
258 | { | 303 | { |
259 | unsigned int input; | 304 | unsigned int input; |
260 | int ret; | 305 | int ret; |
@@ -272,8 +317,8 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused, | |||
272 | return count; | 317 | return count; |
273 | } | 318 | } |
274 | 319 | ||
275 | static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy, | 320 | static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b, |
276 | const char *buf, size_t count) | 321 | const char *buf, size_t count) |
277 | { | 322 | { |
278 | unsigned int input; | 323 | unsigned int input; |
279 | int ret; | 324 | int ret; |
@@ -309,8 +354,8 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy, | |||
309 | return count; | 354 | return count; |
310 | } | 355 | } |
311 | 356 | ||
312 | static ssize_t store_powersave_bias(struct cpufreq_policy *unused, | 357 | static ssize_t store_powersave_bias(struct kobject *a, struct attribute *b, |
313 | const char *buf, size_t count) | 358 | const char *buf, size_t count) |
314 | { | 359 | { |
315 | unsigned int input; | 360 | unsigned int input; |
316 | int ret; | 361 | int ret; |
@@ -331,7 +376,7 @@ static ssize_t store_powersave_bias(struct cpufreq_policy *unused, | |||
331 | } | 376 | } |
332 | 377 | ||
333 | #define define_one_rw(_name) \ | 378 | #define define_one_rw(_name) \ |
334 | static struct freq_attr _name = \ | 379 | static struct global_attr _name = \ |
335 | __ATTR(_name, 0644, show_##_name, store_##_name) | 380 | __ATTR(_name, 0644, show_##_name, store_##_name) |
336 | 381 | ||
337 | define_one_rw(sampling_rate); | 382 | define_one_rw(sampling_rate); |
@@ -354,6 +399,47 @@ static struct attribute_group dbs_attr_group = { | |||
354 | .name = "ondemand", | 399 | .name = "ondemand", |
355 | }; | 400 | }; |
356 | 401 | ||
402 | /*** delete after deprecation time ***/ | ||
403 | |||
404 | #define write_one_old(file_name) \ | ||
405 | static ssize_t store_##file_name##_old \ | ||
406 | (struct cpufreq_policy *unused, const char *buf, size_t count) \ | ||
407 | { \ | ||
408 | printk_once(KERN_INFO "CPUFREQ: Per core ondemand sysfs " \ | ||
409 | "interface is deprecated - " #file_name "\n"); \ | ||
410 | return store_##file_name(NULL, NULL, buf, count); \ | ||
411 | } | ||
412 | write_one_old(sampling_rate); | ||
413 | write_one_old(up_threshold); | ||
414 | write_one_old(ignore_nice_load); | ||
415 | write_one_old(powersave_bias); | ||
416 | |||
417 | #define define_one_rw_old(object, _name) \ | ||
418 | static struct freq_attr object = \ | ||
419 | __ATTR(_name, 0644, show_##_name##_old, store_##_name##_old) | ||
420 | |||
421 | define_one_rw_old(sampling_rate_old, sampling_rate); | ||
422 | define_one_rw_old(up_threshold_old, up_threshold); | ||
423 | define_one_rw_old(ignore_nice_load_old, ignore_nice_load); | ||
424 | define_one_rw_old(powersave_bias_old, powersave_bias); | ||
425 | |||
426 | static struct attribute *dbs_attributes_old[] = { | ||
427 | &sampling_rate_max_old.attr, | ||
428 | &sampling_rate_min_old.attr, | ||
429 | &sampling_rate_old.attr, | ||
430 | &up_threshold_old.attr, | ||
431 | &ignore_nice_load_old.attr, | ||
432 | &powersave_bias_old.attr, | ||
433 | NULL | ||
434 | }; | ||
435 | |||
436 | static struct attribute_group dbs_attr_group_old = { | ||
437 | .attrs = dbs_attributes_old, | ||
438 | .name = "ondemand", | ||
439 | }; | ||
440 | |||
441 | /*** delete after deprecation time ***/ | ||
442 | |||
357 | /************************** sysfs end ************************/ | 443 | /************************** sysfs end ************************/ |
358 | 444 | ||
359 | static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | 445 | static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) |
@@ -544,7 +630,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
544 | 630 | ||
545 | mutex_lock(&dbs_mutex); | 631 | mutex_lock(&dbs_mutex); |
546 | 632 | ||
547 | rc = sysfs_create_group(&policy->kobj, &dbs_attr_group); | 633 | rc = sysfs_create_group(&policy->kobj, &dbs_attr_group_old); |
548 | if (rc) { | 634 | if (rc) { |
549 | mutex_unlock(&dbs_mutex); | 635 | mutex_unlock(&dbs_mutex); |
550 | return rc; | 636 | return rc; |
@@ -565,13 +651,20 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
565 | } | 651 | } |
566 | this_dbs_info->cpu = cpu; | 652 | this_dbs_info->cpu = cpu; |
567 | ondemand_powersave_bias_init_cpu(cpu); | 653 | ondemand_powersave_bias_init_cpu(cpu); |
568 | mutex_init(&this_dbs_info->timer_mutex); | ||
569 | /* | 654 | /* |
570 | * Start the timerschedule work, when this governor | 655 | * Start the timerschedule work, when this governor |
571 | * is used for first time | 656 | * is used for first time |
572 | */ | 657 | */ |
573 | if (dbs_enable == 1) { | 658 | if (dbs_enable == 1) { |
574 | unsigned int latency; | 659 | unsigned int latency; |
660 | |||
661 | rc = sysfs_create_group(cpufreq_global_kobject, | ||
662 | &dbs_attr_group); | ||
663 | if (rc) { | ||
664 | mutex_unlock(&dbs_mutex); | ||
665 | return rc; | ||
666 | } | ||
667 | |||
575 | /* policy latency is in nS. Convert it to uS first */ | 668 | /* policy latency is in nS. Convert it to uS first */ |
576 | latency = policy->cpuinfo.transition_latency / 1000; | 669 | latency = policy->cpuinfo.transition_latency / 1000; |
577 | if (latency == 0) | 670 | if (latency == 0) |
@@ -585,6 +678,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
585 | } | 678 | } |
586 | mutex_unlock(&dbs_mutex); | 679 | mutex_unlock(&dbs_mutex); |
587 | 680 | ||
681 | mutex_init(&this_dbs_info->timer_mutex); | ||
588 | dbs_timer_init(this_dbs_info); | 682 | dbs_timer_init(this_dbs_info); |
589 | break; | 683 | break; |
590 | 684 | ||
@@ -592,10 +686,13 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
592 | dbs_timer_exit(this_dbs_info); | 686 | dbs_timer_exit(this_dbs_info); |
593 | 687 | ||
594 | mutex_lock(&dbs_mutex); | 688 | mutex_lock(&dbs_mutex); |
595 | sysfs_remove_group(&policy->kobj, &dbs_attr_group); | 689 | sysfs_remove_group(&policy->kobj, &dbs_attr_group_old); |
596 | mutex_destroy(&this_dbs_info->timer_mutex); | 690 | mutex_destroy(&this_dbs_info->timer_mutex); |
597 | dbs_enable--; | 691 | dbs_enable--; |
598 | mutex_unlock(&dbs_mutex); | 692 | mutex_unlock(&dbs_mutex); |
693 | if (!dbs_enable) | ||
694 | sysfs_remove_group(cpufreq_global_kobject, | ||
695 | &dbs_attr_group); | ||
599 | 696 | ||
600 | break; | 697 | break; |
601 | 698 | ||
@@ -613,16 +710,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
613 | return 0; | 710 | return 0; |
614 | } | 711 | } |
615 | 712 | ||
616 | #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND | ||
617 | static | ||
618 | #endif | ||
619 | struct cpufreq_governor cpufreq_gov_ondemand = { | ||
620 | .name = "ondemand", | ||
621 | .governor = cpufreq_governor_dbs, | ||
622 | .max_transition_latency = TRANSITION_LATENCY_LIMIT, | ||
623 | .owner = THIS_MODULE, | ||
624 | }; | ||
625 | |||
626 | static int __init cpufreq_gov_dbs_init(void) | 713 | static int __init cpufreq_gov_dbs_init(void) |
627 | { | 714 | { |
628 | int err; | 715 | int err; |