diff options
author | Stratos Karafotis <stratosk@semaphore.gr> | 2013-03-22 04:03:17 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-03-31 19:11:36 -0400 |
commit | 987658477216c3d8e56d1cfc8a17d2f930d2a632 (patch) | |
tree | eee6e5ac143d0d72c4d072660ba73b79a90fdde9 /drivers/cpufreq/cpufreq_conservative.c | |
parent | cc721c4fdf742387f4e5a061fa8a7ab6fac453bf (diff) |
cpufreq: conservative: Use an inline function to evaluate freq_target
Use an inline function to evaluate freq_target to avoid duplicate code.
Also, define a macro for the default frequency step.
Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq_conservative.c')
-rw-r--r-- | drivers/cpufreq/cpufreq_conservative.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index 0d6a9e55ac8c..0ceb2eff5a7e 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -29,11 +29,24 @@ | |||
29 | /* Conservative governor macros */ | 29 | /* Conservative governor macros */ |
30 | #define DEF_FREQUENCY_UP_THRESHOLD (80) | 30 | #define DEF_FREQUENCY_UP_THRESHOLD (80) |
31 | #define DEF_FREQUENCY_DOWN_THRESHOLD (20) | 31 | #define DEF_FREQUENCY_DOWN_THRESHOLD (20) |
32 | #define DEF_FREQUENCY_STEP (5) | ||
32 | #define DEF_SAMPLING_DOWN_FACTOR (1) | 33 | #define DEF_SAMPLING_DOWN_FACTOR (1) |
33 | #define MAX_SAMPLING_DOWN_FACTOR (10) | 34 | #define MAX_SAMPLING_DOWN_FACTOR (10) |
34 | 35 | ||
35 | static DEFINE_PER_CPU(struct cs_cpu_dbs_info_s, cs_cpu_dbs_info); | 36 | static DEFINE_PER_CPU(struct cs_cpu_dbs_info_s, cs_cpu_dbs_info); |
36 | 37 | ||
38 | static inline unsigned int get_freq_target(struct cs_dbs_tuners *cs_tuners, | ||
39 | struct cpufreq_policy *policy) | ||
40 | { | ||
41 | unsigned int freq_target = (cs_tuners->freq_step * policy->max) / 100; | ||
42 | |||
43 | /* max freq cannot be less than 100. But who knows... */ | ||
44 | if (unlikely(freq_target == 0)) | ||
45 | freq_target = DEF_FREQUENCY_STEP; | ||
46 | |||
47 | return freq_target; | ||
48 | } | ||
49 | |||
37 | /* | 50 | /* |
38 | * Every sampling_rate, we check, if current idle time is less than 20% | 51 | * Every sampling_rate, we check, if current idle time is less than 20% |
39 | * (default), then we try to increase frequency. Every sampling_rate * | 52 | * (default), then we try to increase frequency. Every sampling_rate * |
@@ -49,7 +62,6 @@ static void cs_check_cpu(int cpu, unsigned int load) | |||
49 | struct cpufreq_policy *policy = dbs_info->cdbs.cur_policy; | 62 | struct cpufreq_policy *policy = dbs_info->cdbs.cur_policy; |
50 | struct dbs_data *dbs_data = policy->governor_data; | 63 | struct dbs_data *dbs_data = policy->governor_data; |
51 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; | 64 | struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; |
52 | unsigned int freq_target; | ||
53 | 65 | ||
54 | /* | 66 | /* |
55 | * break out if we 'cannot' reduce the speed as the user might | 67 | * break out if we 'cannot' reduce the speed as the user might |
@@ -66,13 +78,7 @@ static void cs_check_cpu(int cpu, unsigned int load) | |||
66 | if (dbs_info->requested_freq == policy->max) | 78 | if (dbs_info->requested_freq == policy->max) |
67 | return; | 79 | return; |
68 | 80 | ||
69 | freq_target = (cs_tuners->freq_step * policy->max) / 100; | 81 | dbs_info->requested_freq += get_freq_target(cs_tuners, policy); |
70 | |||
71 | /* max freq cannot be less than 100. But who knows.... */ | ||
72 | if (unlikely(freq_target == 0)) | ||
73 | freq_target = 5; | ||
74 | |||
75 | dbs_info->requested_freq += freq_target; | ||
76 | if (dbs_info->requested_freq > policy->max) | 82 | if (dbs_info->requested_freq > policy->max) |
77 | dbs_info->requested_freq = policy->max; | 83 | dbs_info->requested_freq = policy->max; |
78 | 84 | ||
@@ -94,9 +100,7 @@ static void cs_check_cpu(int cpu, unsigned int load) | |||
94 | if (policy->cur == policy->min) | 100 | if (policy->cur == policy->min) |
95 | return; | 101 | return; |
96 | 102 | ||
97 | freq_target = (cs_tuners->freq_step * policy->max) / 100; | 103 | dbs_info->requested_freq -= get_freq_target(cs_tuners, policy); |
98 | |||
99 | dbs_info->requested_freq -= freq_target; | ||
100 | if (dbs_info->requested_freq < policy->min) | 104 | if (dbs_info->requested_freq < policy->min) |
101 | dbs_info->requested_freq = policy->min; | 105 | dbs_info->requested_freq = policy->min; |
102 | 106 | ||
@@ -335,7 +339,7 @@ static int cs_init(struct dbs_data *dbs_data) | |||
335 | tuners->down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD; | 339 | tuners->down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD; |
336 | tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR; | 340 | tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR; |
337 | tuners->ignore_nice = 0; | 341 | tuners->ignore_nice = 0; |
338 | tuners->freq_step = 5; | 342 | tuners->freq_step = DEF_FREQUENCY_STEP; |
339 | 343 | ||
340 | dbs_data->tuners = tuners; | 344 | dbs_data->tuners = tuners; |
341 | dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO * | 345 | dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO * |