diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/cpufreq/cpufreq_conservative.c | 61 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.c | 68 |
2 files changed, 45 insertions, 84 deletions
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index 7a74d175287b..7fc58af748b4 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -42,27 +42,12 @@ | |||
42 | * this governor will not work. | 42 | * this governor will not work. |
43 | * All times here are in uS. | 43 | * All times here are in uS. |
44 | */ | 44 | */ |
45 | static unsigned int def_sampling_rate; | ||
46 | #define MIN_SAMPLING_RATE_RATIO (2) | 45 | #define MIN_SAMPLING_RATE_RATIO (2) |
47 | /* for correct statistics, we need at least 10 ticks between each measure */ | ||
48 | #define MIN_STAT_SAMPLING_RATE \ | ||
49 | (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10)) | ||
50 | #define MIN_SAMPLING_RATE \ | ||
51 | (def_sampling_rate / MIN_SAMPLING_RATE_RATIO) | ||
52 | /* Above MIN_SAMPLING_RATE will vanish with its sysfs file soon | ||
53 | * Define the minimal settable sampling rate to the greater of: | ||
54 | * - "HW transition latency" * 100 (same as default sampling / 10) | ||
55 | * - MIN_STAT_SAMPLING_RATE | ||
56 | * To avoid that userspace shoots itself. | ||
57 | */ | ||
58 | static unsigned int minimum_sampling_rate(void) | ||
59 | { | ||
60 | return max(def_sampling_rate / 10, MIN_STAT_SAMPLING_RATE); | ||
61 | } | ||
62 | 46 | ||
63 | /* This will also vanish soon with removing sampling_rate_max */ | 47 | static unsigned int min_sampling_rate; |
64 | #define MAX_SAMPLING_RATE (500 * def_sampling_rate) | 48 | |
65 | #define LATENCY_MULTIPLIER (1000) | 49 | #define LATENCY_MULTIPLIER (1000) |
50 | #define MIN_LATENCY_MULTIPLIER (100) | ||
66 | #define DEF_SAMPLING_DOWN_FACTOR (1) | 51 | #define DEF_SAMPLING_DOWN_FACTOR (1) |
67 | #define MAX_SAMPLING_DOWN_FACTOR (10) | 52 | #define MAX_SAMPLING_DOWN_FACTOR (10) |
68 | #define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) | 53 | #define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) |
@@ -182,27 +167,14 @@ static struct notifier_block dbs_cpufreq_notifier_block = { | |||
182 | /************************** sysfs interface ************************/ | 167 | /************************** sysfs interface ************************/ |
183 | static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf) | 168 | static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf) |
184 | { | 169 | { |
185 | static int print_once; | 170 | printk_once(KERN_INFO "CPUFREQ: conservative sampling_rate_max " |
186 | 171 | "sysfs file is deprecated - used by: %s\n", current->comm); | |
187 | if (!print_once) { | 172 | return sprintf(buf, "%u\n", -1U); |
188 | printk(KERN_INFO "CPUFREQ: conservative sampling_rate_max " | ||
189 | "sysfs file is deprecated - used by: %s\n", | ||
190 | current->comm); | ||
191 | print_once = 1; | ||
192 | } | ||
193 | return sprintf(buf, "%u\n", MAX_SAMPLING_RATE); | ||
194 | } | 173 | } |
195 | 174 | ||
196 | static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) | 175 | static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) |
197 | { | 176 | { |
198 | static int print_once; | 177 | return sprintf(buf, "%u\n", min_sampling_rate); |
199 | |||
200 | if (!print_once) { | ||
201 | printk(KERN_INFO "CPUFREQ: conservative sampling_rate_max " | ||
202 | "sysfs file is deprecated - used by: %s\n", current->comm); | ||
203 | print_once = 1; | ||
204 | } | ||
205 | return sprintf(buf, "%u\n", MIN_SAMPLING_RATE); | ||
206 | } | 178 | } |
207 | 179 | ||
208 | #define define_one_ro(_name) \ | 180 | #define define_one_ro(_name) \ |
@@ -254,7 +226,7 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused, | |||
254 | return -EINVAL; | 226 | return -EINVAL; |
255 | 227 | ||
256 | mutex_lock(&dbs_mutex); | 228 | mutex_lock(&dbs_mutex); |
257 | dbs_tuners_ins.sampling_rate = max(input, minimum_sampling_rate()); | 229 | dbs_tuners_ins.sampling_rate = max(input, min_sampling_rate); |
258 | mutex_unlock(&dbs_mutex); | 230 | mutex_unlock(&dbs_mutex); |
259 | 231 | ||
260 | return count; | 232 | return count; |
@@ -601,11 +573,18 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
601 | if (latency == 0) | 573 | if (latency == 0) |
602 | latency = 1; | 574 | latency = 1; |
603 | 575 | ||
604 | def_sampling_rate = | 576 | /* |
605 | max(latency * LATENCY_MULTIPLIER, | 577 | * conservative does not implement micro like ondemand |
606 | MIN_STAT_SAMPLING_RATE); | 578 | * governor, thus we are bound to jiffes/HZ |
607 | 579 | */ | |
608 | dbs_tuners_ins.sampling_rate = def_sampling_rate; | 580 | min_sampling_rate = |
581 | MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10); | ||
582 | /* Bring kernel and HW constraints together */ | ||
583 | min_sampling_rate = max(min_sampling_rate, | ||
584 | MIN_LATENCY_MULTIPLIER * latency); | ||
585 | dbs_tuners_ins.sampling_rate = | ||
586 | max(min_sampling_rate, | ||
587 | latency * LATENCY_MULTIPLIER); | ||
609 | 588 | ||
610 | cpufreq_register_notifier( | 589 | cpufreq_register_notifier( |
611 | &dbs_cpufreq_notifier_block, | 590 | &dbs_cpufreq_notifier_block, |
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index e741c339df76..1911d1729353 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #define DEF_FREQUENCY_UP_THRESHOLD (80) | 32 | #define DEF_FREQUENCY_UP_THRESHOLD (80) |
33 | #define MICRO_FREQUENCY_DOWN_DIFFERENTIAL (3) | 33 | #define MICRO_FREQUENCY_DOWN_DIFFERENTIAL (3) |
34 | #define MICRO_FREQUENCY_UP_THRESHOLD (95) | 34 | #define MICRO_FREQUENCY_UP_THRESHOLD (95) |
35 | #define MICRO_FREQUENCY_MIN_SAMPLE_RATE (10000) | ||
35 | #define MIN_FREQUENCY_UP_THRESHOLD (11) | 36 | #define MIN_FREQUENCY_UP_THRESHOLD (11) |
36 | #define MAX_FREQUENCY_UP_THRESHOLD (100) | 37 | #define MAX_FREQUENCY_UP_THRESHOLD (100) |
37 | 38 | ||
@@ -45,27 +46,12 @@ | |||
45 | * this governor will not work. | 46 | * this governor will not work. |
46 | * All times here are in uS. | 47 | * All times here are in uS. |
47 | */ | 48 | */ |
48 | static unsigned int def_sampling_rate; | ||
49 | #define MIN_SAMPLING_RATE_RATIO (2) | 49 | #define MIN_SAMPLING_RATE_RATIO (2) |
50 | /* for correct statistics, we need at least 10 ticks between each measure */ | ||
51 | #define MIN_STAT_SAMPLING_RATE \ | ||
52 | (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10)) | ||
53 | #define MIN_SAMPLING_RATE \ | ||
54 | (def_sampling_rate / MIN_SAMPLING_RATE_RATIO) | ||
55 | /* Above MIN_SAMPLING_RATE will vanish with its sysfs file soon | ||
56 | * Define the minimal settable sampling rate to the greater of: | ||
57 | * - "HW transition latency" * 100 (same as default sampling / 10) | ||
58 | * - MIN_STAT_SAMPLING_RATE | ||
59 | * To avoid that userspace shoots itself. | ||
60 | */ | ||
61 | static unsigned int minimum_sampling_rate(void) | ||
62 | { | ||
63 | return max(def_sampling_rate / 10, MIN_STAT_SAMPLING_RATE); | ||
64 | } | ||
65 | 50 | ||
66 | /* This will also vanish soon with removing sampling_rate_max */ | 51 | static unsigned int min_sampling_rate; |
67 | #define MAX_SAMPLING_RATE (500 * def_sampling_rate) | 52 | |
68 | #define LATENCY_MULTIPLIER (1000) | 53 | #define LATENCY_MULTIPLIER (1000) |
54 | #define MIN_LATENCY_MULTIPLIER (100) | ||
69 | #define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) | 55 | #define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) |
70 | 56 | ||
71 | static void do_dbs_timer(struct work_struct *work); | 57 | static void do_dbs_timer(struct work_struct *work); |
@@ -219,28 +205,14 @@ static void ondemand_powersave_bias_init(void) | |||
219 | /************************** sysfs interface ************************/ | 205 | /************************** sysfs interface ************************/ |
220 | static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf) | 206 | static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf) |
221 | { | 207 | { |
222 | static int print_once; | 208 | printk_once(KERN_INFO "CPUFREQ: ondemand sampling_rate_max " |
223 | 209 | "sysfs file is deprecated - used by: %s\n", current->comm); | |
224 | if (!print_once) { | 210 | return sprintf(buf, "%u\n", -1U); |
225 | printk(KERN_INFO "CPUFREQ: ondemand sampling_rate_max " | ||
226 | "sysfs file is deprecated - used by: %s\n", | ||
227 | current->comm); | ||
228 | print_once = 1; | ||
229 | } | ||
230 | return sprintf(buf, "%u\n", MAX_SAMPLING_RATE); | ||
231 | } | 211 | } |
232 | 212 | ||
233 | static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) | 213 | static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) |
234 | { | 214 | { |
235 | static int print_once; | 215 | return sprintf(buf, "%u\n", min_sampling_rate); |
236 | |||
237 | if (!print_once) { | ||
238 | printk(KERN_INFO "CPUFREQ: ondemand sampling_rate_min " | ||
239 | "sysfs file is deprecated - used by: %s\n", | ||
240 | current->comm); | ||
241 | print_once = 1; | ||
242 | } | ||
243 | return sprintf(buf, "%u\n", MIN_SAMPLING_RATE); | ||
244 | } | 216 | } |
245 | 217 | ||
246 | #define define_one_ro(_name) \ | 218 | #define define_one_ro(_name) \ |
@@ -274,7 +246,7 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused, | |||
274 | mutex_unlock(&dbs_mutex); | 246 | mutex_unlock(&dbs_mutex); |
275 | return -EINVAL; | 247 | return -EINVAL; |
276 | } | 248 | } |
277 | dbs_tuners_ins.sampling_rate = max(input, minimum_sampling_rate()); | 249 | dbs_tuners_ins.sampling_rate = max(input, min_sampling_rate); |
278 | mutex_unlock(&dbs_mutex); | 250 | mutex_unlock(&dbs_mutex); |
279 | 251 | ||
280 | return count; | 252 | return count; |
@@ -619,12 +591,12 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
619 | latency = policy->cpuinfo.transition_latency / 1000; | 591 | latency = policy->cpuinfo.transition_latency / 1000; |
620 | if (latency == 0) | 592 | if (latency == 0) |
621 | latency = 1; | 593 | latency = 1; |
622 | 594 | /* Bring kernel and HW constraints together */ | |
623 | def_sampling_rate = | 595 | min_sampling_rate = max(min_sampling_rate, |
624 | max(latency * LATENCY_MULTIPLIER, | 596 | MIN_LATENCY_MULTIPLIER * latency); |
625 | MIN_STAT_SAMPLING_RATE); | 597 | dbs_tuners_ins.sampling_rate = |
626 | 598 | max(min_sampling_rate, | |
627 | dbs_tuners_ins.sampling_rate = def_sampling_rate; | 599 | latency * LATENCY_MULTIPLIER); |
628 | } | 600 | } |
629 | dbs_timer_init(this_dbs_info); | 601 | dbs_timer_init(this_dbs_info); |
630 | 602 | ||
@@ -678,6 +650,16 @@ static int __init cpufreq_gov_dbs_init(void) | |||
678 | dbs_tuners_ins.up_threshold = MICRO_FREQUENCY_UP_THRESHOLD; | 650 | dbs_tuners_ins.up_threshold = MICRO_FREQUENCY_UP_THRESHOLD; |
679 | dbs_tuners_ins.down_differential = | 651 | dbs_tuners_ins.down_differential = |
680 | MICRO_FREQUENCY_DOWN_DIFFERENTIAL; | 652 | MICRO_FREQUENCY_DOWN_DIFFERENTIAL; |
653 | /* | ||
654 | * In no_hz/micro accounting case we set the minimum frequency | ||
655 | * not depending on HZ, but fixed (very low). The deferred | ||
656 | * timer might skip some samples if idle/sleeping as needed. | ||
657 | */ | ||
658 | min_sampling_rate = MICRO_FREQUENCY_MIN_SAMPLE_RATE; | ||
659 | } else { | ||
660 | /* For correct statistics, we need 10 ticks for each measure */ | ||
661 | min_sampling_rate = | ||
662 | MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10); | ||
681 | } | 663 | } |
682 | 664 | ||
683 | kondemand_wq = create_workqueue("kondemand"); | 665 | kondemand_wq = create_workqueue("kondemand"); |