Lines Matching +full:switching +full:- +full:freq

1 // SPDX-License-Identifier: GPL-2.0-only
13 #include <linux/percpu-defs.h>
20 /* On-demand governor macros */
56 * Find right freq to be set now with powersave_bias on.
67 struct policy_dbs_info *policy_dbs = policy->governor_data; in generic_powersave_bias_target()
69 struct dbs_data *dbs_data = policy_dbs->dbs_data; in generic_powersave_bias_target()
70 struct od_dbs_tuners *od_tuners = dbs_data->tuners; in generic_powersave_bias_target()
71 struct cpufreq_frequency_table *freq_table = policy->freq_table; in generic_powersave_bias_target()
74 dbs_info->freq_lo = 0; in generic_powersave_bias_target()
75 dbs_info->freq_lo_delay_us = 0; in generic_powersave_bias_target()
81 freq_reduc = freq_req * od_tuners->powersave_bias / 1000; in generic_powersave_bias_target()
82 freq_avg = freq_req - freq_reduc; in generic_powersave_bias_target()
84 /* Find freq bounds for freq_avg in freq_table */ in generic_powersave_bias_target()
94 dbs_info->freq_lo = 0; in generic_powersave_bias_target()
95 dbs_info->freq_lo_delay_us = 0; in generic_powersave_bias_target()
98 delay_hi_us = (freq_avg - freq_lo) * dbs_data->sampling_rate; in generic_powersave_bias_target()
99 delay_hi_us += (freq_hi - freq_lo) / 2; in generic_powersave_bias_target()
100 delay_hi_us /= freq_hi - freq_lo; in generic_powersave_bias_target()
101 dbs_info->freq_hi_delay_us = delay_hi_us; in generic_powersave_bias_target()
102 dbs_info->freq_lo = freq_lo; in generic_powersave_bias_target()
103 dbs_info->freq_lo_delay_us = dbs_data->sampling_rate - delay_hi_us; in generic_powersave_bias_target()
109 struct od_policy_dbs_info *dbs_info = to_dbs_info(policy->governor_data); in ondemand_powersave_bias_init()
111 dbs_info->freq_lo = 0; in ondemand_powersave_bias_init()
114 static void dbs_freq_increase(struct cpufreq_policy *policy, unsigned int freq) in dbs_freq_increase() argument
116 struct policy_dbs_info *policy_dbs = policy->governor_data; in dbs_freq_increase()
117 struct dbs_data *dbs_data = policy_dbs->dbs_data; in dbs_freq_increase()
118 struct od_dbs_tuners *od_tuners = dbs_data->tuners; in dbs_freq_increase()
120 if (od_tuners->powersave_bias) in dbs_freq_increase()
121 freq = od_ops.powersave_bias_target(policy, freq, in dbs_freq_increase()
123 else if (policy->cur == policy->max) in dbs_freq_increase()
126 __cpufreq_driver_target(policy, freq, od_tuners->powersave_bias ? in dbs_freq_increase()
137 struct policy_dbs_info *policy_dbs = policy->governor_data; in od_update()
139 struct dbs_data *dbs_data = policy_dbs->dbs_data; in od_update()
140 struct od_dbs_tuners *od_tuners = dbs_data->tuners; in od_update()
143 dbs_info->freq_lo = 0; in od_update()
146 if (load > dbs_data->up_threshold) { in od_update()
147 /* If switching to max speed, apply sampling_down_factor */ in od_update()
148 if (policy->cur < policy->max) in od_update()
149 policy_dbs->rate_mult = dbs_data->sampling_down_factor; in od_update()
150 dbs_freq_increase(policy, policy->max); in od_update()
155 min_f = policy->cpuinfo.min_freq; in od_update()
156 max_f = policy->cpuinfo.max_freq; in od_update()
157 freq_next = min_f + load * (max_f - min_f) / 100; in od_update()
160 policy_dbs->rate_mult = 1; in od_update()
162 if (od_tuners->powersave_bias) in od_update()
173 struct policy_dbs_info *policy_dbs = policy->governor_data; in od_dbs_update()
174 struct dbs_data *dbs_data = policy_dbs->dbs_data; in od_dbs_update()
176 int sample_type = dbs_info->sample_type; in od_dbs_update()
179 dbs_info->sample_type = OD_NORMAL_SAMPLE; in od_dbs_update()
184 if (sample_type == OD_SUB_SAMPLE && policy_dbs->sample_delay_ns > 0) { in od_dbs_update()
185 __cpufreq_driver_target(policy, dbs_info->freq_lo, in od_dbs_update()
187 return dbs_info->freq_lo_delay_us; in od_dbs_update()
192 if (dbs_info->freq_lo) { in od_dbs_update()
194 dbs_info->sample_type = OD_SUB_SAMPLE; in od_dbs_update()
195 return dbs_info->freq_hi_delay_us; in od_dbs_update()
198 return dbs_data->sampling_rate * policy_dbs->rate_mult; in od_dbs_update()
213 return -EINVAL; in io_is_busy_store()
214 dbs_data->io_is_busy = !!input; in io_is_busy_store()
216 /* we need to re-evaluate prev_cpu_idle */ in io_is_busy_store()
232 return -EINVAL; in up_threshold_store()
235 dbs_data->up_threshold = input; in up_threshold_store()
249 return -EINVAL; in sampling_down_factor_store()
251 dbs_data->sampling_down_factor = input; in sampling_down_factor_store()
254 list_for_each_entry(policy_dbs, &attr_set->policy_list, list) { in sampling_down_factor_store()
259 mutex_lock(&policy_dbs->update_mutex); in sampling_down_factor_store()
260 policy_dbs->rate_mult = 1; in sampling_down_factor_store()
261 mutex_unlock(&policy_dbs->update_mutex); in sampling_down_factor_store()
276 return -EINVAL; in ignore_nice_load_store()
281 if (input == dbs_data->ignore_nice_load) { /* nothing to do */ in ignore_nice_load_store()
284 dbs_data->ignore_nice_load = input; in ignore_nice_load_store()
286 /* we need to re-evaluate prev_cpu_idle */ in ignore_nice_load_store()
296 struct od_dbs_tuners *od_tuners = dbs_data->tuners; in powersave_bias_store()
303 return -EINVAL; in powersave_bias_store()
308 od_tuners->powersave_bias = input; in powersave_bias_store()
310 list_for_each_entry(policy_dbs, &attr_set->policy_list, list) in powersave_bias_store()
311 ondemand_powersave_bias_init(policy_dbs->policy); in powersave_bias_store()
348 return dbs_info ? &dbs_info->policy_dbs : NULL; in od_alloc()
364 return -ENOMEM; in od_init()
369 if (idle_time != -1ULL) { in od_init()
371 dbs_data->up_threshold = MICRO_FREQUENCY_UP_THRESHOLD; in od_init()
373 dbs_data->up_threshold = DEF_FREQUENCY_UP_THRESHOLD; in od_init()
376 dbs_data->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR; in od_init()
377 dbs_data->ignore_nice_load = 0; in od_init()
378 tuners->powersave_bias = default_powersave_bias; in od_init()
379 dbs_data->io_is_busy = should_io_be_busy(); in od_init()
381 dbs_data->tuners = tuners; in od_init()
387 kfree(dbs_data->tuners); in od_exit()
392 struct od_policy_dbs_info *dbs_info = to_dbs_info(policy->governor_data); in od_start()
394 dbs_info->sample_type = OD_NORMAL_SAMPLE; in od_start()
437 if (!policy || policy->governor != &CPU_FREQ_GOV_ONDEMAND) in od_set_powersave_bias()
440 policy_dbs = policy->governor_data; in od_set_powersave_bias()
444 cpumask_or(done, done, policy->cpus); in od_set_powersave_bias()
446 dbs_data = policy_dbs->dbs_data; in od_set_powersave_bias()
447 od_tuners = dbs_data->tuners; in od_set_powersave_bias()
448 od_tuners->powersave_bias = default_powersave_bias; in od_set_powersave_bias()
473 MODULE_DESCRIPTION("'cpufreq_ondemand' - A dynamic cpufreq governor for "