diff options
Diffstat (limited to 'drivers/cpufreq/cpufreq_ondemand.c')
-rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index e1cc5113c2ae..f697449327c6 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -41,8 +41,10 @@ | |||
41 | static unsigned int def_sampling_rate; | 41 | static unsigned int def_sampling_rate; |
42 | #define MIN_SAMPLING_RATE_RATIO (2) | 42 | #define MIN_SAMPLING_RATE_RATIO (2) |
43 | /* for correct statistics, we need at least 10 ticks between each measure */ | 43 | /* for correct statistics, we need at least 10 ticks between each measure */ |
44 | #define MIN_STAT_SAMPLING_RATE (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10)) | 44 | #define MIN_STAT_SAMPLING_RATE \ |
45 | #define MIN_SAMPLING_RATE (def_sampling_rate / MIN_SAMPLING_RATE_RATIO) | 45 | (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10)) |
46 | #define MIN_SAMPLING_RATE \ | ||
47 | (def_sampling_rate / MIN_SAMPLING_RATE_RATIO) | ||
46 | #define MAX_SAMPLING_RATE (500 * def_sampling_rate) | 48 | #define MAX_SAMPLING_RATE (500 * def_sampling_rate) |
47 | #define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) | 49 | #define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) |
48 | #define TRANSITION_LATENCY_LIMIT (10 * 1000) | 50 | #define TRANSITION_LATENCY_LIMIT (10 * 1000) |
@@ -206,7 +208,8 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused, | |||
206 | ret = sscanf(buf, "%u", &input); | 208 | ret = sscanf(buf, "%u", &input); |
207 | 209 | ||
208 | mutex_lock(&dbs_mutex); | 210 | mutex_lock(&dbs_mutex); |
209 | if (ret != 1 || input > MAX_SAMPLING_RATE || input < MIN_SAMPLING_RATE) { | 211 | if (ret != 1 || input > MAX_SAMPLING_RATE |
212 | || input < MIN_SAMPLING_RATE) { | ||
210 | mutex_unlock(&dbs_mutex); | 213 | mutex_unlock(&dbs_mutex); |
211 | return -EINVAL; | 214 | return -EINVAL; |
212 | } | 215 | } |
@@ -397,8 +400,15 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
397 | * policy. To be safe, we focus 10 points under the threshold. | 400 | * policy. To be safe, we focus 10 points under the threshold. |
398 | */ | 401 | */ |
399 | if (load < (dbs_tuners_ins.up_threshold - 10)) { | 402 | if (load < (dbs_tuners_ins.up_threshold - 10)) { |
400 | unsigned int freq_next = (policy->cur * load) / | 403 | unsigned int freq_next, freq_cur; |
404 | |||
405 | freq_cur = cpufreq_driver_getavg(policy); | ||
406 | if (!freq_cur) | ||
407 | freq_cur = policy->cur; | ||
408 | |||
409 | freq_next = (freq_cur * load) / | ||
401 | (dbs_tuners_ins.up_threshold - 10); | 410 | (dbs_tuners_ins.up_threshold - 10); |
411 | |||
402 | if (!dbs_tuners_ins.powersave_bias) { | 412 | if (!dbs_tuners_ins.powersave_bias) { |
403 | __cpufreq_driver_target(policy, freq_next, | 413 | __cpufreq_driver_target(policy, freq_next, |
404 | CPUFREQ_RELATION_L); | 414 | CPUFREQ_RELATION_L); |
@@ -472,6 +482,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
472 | unsigned int cpu = policy->cpu; | 482 | unsigned int cpu = policy->cpu; |
473 | struct cpu_dbs_info_s *this_dbs_info; | 483 | struct cpu_dbs_info_s *this_dbs_info; |
474 | unsigned int j; | 484 | unsigned int j; |
485 | int rc; | ||
475 | 486 | ||
476 | this_dbs_info = &per_cpu(cpu_dbs_info, cpu); | 487 | this_dbs_info = &per_cpu(cpu_dbs_info, cpu); |
477 | 488 | ||
@@ -494,12 +505,23 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
494 | if (dbs_enable == 1) { | 505 | if (dbs_enable == 1) { |
495 | kondemand_wq = create_workqueue("kondemand"); | 506 | kondemand_wq = create_workqueue("kondemand"); |
496 | if (!kondemand_wq) { | 507 | if (!kondemand_wq) { |
497 | printk(KERN_ERR "Creation of kondemand failed\n"); | 508 | printk(KERN_ERR |
509 | "Creation of kondemand failed\n"); | ||
498 | dbs_enable--; | 510 | dbs_enable--; |
499 | mutex_unlock(&dbs_mutex); | 511 | mutex_unlock(&dbs_mutex); |
500 | return -ENOSPC; | 512 | return -ENOSPC; |
501 | } | 513 | } |
502 | } | 514 | } |
515 | |||
516 | rc = sysfs_create_group(&policy->kobj, &dbs_attr_group); | ||
517 | if (rc) { | ||
518 | if (dbs_enable == 1) | ||
519 | destroy_workqueue(kondemand_wq); | ||
520 | dbs_enable--; | ||
521 | mutex_unlock(&dbs_mutex); | ||
522 | return rc; | ||
523 | } | ||
524 | |||
503 | for_each_cpu_mask(j, policy->cpus) { | 525 | for_each_cpu_mask(j, policy->cpus) { |
504 | struct cpu_dbs_info_s *j_dbs_info; | 526 | struct cpu_dbs_info_s *j_dbs_info; |
505 | j_dbs_info = &per_cpu(cpu_dbs_info, j); | 527 | j_dbs_info = &per_cpu(cpu_dbs_info, j); |
@@ -509,7 +531,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
509 | j_dbs_info->prev_cpu_wall = get_jiffies_64(); | 531 | j_dbs_info->prev_cpu_wall = get_jiffies_64(); |
510 | } | 532 | } |
511 | this_dbs_info->enable = 1; | 533 | this_dbs_info->enable = 1; |
512 | sysfs_create_group(&policy->kobj, &dbs_attr_group); | ||
513 | /* | 534 | /* |
514 | * Start the timerschedule work, when this governor | 535 | * Start the timerschedule work, when this governor |
515 | * is used for first time | 536 | * is used for first time |