aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq_ondemand.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpufreq/cpufreq_ondemand.c')
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c139
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
57static void do_dbs_timer(struct work_struct *work); 57static void do_dbs_timer(struct work_struct *work);
58static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
59 unsigned int event);
60
61#ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND
62static
63#endif
64struct 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 */
60enum {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE}; 72enum {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 ************************/
210static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf) 222
223static 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
217static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) 231static 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) \
223static struct freq_attr _name = \ 238static struct global_attr _name = \
224__ATTR(_name, 0444, show_##_name, NULL) 239__ATTR(_name, 0444, show_##_name, NULL)
225 240
226define_one_ro(sampling_rate_max); 241define_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) \
231static ssize_t show_##file_name \ 246static 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);
238show_one(ignore_nice_load, ignore_nice); 253show_one(ignore_nice_load, ignore_nice);
239show_one(powersave_bias, powersave_bias); 254show_one(powersave_bias, powersave_bias);
240 255
241static 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) \
263static 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}
270show_one_old(sampling_rate);
271show_one_old(up_threshold);
272show_one_old(ignore_nice_load);
273show_one_old(powersave_bias);
274show_one_old(sampling_rate_min);
275show_one_old(sampling_rate_max);
276
277#define define_one_ro_old(object, _name) \
278static struct freq_attr object = \
279__ATTR(_name, 0444, show_##_name##_old, NULL)
280
281define_one_ro_old(sampling_rate_min_old, sampling_rate_min);
282define_one_ro_old(sampling_rate_max_old, sampling_rate_max);
283
284/*** delete after deprecation time ***/
285
286static 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
257static ssize_t store_up_threshold(struct cpufreq_policy *unused, 302static 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
276static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy, 321static 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
313static ssize_t store_powersave_bias(struct cpufreq_policy *unused, 358static 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) \
335static struct freq_attr _name = \ 380static struct global_attr _name = \
336__ATTR(_name, 0644, show_##_name, store_##_name) 381__ATTR(_name, 0644, show_##_name, store_##_name)
337 382
338define_one_rw(sampling_rate); 383define_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) \
406static 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}
413write_one_old(sampling_rate);
414write_one_old(up_threshold);
415write_one_old(ignore_nice_load);
416write_one_old(powersave_bias);
417
418#define define_one_rw_old(object, _name) \
419static struct freq_attr object = \
420__ATTR(_name, 0644, show_##_name##_old, store_##_name##_old)
421
422define_one_rw_old(sampling_rate_old, sampling_rate);
423define_one_rw_old(up_threshold_old, up_threshold);
424define_one_rw_old(ignore_nice_load_old, ignore_nice_load);
425define_one_rw_old(powersave_bias_old, powersave_bias);
426
427static 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
437static 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
360static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) 446static 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
618static
619#endif
620struct 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
627static int __init cpufreq_gov_dbs_init(void) 714static int __init cpufreq_gov_dbs_init(void)
628{ 715{
629 int err; 716 int err;