cpufreq_ondemand.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. /*
  2. * drivers/cpufreq/cpufreq_ondemand.c
  3. *
  4. * Copyright (C) 2001 Russell King
  5. * (C) 2003 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>.
  6. * Jun Nakajima <jun.nakajima@intel.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  13. #include <linux/cpufreq.h>
  14. #include <linux/init.h>
  15. #include <linux/kernel.h>
  16. #include <linux/kernel_stat.h>
  17. #include <linux/kobject.h>
  18. #include <linux/module.h>
  19. #include <linux/mutex.h>
  20. #include <linux/percpu-defs.h>
  21. #include <linux/slab.h>
  22. #include <linux/sysfs.h>
  23. #include <linux/tick.h>
  24. #include <linux/types.h>
  25. #include "cpufreq_governor.h"
  26. /* On-demand governor macros */
  27. #define DEF_FREQUENCY_DOWN_DIFFERENTIAL (10)
  28. #define DEF_FREQUENCY_UP_THRESHOLD (80)
  29. #define DEF_SAMPLING_DOWN_FACTOR (1)
  30. #define MAX_SAMPLING_DOWN_FACTOR (100000)
  31. #define MICRO_FREQUENCY_DOWN_DIFFERENTIAL (3)
  32. #define MICRO_FREQUENCY_UP_THRESHOLD (95)
  33. #define MICRO_FREQUENCY_MIN_SAMPLE_RATE (10000)
  34. #define MIN_FREQUENCY_UP_THRESHOLD (11)
  35. #define MAX_FREQUENCY_UP_THRESHOLD (100)
  36. static DEFINE_PER_CPU(struct od_cpu_dbs_info_s, od_cpu_dbs_info);
  37. #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND
  38. static struct cpufreq_governor cpufreq_gov_ondemand;
  39. #endif
  40. static void ondemand_powersave_bias_init_cpu(int cpu)
  41. {
  42. struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, cpu);
  43. dbs_info->freq_table = cpufreq_frequency_get_table(cpu);
  44. dbs_info->freq_lo = 0;
  45. }
  46. /*
  47. * Not all CPUs want IO time to be accounted as busy; this depends on how
  48. * efficient idling at a higher frequency/voltage is.
  49. * Pavel Machek says this is not so for various generations of AMD and old
  50. * Intel systems.
  51. * Mike Chan (android.com) claims this is also not true for ARM.
  52. * Because of this, whitelist specific known (series) of CPUs by default, and
  53. * leave all others up to the user.
  54. */
  55. static int should_io_be_busy(void)
  56. {
  57. #if defined(CONFIG_X86)
  58. /*
  59. * For Intel, Core 2 (model 15) and later have an efficient idle.
  60. */
  61. if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
  62. boot_cpu_data.x86 == 6 &&
  63. boot_cpu_data.x86_model >= 15)
  64. return 1;
  65. #endif
  66. return 0;
  67. }
  68. /*
  69. * Find right freq to be set now with powersave_bias on.
  70. * Returns the freq_hi to be used right now and will set freq_hi_jiffies,
  71. * freq_lo, and freq_lo_jiffies in percpu area for averaging freqs.
  72. */
  73. static unsigned int powersave_bias_target(struct cpufreq_policy *policy,
  74. unsigned int freq_next, unsigned int relation)
  75. {
  76. unsigned int freq_req, freq_reduc, freq_avg;
  77. unsigned int freq_hi, freq_lo;
  78. unsigned int index = 0;
  79. unsigned int jiffies_total, jiffies_hi, jiffies_lo;
  80. struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info,
  81. policy->cpu);
  82. struct dbs_data *dbs_data = policy->governor_data;
  83. struct od_dbs_tuners *od_tuners = dbs_data->tuners;
  84. if (!dbs_info->freq_table) {
  85. dbs_info->freq_lo = 0;
  86. dbs_info->freq_lo_jiffies = 0;
  87. return freq_next;
  88. }
  89. cpufreq_frequency_table_target(policy, dbs_info->freq_table, freq_next,
  90. relation, &index);
  91. freq_req = dbs_info->freq_table[index].frequency;
  92. freq_reduc = freq_req * od_tuners->powersave_bias / 1000;
  93. freq_avg = freq_req - freq_reduc;
  94. /* Find freq bounds for freq_avg in freq_table */
  95. index = 0;
  96. cpufreq_frequency_table_target(policy, dbs_info->freq_table, freq_avg,
  97. CPUFREQ_RELATION_H, &index);
  98. freq_lo = dbs_info->freq_table[index].frequency;
  99. index = 0;
  100. cpufreq_frequency_table_target(policy, dbs_info->freq_table, freq_avg,
  101. CPUFREQ_RELATION_L, &index);
  102. freq_hi = dbs_info->freq_table[index].frequency;
  103. /* Find out how long we have to be in hi and lo freqs */
  104. if (freq_hi == freq_lo) {
  105. dbs_info->freq_lo = 0;
  106. dbs_info->freq_lo_jiffies = 0;
  107. return freq_lo;
  108. }
  109. jiffies_total = usecs_to_jiffies(od_tuners->sampling_rate);
  110. jiffies_hi = (freq_avg - freq_lo) * jiffies_total;
  111. jiffies_hi += ((freq_hi - freq_lo) / 2);
  112. jiffies_hi /= (freq_hi - freq_lo);
  113. jiffies_lo = jiffies_total - jiffies_hi;
  114. dbs_info->freq_lo = freq_lo;
  115. dbs_info->freq_lo_jiffies = jiffies_lo;
  116. dbs_info->freq_hi_jiffies = jiffies_hi;
  117. return freq_hi;
  118. }
  119. static void ondemand_powersave_bias_init(void)
  120. {
  121. int i;
  122. for_each_online_cpu(i) {
  123. ondemand_powersave_bias_init_cpu(i);
  124. }
  125. }
  126. static void dbs_freq_increase(struct cpufreq_policy *p, unsigned int freq)
  127. {
  128. struct dbs_data *dbs_data = p->governor_data;
  129. struct od_dbs_tuners *od_tuners = dbs_data->tuners;
  130. if (od_tuners->powersave_bias)
  131. freq = powersave_bias_target(p, freq, CPUFREQ_RELATION_H);
  132. else if (p->cur == p->max)
  133. return;
  134. __cpufreq_driver_target(p, freq, od_tuners->powersave_bias ?
  135. CPUFREQ_RELATION_L : CPUFREQ_RELATION_H);
  136. }
  137. /*
  138. * Every sampling_rate, we check, if current idle time is less than 20%
  139. * (default), then we try to increase frequency. Every sampling_rate, we look
  140. * for the lowest frequency which can sustain the load while keeping idle time
  141. * over 30%. If such a frequency exist, we try to decrease to this frequency.
  142. *
  143. * Any frequency increase takes it to the maximum frequency. Frequency reduction
  144. * happens at minimum steps of 5% (default) of current frequency
  145. */
  146. static void od_check_cpu(int cpu, unsigned int load_freq)
  147. {
  148. struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, cpu);
  149. struct cpufreq_policy *policy = dbs_info->cdbs.cur_policy;
  150. struct dbs_data *dbs_data = policy->governor_data;
  151. struct od_dbs_tuners *od_tuners = dbs_data->tuners;
  152. dbs_info->freq_lo = 0;
  153. /* Check for frequency increase */
  154. if (load_freq > od_tuners->up_threshold * policy->cur) {
  155. /* If switching to max speed, apply sampling_down_factor */
  156. if (policy->cur < policy->max)
  157. dbs_info->rate_mult =
  158. od_tuners->sampling_down_factor;
  159. dbs_freq_increase(policy, policy->max);
  160. return;
  161. }
  162. /* Check for frequency decrease */
  163. /* if we cannot reduce the frequency anymore, break out early */
  164. if (policy->cur == policy->min)
  165. return;
  166. /*
  167. * The optimal frequency is the frequency that is the lowest that can
  168. * support the current CPU usage without triggering the up policy. To be
  169. * safe, we focus 10 points under the threshold.
  170. */
  171. if (load_freq < od_tuners->adj_up_threshold
  172. * policy->cur) {
  173. unsigned int freq_next;
  174. freq_next = load_freq / od_tuners->adj_up_threshold;
  175. /* No longer fully busy, reset rate_mult */
  176. dbs_info->rate_mult = 1;
  177. if (freq_next < policy->min)
  178. freq_next = policy->min;
  179. if (!od_tuners->powersave_bias) {
  180. __cpufreq_driver_target(policy, freq_next,
  181. CPUFREQ_RELATION_L);
  182. } else {
  183. int freq = powersave_bias_target(policy, freq_next,
  184. CPUFREQ_RELATION_L);
  185. __cpufreq_driver_target(policy, freq,
  186. CPUFREQ_RELATION_L);
  187. }
  188. }
  189. }
  190. static void od_dbs_timer(struct work_struct *work)
  191. {
  192. struct delayed_work *dw = to_delayed_work(work);
  193. struct od_cpu_dbs_info_s *dbs_info =
  194. container_of(work, struct od_cpu_dbs_info_s, cdbs.work.work);
  195. unsigned int cpu = dbs_info->cdbs.cur_policy->cpu;
  196. struct od_cpu_dbs_info_s *core_dbs_info = &per_cpu(od_cpu_dbs_info,
  197. cpu);
  198. struct dbs_data *dbs_data = dbs_info->cdbs.cur_policy->governor_data;
  199. struct od_dbs_tuners *od_tuners = dbs_data->tuners;
  200. int delay = 0, sample_type = core_dbs_info->sample_type;
  201. mutex_lock(&core_dbs_info->cdbs.timer_mutex);
  202. if (!need_load_eval(&core_dbs_info->cdbs, od_tuners->sampling_rate))
  203. goto max_delay;
  204. /* Common NORMAL_SAMPLE setup */
  205. core_dbs_info->sample_type = OD_NORMAL_SAMPLE;
  206. if (sample_type == OD_SUB_SAMPLE) {
  207. delay = core_dbs_info->freq_lo_jiffies;
  208. __cpufreq_driver_target(core_dbs_info->cdbs.cur_policy,
  209. core_dbs_info->freq_lo, CPUFREQ_RELATION_H);
  210. } else {
  211. dbs_check_cpu(dbs_data, cpu);
  212. if (core_dbs_info->freq_lo) {
  213. /* Setup timer for SUB_SAMPLE */
  214. core_dbs_info->sample_type = OD_SUB_SAMPLE;
  215. delay = core_dbs_info->freq_hi_jiffies;
  216. }
  217. }
  218. max_delay:
  219. if (!delay)
  220. delay = delay_for_sampling_rate(od_tuners->sampling_rate
  221. * core_dbs_info->rate_mult);
  222. schedule_delayed_work_on(smp_processor_id(), dw, delay);
  223. mutex_unlock(&core_dbs_info->cdbs.timer_mutex);
  224. }
  225. /************************** sysfs interface ************************/
  226. static struct common_dbs_data od_dbs_cdata;
  227. /**
  228. * update_sampling_rate - update sampling rate effective immediately if needed.
  229. * @new_rate: new sampling rate
  230. *
  231. * If new rate is smaller than the old, simply updating
  232. * dbs_tuners_int.sampling_rate might not be appropriate. For example, if the
  233. * original sampling_rate was 1 second and the requested new sampling rate is 10
  234. * ms because the user needs immediate reaction from ondemand governor, but not
  235. * sure if higher frequency will be required or not, then, the governor may
  236. * change the sampling rate too late; up to 1 second later. Thus, if we are
  237. * reducing the sampling rate, we need to make the new value effective
  238. * immediately.
  239. */
  240. static void update_sampling_rate(struct dbs_data *dbs_data,
  241. unsigned int new_rate)
  242. {
  243. struct od_dbs_tuners *od_tuners = dbs_data->tuners;
  244. int cpu;
  245. od_tuners->sampling_rate = new_rate = max(new_rate,
  246. dbs_data->min_sampling_rate);
  247. for_each_online_cpu(cpu) {
  248. struct cpufreq_policy *policy;
  249. struct od_cpu_dbs_info_s *dbs_info;
  250. unsigned long next_sampling, appointed_at;
  251. policy = cpufreq_cpu_get(cpu);
  252. if (!policy)
  253. continue;
  254. if (policy->governor != &cpufreq_gov_ondemand) {
  255. cpufreq_cpu_put(policy);
  256. continue;
  257. }
  258. dbs_info = &per_cpu(od_cpu_dbs_info, cpu);
  259. cpufreq_cpu_put(policy);
  260. mutex_lock(&dbs_info->cdbs.timer_mutex);
  261. if (!delayed_work_pending(&dbs_info->cdbs.work)) {
  262. mutex_unlock(&dbs_info->cdbs.timer_mutex);
  263. continue;
  264. }
  265. next_sampling = jiffies + usecs_to_jiffies(new_rate);
  266. appointed_at = dbs_info->cdbs.work.timer.expires;
  267. if (time_before(next_sampling, appointed_at)) {
  268. mutex_unlock(&dbs_info->cdbs.timer_mutex);
  269. cancel_delayed_work_sync(&dbs_info->cdbs.work);
  270. mutex_lock(&dbs_info->cdbs.timer_mutex);
  271. schedule_delayed_work_on(cpu, &dbs_info->cdbs.work,
  272. usecs_to_jiffies(new_rate));
  273. }
  274. mutex_unlock(&dbs_info->cdbs.timer_mutex);
  275. }
  276. }
  277. static ssize_t store_sampling_rate(struct dbs_data *dbs_data, const char *buf,
  278. size_t count)
  279. {
  280. unsigned int input;
  281. int ret;
  282. ret = sscanf(buf, "%u", &input);
  283. if (ret != 1)
  284. return -EINVAL;
  285. update_sampling_rate(dbs_data, input);
  286. return count;
  287. }
  288. static ssize_t store_io_is_busy(struct dbs_data *dbs_data, const char *buf,
  289. size_t count)
  290. {
  291. struct od_dbs_tuners *od_tuners = dbs_data->tuners;
  292. unsigned int input;
  293. int ret;
  294. ret = sscanf(buf, "%u", &input);
  295. if (ret != 1)
  296. return -EINVAL;
  297. od_tuners->io_is_busy = !!input;
  298. return count;
  299. }
  300. static ssize_t store_up_threshold(struct dbs_data *dbs_data, const char *buf,
  301. size_t count)
  302. {
  303. struct od_dbs_tuners *od_tuners = dbs_data->tuners;
  304. unsigned int input;
  305. int ret;
  306. ret = sscanf(buf, "%u", &input);
  307. if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD ||
  308. input < MIN_FREQUENCY_UP_THRESHOLD) {
  309. return -EINVAL;
  310. }
  311. /* Calculate the new adj_up_threshold */
  312. od_tuners->adj_up_threshold += input;
  313. od_tuners->adj_up_threshold -= od_tuners->up_threshold;
  314. od_tuners->up_threshold = input;
  315. return count;
  316. }
  317. static ssize_t store_sampling_down_factor(struct dbs_data *dbs_data,
  318. const char *buf, size_t count)
  319. {
  320. struct od_dbs_tuners *od_tuners = dbs_data->tuners;
  321. unsigned int input, j;
  322. int ret;
  323. ret = sscanf(buf, "%u", &input);
  324. if (ret != 1 || input > MAX_SAMPLING_DOWN_FACTOR || input < 1)
  325. return -EINVAL;
  326. od_tuners->sampling_down_factor = input;
  327. /* Reset down sampling multiplier in case it was active */
  328. for_each_online_cpu(j) {
  329. struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info,
  330. j);
  331. dbs_info->rate_mult = 1;
  332. }
  333. return count;
  334. }
  335. static ssize_t store_ignore_nice(struct dbs_data *dbs_data, const char *buf,
  336. size_t count)
  337. {
  338. struct od_dbs_tuners *od_tuners = dbs_data->tuners;
  339. unsigned int input;
  340. int ret;
  341. unsigned int j;
  342. ret = sscanf(buf, "%u", &input);
  343. if (ret != 1)
  344. return -EINVAL;
  345. if (input > 1)
  346. input = 1;
  347. if (input == od_tuners->ignore_nice) { /* nothing to do */
  348. return count;
  349. }
  350. od_tuners->ignore_nice = input;
  351. /* we need to re-evaluate prev_cpu_idle */
  352. for_each_online_cpu(j) {
  353. struct od_cpu_dbs_info_s *dbs_info;
  354. dbs_info = &per_cpu(od_cpu_dbs_info, j);
  355. dbs_info->cdbs.prev_cpu_idle = get_cpu_idle_time(j,
  356. &dbs_info->cdbs.prev_cpu_wall);
  357. if (od_tuners->ignore_nice)
  358. dbs_info->cdbs.prev_cpu_nice =
  359. kcpustat_cpu(j).cpustat[CPUTIME_NICE];
  360. }
  361. return count;
  362. }
  363. static ssize_t store_powersave_bias(struct dbs_data *dbs_data, const char *buf,
  364. size_t count)
  365. {
  366. struct od_dbs_tuners *od_tuners = dbs_data->tuners;
  367. unsigned int input;
  368. int ret;
  369. ret = sscanf(buf, "%u", &input);
  370. if (ret != 1)
  371. return -EINVAL;
  372. if (input > 1000)
  373. input = 1000;
  374. od_tuners->powersave_bias = input;
  375. ondemand_powersave_bias_init();
  376. return count;
  377. }
  378. show_store_one(od, sampling_rate);
  379. show_store_one(od, io_is_busy);
  380. show_store_one(od, up_threshold);
  381. show_store_one(od, sampling_down_factor);
  382. show_store_one(od, ignore_nice);
  383. show_store_one(od, powersave_bias);
  384. declare_show_sampling_rate_min(od);
  385. gov_sys_pol_attr_rw(sampling_rate);
  386. gov_sys_pol_attr_rw(io_is_busy);
  387. gov_sys_pol_attr_rw(up_threshold);
  388. gov_sys_pol_attr_rw(sampling_down_factor);
  389. gov_sys_pol_attr_rw(ignore_nice);
  390. gov_sys_pol_attr_rw(powersave_bias);
  391. gov_sys_pol_attr_ro(sampling_rate_min);
  392. static struct attribute *dbs_attributes_gov_sys[] = {
  393. &sampling_rate_min_gov_sys.attr,
  394. &sampling_rate_gov_sys.attr,
  395. &up_threshold_gov_sys.attr,
  396. &sampling_down_factor_gov_sys.attr,
  397. &ignore_nice_gov_sys.attr,
  398. &powersave_bias_gov_sys.attr,
  399. &io_is_busy_gov_sys.attr,
  400. NULL
  401. };
  402. static struct attribute_group od_attr_group_gov_sys = {
  403. .attrs = dbs_attributes_gov_sys,
  404. .name = "ondemand",
  405. };
  406. static struct attribute *dbs_attributes_gov_pol[] = {
  407. &sampling_rate_min_gov_pol.attr,
  408. &sampling_rate_gov_pol.attr,
  409. &up_threshold_gov_pol.attr,
  410. &sampling_down_factor_gov_pol.attr,
  411. &ignore_nice_gov_pol.attr,
  412. &powersave_bias_gov_pol.attr,
  413. &io_is_busy_gov_pol.attr,
  414. NULL
  415. };
  416. static struct attribute_group od_attr_group_gov_pol = {
  417. .attrs = dbs_attributes_gov_pol,
  418. .name = "ondemand",
  419. };
  420. /************************** sysfs end ************************/
  421. static int od_init(struct dbs_data *dbs_data)
  422. {
  423. struct od_dbs_tuners *tuners;
  424. u64 idle_time;
  425. int cpu;
  426. tuners = kzalloc(sizeof(struct od_dbs_tuners), GFP_KERNEL);
  427. if (!tuners) {
  428. pr_err("%s: kzalloc failed\n", __func__);
  429. return -ENOMEM;
  430. }
  431. cpu = get_cpu();
  432. idle_time = get_cpu_idle_time_us(cpu, NULL);
  433. put_cpu();
  434. if (idle_time != -1ULL) {
  435. /* Idle micro accounting is supported. Use finer thresholds */
  436. tuners->up_threshold = MICRO_FREQUENCY_UP_THRESHOLD;
  437. tuners->adj_up_threshold = MICRO_FREQUENCY_UP_THRESHOLD -
  438. MICRO_FREQUENCY_DOWN_DIFFERENTIAL;
  439. /*
  440. * In nohz/micro accounting case we set the minimum frequency
  441. * not depending on HZ, but fixed (very low). The deferred
  442. * timer might skip some samples if idle/sleeping as needed.
  443. */
  444. dbs_data->min_sampling_rate = MICRO_FREQUENCY_MIN_SAMPLE_RATE;
  445. } else {
  446. tuners->up_threshold = DEF_FREQUENCY_UP_THRESHOLD;
  447. tuners->adj_up_threshold = DEF_FREQUENCY_UP_THRESHOLD -
  448. DEF_FREQUENCY_DOWN_DIFFERENTIAL;
  449. /* For correct statistics, we need 10 ticks for each measure */
  450. dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
  451. jiffies_to_usecs(10);
  452. }
  453. tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR;
  454. tuners->ignore_nice = 0;
  455. tuners->powersave_bias = 0;
  456. tuners->io_is_busy = should_io_be_busy();
  457. dbs_data->tuners = tuners;
  458. pr_info("%s: tuners %p\n", __func__, tuners);
  459. mutex_init(&dbs_data->mutex);
  460. return 0;
  461. }
  462. static void od_exit(struct dbs_data *dbs_data)
  463. {
  464. kfree(dbs_data->tuners);
  465. }
  466. define_get_cpu_dbs_routines(od_cpu_dbs_info);
  467. static struct od_ops od_ops = {
  468. .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
  469. .powersave_bias_target = powersave_bias_target,
  470. .freq_increase = dbs_freq_increase,
  471. };
  472. static struct common_dbs_data od_dbs_cdata = {
  473. .governor = GOV_ONDEMAND,
  474. .attr_group_gov_sys = &od_attr_group_gov_sys,
  475. .attr_group_gov_pol = &od_attr_group_gov_pol,
  476. .get_cpu_cdbs = get_cpu_cdbs,
  477. .get_cpu_dbs_info_s = get_cpu_dbs_info_s,
  478. .gov_dbs_timer = od_dbs_timer,
  479. .gov_check_cpu = od_check_cpu,
  480. .gov_ops = &od_ops,
  481. .init = od_init,
  482. .exit = od_exit,
  483. };
  484. static int od_cpufreq_governor_dbs(struct cpufreq_policy *policy,
  485. unsigned int event)
  486. {
  487. return cpufreq_governor_dbs(policy, &od_dbs_cdata, event);
  488. }
  489. #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND
  490. static
  491. #endif
  492. struct cpufreq_governor cpufreq_gov_ondemand = {
  493. .name = "ondemand",
  494. .governor = od_cpufreq_governor_dbs,
  495. .max_transition_latency = TRANSITION_LATENCY_LIMIT,
  496. .owner = THIS_MODULE,
  497. };
  498. static int __init cpufreq_gov_dbs_init(void)
  499. {
  500. return cpufreq_register_governor(&cpufreq_gov_ondemand);
  501. }
  502. static void __exit cpufreq_gov_dbs_exit(void)
  503. {
  504. cpufreq_unregister_governor(&cpufreq_gov_ondemand);
  505. }
  506. MODULE_AUTHOR("Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>");
  507. MODULE_AUTHOR("Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>");
  508. MODULE_DESCRIPTION("'cpufreq_ondemand' - A dynamic cpufreq governor for "
  509. "Low Latency Frequency Transition capable processors");
  510. MODULE_LICENSE("GPL");
  511. #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND
  512. fs_initcall(cpufreq_gov_dbs_init);
  513. #else
  514. module_init(cpufreq_gov_dbs_init);
  515. #endif
  516. module_exit(cpufreq_gov_dbs_exit);