cpufreq_ondemand.c 17 KB

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