blob: 841e25699656bc6a316603d610baf8ef444e9353 [file] [log] [blame]
Dave Jonesb9170832005-05-31 19:03:47 -07001/*
2 * drivers/cpufreq/cpufreq_conservative.c
3 *
4 * Copyright (C) 2001 Russell King
5 * (C) 2003 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>.
6 * Jun Nakajima <jun.nakajima@intel.com>
Alexander Clouter11a80a9c762009-02-13 19:01:01 +00007 * (C) 2009 Alexander Clouter <alex@digriz.org.uk>
Dave Jonesb9170832005-05-31 19:03:47 -07008 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
Viresh Kumar4d5dcc42013-03-27 15:58:58 +000014#include <linux/slab.h>
Viresh Kumar4471a342012-10-26 00:47:42 +020015#include "cpufreq_governor.h"
Dave Jonesb9170832005-05-31 19:03:47 -070016
Stratos Karafotisc88883c2013-02-08 17:24:24 +000017/* Conservative governor macros */
Dave Jonesb9170832005-05-31 19:03:47 -070018#define DEF_FREQUENCY_UP_THRESHOLD (80)
Dave Jonesb9170832005-05-31 19:03:47 -070019#define DEF_FREQUENCY_DOWN_THRESHOLD (20)
Stratos Karafotis98765842013-03-22 08:03:17 +000020#define DEF_FREQUENCY_STEP (5)
Alexander Clouter2c906b32006-03-22 09:54:10 +000021#define DEF_SAMPLING_DOWN_FACTOR (1)
22#define MAX_SAMPLING_DOWN_FACTOR (10)
Dave Jonesb9170832005-05-31 19:03:47 -070023
Viresh Kumar4471a342012-10-26 00:47:42 +020024static DEFINE_PER_CPU(struct cs_cpu_dbs_info_s, cs_cpu_dbs_info);
Dave Jonesb9170832005-05-31 19:03:47 -070025
Stratos Karafotis98765842013-03-22 08:03:17 +000026static inline unsigned int get_freq_target(struct cs_dbs_tuners *cs_tuners,
27 struct cpufreq_policy *policy)
28{
29 unsigned int freq_target = (cs_tuners->freq_step * policy->max) / 100;
30
31 /* max freq cannot be less than 100. But who knows... */
32 if (unlikely(freq_target == 0))
33 freq_target = DEF_FREQUENCY_STEP;
34
35 return freq_target;
36}
37
Viresh Kumar4471a342012-10-26 00:47:42 +020038/*
39 * Every sampling_rate, we check, if current idle time is less than 20%
Stratos Karafotis7af1c052013-03-05 22:06:29 +000040 * (default), then we try to increase frequency. Every sampling_rate *
41 * sampling_down_factor, we check, if current idle time is more than 80%
42 * (default), then we try to decrease frequency
Viresh Kumar4471a342012-10-26 00:47:42 +020043 *
44 * Any frequency increase takes it to the maximum frequency. Frequency reduction
45 * happens at minimum steps of 5% (default) of maximum frequency
46 */
47static void cs_check_cpu(int cpu, unsigned int load)
Elias Oltmannsa8d7c3b2007-10-22 09:50:13 +020048{
Viresh Kumar4471a342012-10-26 00:47:42 +020049 struct cs_cpu_dbs_info_s *dbs_info = &per_cpu(cs_cpu_dbs_info, cpu);
50 struct cpufreq_policy *policy = dbs_info->cdbs.cur_policy;
Viresh Kumar4d5dcc42013-03-27 15:58:58 +000051 struct dbs_data *dbs_data = policy->governor_data;
52 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
Alexander Clouterf407a082009-02-13 19:01:51 +000053
54 /*
Viresh Kumar4471a342012-10-26 00:47:42 +020055 * break out if we 'cannot' reduce the speed as the user might
56 * want freq_step to be zero
57 */
Viresh Kumar4d5dcc42013-03-27 15:58:58 +000058 if (cs_tuners->freq_step == 0)
Viresh Kumar4471a342012-10-26 00:47:42 +020059 return;
60
61 /* Check for frequency increase */
Viresh Kumar4d5dcc42013-03-27 15:58:58 +000062 if (load > cs_tuners->up_threshold) {
Viresh Kumar4471a342012-10-26 00:47:42 +020063 dbs_info->down_skip = 0;
64
65 /* if we are already at full speed then break out early */
66 if (dbs_info->requested_freq == policy->max)
67 return;
68
Stratos Karafotis98765842013-03-22 08:03:17 +000069 dbs_info->requested_freq += get_freq_target(cs_tuners, policy);
Viresh Kumar4471a342012-10-26 00:47:42 +020070 if (dbs_info->requested_freq > policy->max)
71 dbs_info->requested_freq = policy->max;
72
73 __cpufreq_driver_target(policy, dbs_info->requested_freq,
74 CPUFREQ_RELATION_H);
75 return;
76 }
77
Stratos Karafotis7af1c052013-03-05 22:06:29 +000078 /* if sampling_down_factor is active break out early */
79 if (++dbs_info->down_skip < cs_tuners->sampling_down_factor)
80 return;
81 dbs_info->down_skip = 0;
82
Stratos Karafotis27ed3cd2013-03-05 22:06:40 +000083 /* Check for frequency decrease */
84 if (load < cs_tuners->down_threshold) {
Viresh Kumar4471a342012-10-26 00:47:42 +020085 /*
86 * if we cannot reduce the frequency anymore, break out early
87 */
88 if (policy->cur == policy->min)
89 return;
90
Stratos Karafotis98765842013-03-22 08:03:17 +000091 dbs_info->requested_freq -= get_freq_target(cs_tuners, policy);
Namhyung Kimad529a92013-02-28 05:38:01 +000092 if (dbs_info->requested_freq < policy->min)
93 dbs_info->requested_freq = policy->min;
94
Viresh Kumar4471a342012-10-26 00:47:42 +020095 __cpufreq_driver_target(policy, dbs_info->requested_freq,
Namhyung Kimfed573d2013-02-28 05:38:02 +000096 CPUFREQ_RELATION_L);
Viresh Kumar4471a342012-10-26 00:47:42 +020097 return;
98 }
99}
100
Fabio Baltieri66df2a012012-12-27 14:55:41 +0000101static void cs_dbs_timer(struct work_struct *work)
102{
Fabio Baltieri66df2a012012-12-27 14:55:41 +0000103 struct cs_cpu_dbs_info_s *dbs_info = container_of(work,
104 struct cs_cpu_dbs_info_s, cdbs.work.work);
Viresh Kumar44472662013-01-31 17:28:02 +0000105 unsigned int cpu = dbs_info->cdbs.cur_policy->cpu;
106 struct cs_cpu_dbs_info_s *core_dbs_info = &per_cpu(cs_cpu_dbs_info,
107 cpu);
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000108 struct dbs_data *dbs_data = dbs_info->cdbs.cur_policy->governor_data;
109 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
110 int delay = delay_for_sampling_rate(cs_tuners->sampling_rate);
Viresh Kumar031299b2013-02-27 12:24:03 +0530111 bool modify_all = true;
Fabio Baltieri66df2a012012-12-27 14:55:41 +0000112
Viresh Kumar44472662013-01-31 17:28:02 +0000113 mutex_lock(&core_dbs_info->cdbs.timer_mutex);
Viresh Kumar031299b2013-02-27 12:24:03 +0530114 if (!need_load_eval(&core_dbs_info->cdbs, cs_tuners->sampling_rate))
115 modify_all = false;
116 else
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000117 dbs_check_cpu(dbs_data, cpu);
Viresh Kumar44472662013-01-31 17:28:02 +0000118
Viresh Kumar031299b2013-02-27 12:24:03 +0530119 gov_queue_work(dbs_data, dbs_info->cdbs.cur_policy, delay, modify_all);
Viresh Kumar44472662013-01-31 17:28:02 +0000120 mutex_unlock(&core_dbs_info->cdbs.timer_mutex);
Fabio Baltieri66df2a012012-12-27 14:55:41 +0000121}
Viresh Kumar44472662013-01-31 17:28:02 +0000122
Viresh Kumar4471a342012-10-26 00:47:42 +0200123static int dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
124 void *data)
125{
126 struct cpufreq_freqs *freq = data;
127 struct cs_cpu_dbs_info_s *dbs_info =
128 &per_cpu(cs_cpu_dbs_info, freq->cpu);
129 struct cpufreq_policy *policy;
130
131 if (!dbs_info->enable)
132 return 0;
133
134 policy = dbs_info->cdbs.cur_policy;
135
136 /*
137 * we only care if our internally tracked freq moves outside the 'valid'
Stratos Karafotisc88883c2013-02-08 17:24:24 +0000138 * ranges of frequency available to us otherwise we do not change it
Alexander Clouterf407a082009-02-13 19:01:51 +0000139 */
Viresh Kumar4471a342012-10-26 00:47:42 +0200140 if (dbs_info->requested_freq > policy->max
141 || dbs_info->requested_freq < policy->min)
142 dbs_info->requested_freq = freq->new;
Elias Oltmannsa8d7c3b2007-10-22 09:50:13 +0200143
144 return 0;
145}
146
Dave Jonesb9170832005-05-31 19:03:47 -0700147/************************** sysfs interface ************************/
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000148static struct common_dbs_data cs_dbs_cdata;
Dave Jonesb9170832005-05-31 19:03:47 -0700149
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000150static ssize_t store_sampling_down_factor(struct dbs_data *dbs_data,
151 const char *buf, size_t count)
Dave Jonesb9170832005-05-31 19:03:47 -0700152{
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000153 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
Dave Jonesb9170832005-05-31 19:03:47 -0700154 unsigned int input;
155 int ret;
Dave Jones9acef482009-01-18 01:39:51 -0500156 ret = sscanf(buf, "%u", &input);
Alexander Clouter8e677ce2009-02-13 19:02:34 +0000157
Alexander Clouter2c906b32006-03-22 09:54:10 +0000158 if (ret != 1 || input > MAX_SAMPLING_DOWN_FACTOR || input < 1)
Dave Jonesb9170832005-05-31 19:03:47 -0700159 return -EINVAL;
160
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000161 cs_tuners->sampling_down_factor = input;
Dave Jonesb9170832005-05-31 19:03:47 -0700162 return count;
163}
164
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000165static ssize_t store_sampling_rate(struct dbs_data *dbs_data, const char *buf,
166 size_t count)
Dave Jonesb9170832005-05-31 19:03:47 -0700167{
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000168 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
Dave Jonesb9170832005-05-31 19:03:47 -0700169 unsigned int input;
170 int ret;
Dave Jones9acef482009-01-18 01:39:51 -0500171 ret = sscanf(buf, "%u", &input);
Dave Jonesb9170832005-05-31 19:03:47 -0700172
Alexander Clouter8e677ce2009-02-13 19:02:34 +0000173 if (ret != 1)
Dave Jonesb9170832005-05-31 19:03:47 -0700174 return -EINVAL;
Alexander Clouter8e677ce2009-02-13 19:02:34 +0000175
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000176 cs_tuners->sampling_rate = max(input, dbs_data->min_sampling_rate);
Dave Jonesb9170832005-05-31 19:03:47 -0700177 return count;
178}
179
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000180static ssize_t store_up_threshold(struct dbs_data *dbs_data, const char *buf,
181 size_t count)
Dave Jonesb9170832005-05-31 19:03:47 -0700182{
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000183 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
Dave Jonesb9170832005-05-31 19:03:47 -0700184 unsigned int input;
185 int ret;
Dave Jones9acef482009-01-18 01:39:51 -0500186 ret = sscanf(buf, "%u", &input);
Dave Jonesb9170832005-05-31 19:03:47 -0700187
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000188 if (ret != 1 || input > 100 || input <= cs_tuners->down_threshold)
Dave Jonesb9170832005-05-31 19:03:47 -0700189 return -EINVAL;
Dave Jonesb9170832005-05-31 19:03:47 -0700190
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000191 cs_tuners->up_threshold = input;
Dave Jonesb9170832005-05-31 19:03:47 -0700192 return count;
193}
194
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000195static ssize_t store_down_threshold(struct dbs_data *dbs_data, const char *buf,
196 size_t count)
Dave Jonesb9170832005-05-31 19:03:47 -0700197{
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000198 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
Dave Jonesb9170832005-05-31 19:03:47 -0700199 unsigned int input;
200 int ret;
Dave Jones9acef482009-01-18 01:39:51 -0500201 ret = sscanf(buf, "%u", &input);
Dave Jonesb9170832005-05-31 19:03:47 -0700202
Alexander Clouter8e677ce2009-02-13 19:02:34 +0000203 /* cannot be lower than 11 otherwise freq will not fall */
204 if (ret != 1 || input < 11 || input > 100 ||
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000205 input >= cs_tuners->up_threshold)
Dave Jonesb9170832005-05-31 19:03:47 -0700206 return -EINVAL;
Dave Jonesb9170832005-05-31 19:03:47 -0700207
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000208 cs_tuners->down_threshold = input;
Dave Jonesb9170832005-05-31 19:03:47 -0700209 return count;
210}
211
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000212static ssize_t store_ignore_nice(struct dbs_data *dbs_data, const char *buf,
213 size_t count)
Dave Jonesb9170832005-05-31 19:03:47 -0700214{
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000215 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
Viresh Kumar4471a342012-10-26 00:47:42 +0200216 unsigned int input, j;
Dave Jonesb9170832005-05-31 19:03:47 -0700217 int ret;
218
Dave Jones18a72472007-10-22 16:49:09 -0400219 ret = sscanf(buf, "%u", &input);
220 if (ret != 1)
Dave Jonesb9170832005-05-31 19:03:47 -0700221 return -EINVAL;
222
Dave Jones18a72472007-10-22 16:49:09 -0400223 if (input > 1)
Dave Jonesb9170832005-05-31 19:03:47 -0700224 input = 1;
Dave Jones18a72472007-10-22 16:49:09 -0400225
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000226 if (input == cs_tuners->ignore_nice) /* nothing to do */
Dave Jonesb9170832005-05-31 19:03:47 -0700227 return count;
Thomas Renninger326c86d2011-03-03 21:31:27 +0100228
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000229 cs_tuners->ignore_nice = input;
Dave Jonesb9170832005-05-31 19:03:47 -0700230
Alexander Clouter8e677ce2009-02-13 19:02:34 +0000231 /* we need to re-evaluate prev_cpu_idle */
Dave Jonesdac1c1a2005-05-31 19:03:49 -0700232 for_each_online_cpu(j) {
Viresh Kumar4471a342012-10-26 00:47:42 +0200233 struct cs_cpu_dbs_info_s *dbs_info;
Tejun Heo245b2e72009-06-24 15:13:48 +0900234 dbs_info = &per_cpu(cs_cpu_dbs_info, j);
Viresh Kumar4471a342012-10-26 00:47:42 +0200235 dbs_info->cdbs.prev_cpu_idle = get_cpu_idle_time(j,
Stratos Karafotis9366d842013-02-28 16:57:32 +0000236 &dbs_info->cdbs.prev_cpu_wall, 0);
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000237 if (cs_tuners->ignore_nice)
Viresh Kumar4471a342012-10-26 00:47:42 +0200238 dbs_info->cdbs.prev_cpu_nice =
239 kcpustat_cpu(j).cpustat[CPUTIME_NICE];
Dave Jonesb9170832005-05-31 19:03:47 -0700240 }
Dave Jonesb9170832005-05-31 19:03:47 -0700241 return count;
242}
243
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000244static ssize_t store_freq_step(struct dbs_data *dbs_data, const char *buf,
245 size_t count)
Dave Jonesb9170832005-05-31 19:03:47 -0700246{
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000247 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
Dave Jonesb9170832005-05-31 19:03:47 -0700248 unsigned int input;
249 int ret;
Dave Jones18a72472007-10-22 16:49:09 -0400250 ret = sscanf(buf, "%u", &input);
Dave Jonesb9170832005-05-31 19:03:47 -0700251
Dave Jones18a72472007-10-22 16:49:09 -0400252 if (ret != 1)
Dave Jonesb9170832005-05-31 19:03:47 -0700253 return -EINVAL;
254
Dave Jones18a72472007-10-22 16:49:09 -0400255 if (input > 100)
Dave Jonesb9170832005-05-31 19:03:47 -0700256 input = 100;
Dave Jones18a72472007-10-22 16:49:09 -0400257
Viresh Kumar4471a342012-10-26 00:47:42 +0200258 /*
259 * no need to test here if freq_step is zero as the user might actually
260 * want this, they would be crazy though :)
261 */
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000262 cs_tuners->freq_step = input;
Dave Jonesb9170832005-05-31 19:03:47 -0700263 return count;
264}
265
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000266show_store_one(cs, sampling_rate);
267show_store_one(cs, sampling_down_factor);
268show_store_one(cs, up_threshold);
269show_store_one(cs, down_threshold);
270show_store_one(cs, ignore_nice);
271show_store_one(cs, freq_step);
272declare_show_sampling_rate_min(cs);
Viresh Kumar4471a342012-10-26 00:47:42 +0200273
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000274gov_sys_pol_attr_rw(sampling_rate);
275gov_sys_pol_attr_rw(sampling_down_factor);
276gov_sys_pol_attr_rw(up_threshold);
277gov_sys_pol_attr_rw(down_threshold);
278gov_sys_pol_attr_rw(ignore_nice);
279gov_sys_pol_attr_rw(freq_step);
280gov_sys_pol_attr_ro(sampling_rate_min);
Dave Jonesb9170832005-05-31 19:03:47 -0700281
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000282static struct attribute *dbs_attributes_gov_sys[] = {
283 &sampling_rate_min_gov_sys.attr,
284 &sampling_rate_gov_sys.attr,
285 &sampling_down_factor_gov_sys.attr,
286 &up_threshold_gov_sys.attr,
287 &down_threshold_gov_sys.attr,
288 &ignore_nice_gov_sys.attr,
289 &freq_step_gov_sys.attr,
Dave Jonesb9170832005-05-31 19:03:47 -0700290 NULL
291};
292
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000293static struct attribute_group cs_attr_group_gov_sys = {
294 .attrs = dbs_attributes_gov_sys,
295 .name = "conservative",
296};
297
298static struct attribute *dbs_attributes_gov_pol[] = {
299 &sampling_rate_min_gov_pol.attr,
300 &sampling_rate_gov_pol.attr,
301 &sampling_down_factor_gov_pol.attr,
302 &up_threshold_gov_pol.attr,
303 &down_threshold_gov_pol.attr,
304 &ignore_nice_gov_pol.attr,
305 &freq_step_gov_pol.attr,
306 NULL
307};
308
309static struct attribute_group cs_attr_group_gov_pol = {
310 .attrs = dbs_attributes_gov_pol,
Dave Jonesb9170832005-05-31 19:03:47 -0700311 .name = "conservative",
312};
313
314/************************** sysfs end ************************/
315
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000316static int cs_init(struct dbs_data *dbs_data)
317{
318 struct cs_dbs_tuners *tuners;
319
320 tuners = kzalloc(sizeof(struct cs_dbs_tuners), GFP_KERNEL);
321 if (!tuners) {
322 pr_err("%s: kzalloc failed\n", __func__);
323 return -ENOMEM;
324 }
325
326 tuners->up_threshold = DEF_FREQUENCY_UP_THRESHOLD;
327 tuners->down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD;
328 tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR;
329 tuners->ignore_nice = 0;
Stratos Karafotis98765842013-03-22 08:03:17 +0000330 tuners->freq_step = DEF_FREQUENCY_STEP;
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000331
332 dbs_data->tuners = tuners;
333 dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
334 jiffies_to_usecs(10);
335 mutex_init(&dbs_data->mutex);
336 return 0;
337}
338
339static void cs_exit(struct dbs_data *dbs_data)
340{
341 kfree(dbs_data->tuners);
342}
343
Viresh Kumar4471a342012-10-26 00:47:42 +0200344define_get_cpu_dbs_routines(cs_cpu_dbs_info);
Dave Jonesb9170832005-05-31 19:03:47 -0700345
Viresh Kumar4471a342012-10-26 00:47:42 +0200346static struct notifier_block cs_cpufreq_notifier_block = {
347 .notifier_call = dbs_cpufreq_notifier,
348};
Dave Jonesb9170832005-05-31 19:03:47 -0700349
Viresh Kumar4471a342012-10-26 00:47:42 +0200350static struct cs_ops cs_ops = {
351 .notifier_block = &cs_cpufreq_notifier_block,
352};
Alexander Clouter08a28e22006-03-22 09:59:16 +0000353
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000354static struct common_dbs_data cs_dbs_cdata = {
Viresh Kumar4471a342012-10-26 00:47:42 +0200355 .governor = GOV_CONSERVATIVE,
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000356 .attr_group_gov_sys = &cs_attr_group_gov_sys,
357 .attr_group_gov_pol = &cs_attr_group_gov_pol,
Viresh Kumar4471a342012-10-26 00:47:42 +0200358 .get_cpu_cdbs = get_cpu_cdbs,
359 .get_cpu_dbs_info_s = get_cpu_dbs_info_s,
360 .gov_dbs_timer = cs_dbs_timer,
361 .gov_check_cpu = cs_check_cpu,
362 .gov_ops = &cs_ops,
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000363 .init = cs_init,
364 .exit = cs_exit,
Viresh Kumar4471a342012-10-26 00:47:42 +0200365};
Dave Jonesb9170832005-05-31 19:03:47 -0700366
Viresh Kumar4471a342012-10-26 00:47:42 +0200367static int cs_cpufreq_governor_dbs(struct cpufreq_policy *policy,
Dave Jonesb9170832005-05-31 19:03:47 -0700368 unsigned int event)
369{
Viresh Kumar4d5dcc42013-03-27 15:58:58 +0000370 return cpufreq_governor_dbs(policy, &cs_dbs_cdata, event);
Dave Jonesb9170832005-05-31 19:03:47 -0700371}
372
Sven Wegenerc4d14bc2008-09-20 16:50:08 +0200373#ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE
374static
375#endif
Thomas Renninger1c256242007-10-02 13:28:12 -0700376struct cpufreq_governor cpufreq_gov_conservative = {
377 .name = "conservative",
Viresh Kumar4471a342012-10-26 00:47:42 +0200378 .governor = cs_cpufreq_governor_dbs,
Thomas Renninger1c256242007-10-02 13:28:12 -0700379 .max_transition_latency = TRANSITION_LATENCY_LIMIT,
380 .owner = THIS_MODULE,
Dave Jonesb9170832005-05-31 19:03:47 -0700381};
382
383static int __init cpufreq_gov_dbs_init(void)
384{
Tejun Heo57df5572011-01-26 12:12:50 +0100385 return cpufreq_register_governor(&cpufreq_gov_conservative);
Dave Jonesb9170832005-05-31 19:03:47 -0700386}
387
388static void __exit cpufreq_gov_dbs_exit(void)
389{
Thomas Renninger1c256242007-10-02 13:28:12 -0700390 cpufreq_unregister_governor(&cpufreq_gov_conservative);
Dave Jonesb9170832005-05-31 19:03:47 -0700391}
392
Alexander Clouter11a80a9c762009-02-13 19:01:01 +0000393MODULE_AUTHOR("Alexander Clouter <alex@digriz.org.uk>");
Dave Jones9acef482009-01-18 01:39:51 -0500394MODULE_DESCRIPTION("'cpufreq_conservative' - A dynamic cpufreq governor for "
Dave Jonesb9170832005-05-31 19:03:47 -0700395 "Low Latency Frequency Transition capable processors "
396 "optimised for use in a battery environment");
Dave Jones9acef482009-01-18 01:39:51 -0500397MODULE_LICENSE("GPL");
Dave Jonesb9170832005-05-31 19:03:47 -0700398
Johannes Weiner69157192008-01-17 15:21:08 -0800399#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE
400fs_initcall(cpufreq_gov_dbs_init);
401#else
Dave Jonesb9170832005-05-31 19:03:47 -0700402module_init(cpufreq_gov_dbs_init);
Johannes Weiner69157192008-01-17 15:21:08 -0800403#endif
Dave Jonesb9170832005-05-31 19:03:47 -0700404module_exit(cpufreq_gov_dbs_exit);