cpufreq_ondemand.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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. mutex_lock(&dbs_info->cdbs.shared->timer_mutex);
  234. if (!delayed_work_pending(&dbs_info->cdbs.dwork)) {
  235. mutex_unlock(&dbs_info->cdbs.shared->timer_mutex);
  236. continue;
  237. }
  238. next_sampling = jiffies + usecs_to_jiffies(new_rate);
  239. appointed_at = dbs_info->cdbs.dwork.timer.expires;
  240. if (time_before(next_sampling, appointed_at)) {
  241. mutex_unlock(&dbs_info->cdbs.shared->timer_mutex);
  242. cancel_delayed_work_sync(&dbs_info->cdbs.dwork);
  243. mutex_lock(&dbs_info->cdbs.shared->timer_mutex);
  244. gov_queue_work(dbs_data, policy,
  245. usecs_to_jiffies(new_rate), true);
  246. }
  247. mutex_unlock(&dbs_info->cdbs.shared->timer_mutex);
  248. }
  249. }
  250. static ssize_t store_sampling_rate(struct dbs_data *dbs_data, const char *buf,
  251. size_t count)
  252. {
  253. unsigned int input;
  254. int ret;
  255. ret = sscanf(buf, "%u", &input);
  256. if (ret != 1)
  257. return -EINVAL;
  258. update_sampling_rate(dbs_data, input);
  259. return count;
  260. }
  261. static ssize_t store_io_is_busy(struct dbs_data *dbs_data, const char *buf,
  262. size_t count)
  263. {
  264. struct od_dbs_tuners *od_tuners = dbs_data->tuners;
  265. unsigned int input;
  266. int ret;
  267. unsigned int j;
  268. ret = sscanf(buf, "%u", &input);
  269. if (ret != 1)
  270. return -EINVAL;
  271. od_tuners->io_is_busy = !!input;
  272. /* we need to re-evaluate prev_cpu_idle */
  273. for_each_online_cpu(j) {
  274. struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info,
  275. j);
  276. dbs_info->cdbs.prev_cpu_idle = get_cpu_idle_time(j,
  277. &dbs_info->cdbs.prev_cpu_wall, od_tuners->io_is_busy);
  278. }
  279. return count;
  280. }
  281. static ssize_t store_up_threshold(struct dbs_data *dbs_data, const char *buf,
  282. size_t count)
  283. {
  284. struct od_dbs_tuners *od_tuners = dbs_data->tuners;
  285. unsigned int input;
  286. int ret;
  287. ret = sscanf(buf, "%u", &input);
  288. if (ret != 1 || input > MAX_FREQUENCY_UP_THRESHOLD ||
  289. input < MIN_FREQUENCY_UP_THRESHOLD) {
  290. return -EINVAL;
  291. }
  292. od_tuners->up_threshold = input;
  293. return count;
  294. }
  295. static ssize_t store_sampling_down_factor(struct dbs_data *dbs_data,
  296. const char *buf, size_t count)
  297. {
  298. struct od_dbs_tuners *od_tuners = dbs_data->tuners;
  299. unsigned int input, j;
  300. int ret;
  301. ret = sscanf(buf, "%u", &input);
  302. if (ret != 1 || input > MAX_SAMPLING_DOWN_FACTOR || input < 1)
  303. return -EINVAL;
  304. od_tuners->sampling_down_factor = input;
  305. /* Reset down sampling multiplier in case it was active */
  306. for_each_online_cpu(j) {
  307. struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info,
  308. j);
  309. dbs_info->rate_mult = 1;
  310. }
  311. return count;
  312. }
  313. static ssize_t store_ignore_nice_load(struct dbs_data *dbs_data,
  314. const char *buf, size_t count)
  315. {
  316. struct od_dbs_tuners *od_tuners = dbs_data->tuners;
  317. unsigned int input;
  318. int ret;
  319. unsigned int j;
  320. ret = sscanf(buf, "%u", &input);
  321. if (ret != 1)
  322. return -EINVAL;
  323. if (input > 1)
  324. input = 1;
  325. if (input == od_tuners->ignore_nice_load) { /* nothing to do */
  326. return count;
  327. }
  328. od_tuners->ignore_nice_load = input;
  329. /* we need to re-evaluate prev_cpu_idle */
  330. for_each_online_cpu(j) {
  331. struct od_cpu_dbs_info_s *dbs_info;
  332. dbs_info = &per_cpu(od_cpu_dbs_info, j);
  333. dbs_info->cdbs.prev_cpu_idle = get_cpu_idle_time(j,
  334. &dbs_info->cdbs.prev_cpu_wall, od_tuners->io_is_busy);
  335. if (od_tuners->ignore_nice_load)
  336. dbs_info->cdbs.prev_cpu_nice =
  337. kcpustat_cpu(j).cpustat[CPUTIME_NICE];
  338. }
  339. return count;
  340. }
  341. static ssize_t store_powersave_bias(struct dbs_data *dbs_data, const char *buf,
  342. size_t count)
  343. {
  344. struct od_dbs_tuners *od_tuners = dbs_data->tuners;
  345. unsigned int input;
  346. int ret;
  347. ret = sscanf(buf, "%u", &input);
  348. if (ret != 1)
  349. return -EINVAL;
  350. if (input > 1000)
  351. input = 1000;
  352. od_tuners->powersave_bias = input;
  353. ondemand_powersave_bias_init();
  354. return count;
  355. }
  356. show_store_one(od, sampling_rate);
  357. show_store_one(od, io_is_busy);
  358. show_store_one(od, up_threshold);
  359. show_store_one(od, sampling_down_factor);
  360. show_store_one(od, ignore_nice_load);
  361. show_store_one(od, powersave_bias);
  362. declare_show_sampling_rate_min(od);
  363. gov_sys_pol_attr_rw(sampling_rate);
  364. gov_sys_pol_attr_rw(io_is_busy);
  365. gov_sys_pol_attr_rw(up_threshold);
  366. gov_sys_pol_attr_rw(sampling_down_factor);
  367. gov_sys_pol_attr_rw(ignore_nice_load);
  368. gov_sys_pol_attr_rw(powersave_bias);
  369. gov_sys_pol_attr_ro(sampling_rate_min);
  370. static struct attribute *dbs_attributes_gov_sys[] = {
  371. &sampling_rate_min_gov_sys.attr,
  372. &sampling_rate_gov_sys.attr,
  373. &up_threshold_gov_sys.attr,
  374. &sampling_down_factor_gov_sys.attr,
  375. &ignore_nice_load_gov_sys.attr,
  376. &powersave_bias_gov_sys.attr,
  377. &io_is_busy_gov_sys.attr,
  378. NULL
  379. };
  380. static struct attribute_group od_attr_group_gov_sys = {
  381. .attrs = dbs_attributes_gov_sys,
  382. .name = "ondemand",
  383. };
  384. static struct attribute *dbs_attributes_gov_pol[] = {
  385. &sampling_rate_min_gov_pol.attr,
  386. &sampling_rate_gov_pol.attr,
  387. &up_threshold_gov_pol.attr,
  388. &sampling_down_factor_gov_pol.attr,
  389. &ignore_nice_load_gov_pol.attr,
  390. &powersave_bias_gov_pol.attr,
  391. &io_is_busy_gov_pol.attr,
  392. NULL
  393. };
  394. static struct attribute_group od_attr_group_gov_pol = {
  395. .attrs = dbs_attributes_gov_pol,
  396. .name = "ondemand",
  397. };
  398. /************************** sysfs end ************************/
  399. static int od_init(struct dbs_data *dbs_data, bool notify)
  400. {
  401. struct od_dbs_tuners *tuners;
  402. u64 idle_time;
  403. int cpu;
  404. tuners = kzalloc(sizeof(*tuners), GFP_KERNEL);
  405. if (!tuners) {
  406. pr_err("%s: kzalloc failed\n", __func__);
  407. return -ENOMEM;
  408. }
  409. cpu = get_cpu();
  410. idle_time = get_cpu_idle_time_us(cpu, NULL);
  411. put_cpu();
  412. if (idle_time != -1ULL) {
  413. /* Idle micro accounting is supported. Use finer thresholds */
  414. tuners->up_threshold = MICRO_FREQUENCY_UP_THRESHOLD;
  415. /*
  416. * In nohz/micro accounting case we set the minimum frequency
  417. * not depending on HZ, but fixed (very low). The deferred
  418. * timer might skip some samples if idle/sleeping as needed.
  419. */
  420. dbs_data->min_sampling_rate = MICRO_FREQUENCY_MIN_SAMPLE_RATE;
  421. } else {
  422. tuners->up_threshold = DEF_FREQUENCY_UP_THRESHOLD;
  423. /* For correct statistics, we need 10 ticks for each measure */
  424. dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
  425. jiffies_to_usecs(10);
  426. }
  427. tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR;
  428. tuners->ignore_nice_load = 0;
  429. tuners->powersave_bias = default_powersave_bias;
  430. tuners->io_is_busy = should_io_be_busy();
  431. dbs_data->tuners = tuners;
  432. return 0;
  433. }
  434. static void od_exit(struct dbs_data *dbs_data, bool notify)
  435. {
  436. kfree(dbs_data->tuners);
  437. }
  438. define_get_cpu_dbs_routines(od_cpu_dbs_info);
  439. static struct od_ops od_ops = {
  440. .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
  441. .powersave_bias_target = generic_powersave_bias_target,
  442. .freq_increase = dbs_freq_increase,
  443. };
  444. static struct common_dbs_data od_dbs_cdata = {
  445. .governor = GOV_ONDEMAND,
  446. .attr_group_gov_sys = &od_attr_group_gov_sys,
  447. .attr_group_gov_pol = &od_attr_group_gov_pol,
  448. .get_cpu_cdbs = get_cpu_cdbs,
  449. .get_cpu_dbs_info_s = get_cpu_dbs_info_s,
  450. .gov_dbs_timer = od_dbs_timer,
  451. .gov_check_cpu = od_check_cpu,
  452. .gov_ops = &od_ops,
  453. .init = od_init,
  454. .exit = od_exit,
  455. .mutex = __MUTEX_INITIALIZER(od_dbs_cdata.mutex),
  456. };
  457. static void od_set_powersave_bias(unsigned int powersave_bias)
  458. {
  459. struct cpufreq_policy *policy;
  460. struct dbs_data *dbs_data;
  461. struct od_dbs_tuners *od_tuners;
  462. unsigned int cpu;
  463. cpumask_t done;
  464. default_powersave_bias = powersave_bias;
  465. cpumask_clear(&done);
  466. get_online_cpus();
  467. for_each_online_cpu(cpu) {
  468. struct cpu_common_dbs_info *shared;
  469. if (cpumask_test_cpu(cpu, &done))
  470. continue;
  471. shared = per_cpu(od_cpu_dbs_info, cpu).cdbs.shared;
  472. if (!shared)
  473. continue;
  474. policy = shared->policy;
  475. cpumask_or(&done, &done, policy->cpus);
  476. if (policy->governor != &cpufreq_gov_ondemand)
  477. continue;
  478. dbs_data = policy->governor_data;
  479. od_tuners = dbs_data->tuners;
  480. od_tuners->powersave_bias = default_powersave_bias;
  481. }
  482. put_online_cpus();
  483. }
  484. void od_register_powersave_bias_handler(unsigned int (*f)
  485. (struct cpufreq_policy *, unsigned int, unsigned int),
  486. unsigned int powersave_bias)
  487. {
  488. od_ops.powersave_bias_target = f;
  489. od_set_powersave_bias(powersave_bias);
  490. }
  491. EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
  492. void od_unregister_powersave_bias_handler(void)
  493. {
  494. od_ops.powersave_bias_target = generic_powersave_bias_target;
  495. od_set_powersave_bias(0);
  496. }
  497. EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
  498. static int od_cpufreq_governor_dbs(struct cpufreq_policy *policy,
  499. unsigned int event)
  500. {
  501. return cpufreq_governor_dbs(policy, &od_dbs_cdata, event);
  502. }
  503. #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND
  504. static
  505. #endif
  506. struct cpufreq_governor cpufreq_gov_ondemand = {
  507. .name = "ondemand",
  508. .governor = od_cpufreq_governor_dbs,
  509. .max_transition_latency = TRANSITION_LATENCY_LIMIT,
  510. .owner = THIS_MODULE,
  511. };
  512. static int __init cpufreq_gov_dbs_init(void)
  513. {
  514. return cpufreq_register_governor(&cpufreq_gov_ondemand);
  515. }
  516. static void __exit cpufreq_gov_dbs_exit(void)
  517. {
  518. cpufreq_unregister_governor(&cpufreq_gov_ondemand);
  519. }
  520. MODULE_AUTHOR("Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>");
  521. MODULE_AUTHOR("Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>");
  522. MODULE_DESCRIPTION("'cpufreq_ondemand' - A dynamic cpufreq governor for "
  523. "Low Latency Frequency Transition capable processors");
  524. MODULE_LICENSE("GPL");
  525. #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND
  526. fs_initcall(cpufreq_gov_dbs_init);
  527. #else
  528. module_init(cpufreq_gov_dbs_init);
  529. #endif
  530. module_exit(cpufreq_gov_dbs_exit);