Lines Matching full:policy
83 static unsigned int __cpufreq_get(struct cpufreq_policy *policy);
84 static int cpufreq_init_governor(struct cpufreq_policy *policy);
85 static void cpufreq_exit_governor(struct cpufreq_policy *policy);
86 static void cpufreq_governor_limits(struct cpufreq_policy *policy);
87 static int cpufreq_set_policy(struct cpufreq_policy *policy,
94 * Two notifier lists: the "policy" list is involved in the
95 * validation process for a new CPU frequency policy; the
122 struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy) in get_governor_parent_kobj() argument
125 return &policy->kobj; in get_governor_parent_kobj()
174 * - policy->cpus with all possible CPUs
176 void cpufreq_generic_init(struct cpufreq_policy *policy, in cpufreq_generic_init() argument
180 policy->freq_table = table; in cpufreq_generic_init()
181 policy->cpuinfo.transition_latency = transition_latency; in cpufreq_generic_init()
187 cpumask_setall(policy->cpus); in cpufreq_generic_init()
193 struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); in cpufreq_cpu_get_raw() local
195 return policy && cpumask_test_cpu(cpu, policy->cpus) ? policy : NULL; in cpufreq_cpu_get_raw()
201 struct cpufreq_policy *policy = cpufreq_cpu_get_raw(cpu); in cpufreq_generic_get() local
203 if (!policy || IS_ERR(policy->clk)) { in cpufreq_generic_get()
205 __func__, policy ? "clk" : "policy", cpu); in cpufreq_generic_get()
209 return clk_get_rate(policy->clk) / 1000; in cpufreq_generic_get()
214 * cpufreq_cpu_get - Return policy for a CPU and mark it as busy.
215 * @cpu: CPU to find the policy for.
217 * Call cpufreq_cpu_get_raw() to obtain a cpufreq policy for @cpu and increment
218 * the kobject reference counter of that policy. Return a valid policy on
221 * The policy returned by this function has to be released with the help of
226 struct cpufreq_policy *policy = NULL; in cpufreq_cpu_get() local
237 policy = cpufreq_cpu_get_raw(cpu); in cpufreq_cpu_get()
238 if (policy) in cpufreq_cpu_get()
239 kobject_get(&policy->kobj); in cpufreq_cpu_get()
244 return policy; in cpufreq_cpu_get()
249 * cpufreq_cpu_put - Decrement kobject usage counter for cpufreq policy.
250 * @policy: cpufreq policy returned by cpufreq_cpu_get().
252 void cpufreq_cpu_put(struct cpufreq_policy *policy) in cpufreq_cpu_put() argument
254 kobject_put(&policy->kobj); in cpufreq_cpu_put()
259 * cpufreq_cpu_release - Unlock a policy and decrement its usage counter.
260 * @policy: cpufreq policy returned by cpufreq_cpu_acquire().
262 void cpufreq_cpu_release(struct cpufreq_policy *policy) in cpufreq_cpu_release() argument
264 if (WARN_ON(!policy)) in cpufreq_cpu_release()
267 lockdep_assert_held(&policy->rwsem); in cpufreq_cpu_release()
269 up_write(&policy->rwsem); in cpufreq_cpu_release()
271 cpufreq_cpu_put(policy); in cpufreq_cpu_release()
275 * cpufreq_cpu_acquire - Find policy for a CPU, mark it as busy and lock it.
276 * @cpu: CPU to find the policy for.
278 * Call cpufreq_cpu_get() to get a reference on the cpufreq policy for @cpu and
279 * if the policy returned by it is not NULL, acquire its rwsem for writing.
280 * Return the policy if it is active or release it and return NULL otherwise.
282 * The policy returned by this function has to be released with the help of
288 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); in cpufreq_cpu_acquire() local
290 if (!policy) in cpufreq_cpu_acquire()
293 down_write(&policy->rwsem); in cpufreq_cpu_acquire()
295 if (policy_is_inactive(policy)) { in cpufreq_cpu_acquire()
296 cpufreq_cpu_release(policy); in cpufreq_cpu_acquire()
300 return policy; in cpufreq_cpu_acquire()
343 * @policy: cpufreq policy to enable fast frequency switching for.
351 static void cpufreq_notify_transition(struct cpufreq_policy *policy, in cpufreq_notify_transition() argument
362 freqs->policy = policy; in cpufreq_notify_transition()
374 if (policy->cur && policy->cur != freqs->old) { in cpufreq_notify_transition()
376 freqs->old, policy->cur); in cpufreq_notify_transition()
377 freqs->old = policy->cur; in cpufreq_notify_transition()
389 cpumask_pr_args(policy->cpus)); in cpufreq_notify_transition()
391 for_each_cpu(cpu, policy->cpus) in cpufreq_notify_transition()
397 cpufreq_stats_record_transition(policy, freqs->new); in cpufreq_notify_transition()
398 policy->cur = freqs->new; in cpufreq_notify_transition()
403 static void cpufreq_notify_post_transition(struct cpufreq_policy *policy, in cpufreq_notify_post_transition() argument
406 cpufreq_notify_transition(policy, freqs, CPUFREQ_POSTCHANGE); in cpufreq_notify_post_transition()
411 cpufreq_notify_transition(policy, freqs, CPUFREQ_PRECHANGE); in cpufreq_notify_post_transition()
412 cpufreq_notify_transition(policy, freqs, CPUFREQ_POSTCHANGE); in cpufreq_notify_post_transition()
415 void cpufreq_freq_transition_begin(struct cpufreq_policy *policy, in cpufreq_freq_transition_begin() argument
428 && current == policy->transition_task); in cpufreq_freq_transition_begin()
431 wait_event(policy->transition_wait, !policy->transition_ongoing); in cpufreq_freq_transition_begin()
433 spin_lock(&policy->transition_lock); in cpufreq_freq_transition_begin()
435 if (unlikely(policy->transition_ongoing)) { in cpufreq_freq_transition_begin()
436 spin_unlock(&policy->transition_lock); in cpufreq_freq_transition_begin()
440 policy->transition_ongoing = true; in cpufreq_freq_transition_begin()
441 policy->transition_task = current; in cpufreq_freq_transition_begin()
443 spin_unlock(&policy->transition_lock); in cpufreq_freq_transition_begin()
445 cpufreq_notify_transition(policy, freqs, CPUFREQ_PRECHANGE); in cpufreq_freq_transition_begin()
449 void cpufreq_freq_transition_end(struct cpufreq_policy *policy, in cpufreq_freq_transition_end() argument
452 if (WARN_ON(!policy->transition_ongoing)) in cpufreq_freq_transition_end()
455 cpufreq_notify_post_transition(policy, freqs, transition_failed); in cpufreq_freq_transition_end()
457 arch_set_freq_scale(policy->related_cpus, in cpufreq_freq_transition_end()
458 policy->cur, in cpufreq_freq_transition_end()
459 arch_scale_freq_ref(policy->cpu)); in cpufreq_freq_transition_end()
461 spin_lock(&policy->transition_lock); in cpufreq_freq_transition_end()
462 policy->transition_ongoing = false; in cpufreq_freq_transition_end()
463 policy->transition_task = NULL; in cpufreq_freq_transition_end()
464 spin_unlock(&policy->transition_lock); in cpufreq_freq_transition_end()
466 wake_up(&policy->transition_wait); in cpufreq_freq_transition_end()
492 * cpufreq_enable_fast_switch - Enable fast frequency switching for policy.
493 * @policy: cpufreq policy to enable fast frequency switching for.
495 * Try to enable fast frequency switching for @policy.
502 void cpufreq_enable_fast_switch(struct cpufreq_policy *policy) in cpufreq_enable_fast_switch() argument
504 lockdep_assert_held(&policy->rwsem); in cpufreq_enable_fast_switch()
506 if (!policy->fast_switch_possible) in cpufreq_enable_fast_switch()
512 policy->fast_switch_enabled = true; in cpufreq_enable_fast_switch()
515 policy->cpu); in cpufreq_enable_fast_switch()
523 * cpufreq_disable_fast_switch - Disable fast frequency switching for policy.
524 * @policy: cpufreq policy to disable fast frequency switching for.
526 void cpufreq_disable_fast_switch(struct cpufreq_policy *policy) in cpufreq_disable_fast_switch() argument
529 if (policy->fast_switch_enabled) { in cpufreq_disable_fast_switch()
530 policy->fast_switch_enabled = false; in cpufreq_disable_fast_switch()
538 static unsigned int __resolve_freq(struct cpufreq_policy *policy, in __resolve_freq() argument
547 if (!policy->freq_table) in __resolve_freq()
550 idx = cpufreq_frequency_table_target(policy, target_freq, min, max, relation); in __resolve_freq()
551 policy->cached_resolved_idx = idx; in __resolve_freq()
552 policy->cached_target_freq = target_freq; in __resolve_freq()
553 return policy->freq_table[idx].frequency; in __resolve_freq()
559 * @policy: associated policy to interrogate
562 * The target to driver frequency mapping is cached in the policy.
565 * given target_freq, subject to policy (min/max) and driver limitations.
567 unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy, in cpufreq_driver_resolve_freq() argument
570 unsigned int min = READ_ONCE(policy->min); in cpufreq_driver_resolve_freq()
571 unsigned int max = READ_ONCE(policy->max); in cpufreq_driver_resolve_freq()
575 * read policy->min before the update and policy->max after the update in cpufreq_driver_resolve_freq()
584 return __resolve_freq(policy, target_freq, min, max, CPUFREQ_RELATION_LE); in cpufreq_driver_resolve_freq()
588 unsigned int cpufreq_policy_transition_delay_us(struct cpufreq_policy *policy) in cpufreq_policy_transition_delay_us() argument
592 if (policy->transition_delay_us) in cpufreq_policy_transition_delay_us()
593 return policy->transition_delay_us; in cpufreq_policy_transition_delay_us()
595 latency = policy->cpuinfo.transition_latency / NSEC_PER_USEC; in cpufreq_policy_transition_delay_us()
634 static ssize_t show_local_boost(struct cpufreq_policy *policy, char *buf) in show_local_boost() argument
636 return sysfs_emit(buf, "%d\n", policy->boost_enabled); in show_local_boost()
639 static ssize_t store_local_boost(struct cpufreq_policy *policy, in store_local_boost() argument
651 if (!policy->boost_supported) in store_local_boost()
654 if (policy->boost_enabled == enable) in store_local_boost()
657 policy->boost_enabled = enable; in store_local_boost()
660 ret = cpufreq_driver->set_boost(policy, enable); in store_local_boost()
664 policy->boost_enabled = !policy->boost_enabled; in store_local_boost()
735 * Write out information from cpufreq_driver->policy[cpu]; object must be
741 (struct cpufreq_policy *policy, char *buf) \
743 return sysfs_emit(buf, "%u\n", policy->object); \
757 static inline bool cpufreq_avg_freq_supported(struct cpufreq_policy *policy) in cpufreq_avg_freq_supported() argument
759 return arch_freq_get_on_cpu(policy->cpu) != -EOPNOTSUPP; in cpufreq_avg_freq_supported()
762 static ssize_t show_scaling_cur_freq(struct cpufreq_policy *policy, char *buf) in show_scaling_cur_freq() argument
768 ? arch_freq_get_on_cpu(policy->cpu) in show_scaling_cur_freq()
774 ret = sysfs_emit(buf, "%u\n", cpufreq_driver->get(policy->cpu)); in show_scaling_cur_freq()
776 ret = sysfs_emit(buf, "%u\n", policy->cur); in show_scaling_cur_freq()
785 (struct cpufreq_policy *policy, const char *buf, size_t count) \
794 ret = freq_qos_update_request(policy->object##_freq_req, val);\
804 static ssize_t show_cpuinfo_cur_freq(struct cpufreq_policy *policy, in show_cpuinfo_cur_freq() argument
807 unsigned int cur_freq = __cpufreq_get(policy); in show_cpuinfo_cur_freq()
818 static ssize_t show_cpuinfo_avg_freq(struct cpufreq_policy *policy, in show_cpuinfo_avg_freq() argument
821 int avg_freq = arch_freq_get_on_cpu(policy->cpu); in show_cpuinfo_avg_freq()
829 * show_scaling_governor - show the current policy for the specified CPU
831 static ssize_t show_scaling_governor(struct cpufreq_policy *policy, char *buf) in show_scaling_governor() argument
833 if (policy->policy == CPUFREQ_POLICY_POWERSAVE) in show_scaling_governor()
835 else if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) in show_scaling_governor()
837 else if (policy->governor) in show_scaling_governor()
838 return sysfs_emit(buf, "%s\n", policy->governor->name); in show_scaling_governor()
843 * store_scaling_governor - store policy for the specified CPU
845 static ssize_t store_scaling_governor(struct cpufreq_policy *policy, in store_scaling_governor() argument
862 ret = cpufreq_set_policy(policy, NULL, new_pol); in store_scaling_governor()
870 ret = cpufreq_set_policy(policy, new_gov, in store_scaling_governor()
882 static ssize_t show_scaling_driver(struct cpufreq_policy *policy, char *buf) in show_scaling_driver() argument
890 static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy, in show_scaling_available_governors() argument
937 static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf) in show_related_cpus() argument
939 return cpufreq_show_cpus(policy->related_cpus, buf); in show_related_cpus()
945 static ssize_t show_affected_cpus(struct cpufreq_policy *policy, char *buf) in show_affected_cpus() argument
947 return cpufreq_show_cpus(policy->cpus, buf); in show_affected_cpus()
950 static ssize_t store_scaling_setspeed(struct cpufreq_policy *policy, in store_scaling_setspeed() argument
956 if (!policy->governor || !policy->governor->store_setspeed) in store_scaling_setspeed()
963 policy->governor->store_setspeed(policy, freq); in store_scaling_setspeed()
968 static ssize_t show_scaling_setspeed(struct cpufreq_policy *policy, char *buf) in show_scaling_setspeed() argument
970 if (!policy->governor || !policy->governor->show_setspeed) in show_scaling_setspeed()
973 return policy->governor->show_setspeed(policy, buf); in show_scaling_setspeed()
979 static ssize_t show_bios_limit(struct cpufreq_policy *policy, char *buf) in show_bios_limit() argument
983 ret = cpufreq_driver->bios_limit(policy->cpu, &limit); in show_bios_limit()
986 return sysfs_emit(buf, "%u\n", policy->cpuinfo.max_freq); in show_bios_limit()
1026 struct cpufreq_policy *policy = to_policy(kobj); in show() local
1033 down_read(&policy->rwsem); in show()
1034 if (likely(!policy_is_inactive(policy))) in show()
1035 ret = fattr->show(policy, buf); in show()
1036 up_read(&policy->rwsem); in show()
1044 struct cpufreq_policy *policy = to_policy(kobj); in store() local
1051 down_write(&policy->rwsem); in store()
1052 if (likely(!policy_is_inactive(policy))) in store()
1053 ret = fattr->store(policy, buf, count); in store()
1054 up_write(&policy->rwsem); in store()
1061 struct cpufreq_policy *policy = to_policy(kobj); in cpufreq_sysfs_release() local
1063 complete(&policy->kobj_unregister); in cpufreq_sysfs_release()
1077 static void add_cpu_dev_symlink(struct cpufreq_policy *policy, unsigned int cpu, in add_cpu_dev_symlink() argument
1083 if (cpumask_test_and_set_cpu(cpu, policy->real_cpus)) in add_cpu_dev_symlink()
1087 if (sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq")) in add_cpu_dev_symlink()
1091 static void remove_cpu_dev_symlink(struct cpufreq_policy *policy, int cpu, in remove_cpu_dev_symlink() argument
1096 cpumask_clear_cpu(cpu, policy->real_cpus); in remove_cpu_dev_symlink()
1099 static int cpufreq_add_dev_interface(struct cpufreq_policy *policy) in cpufreq_add_dev_interface() argument
1105 if (policy->freq_table) { in cpufreq_add_dev_interface()
1106 ret = sysfs_create_file(&policy->kobj, in cpufreq_add_dev_interface()
1112 ret = sysfs_create_file(&policy->kobj, in cpufreq_add_dev_interface()
1122 ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr)); in cpufreq_add_dev_interface()
1128 ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr); in cpufreq_add_dev_interface()
1133 if (cpufreq_avg_freq_supported(policy)) { in cpufreq_add_dev_interface()
1134 ret = sysfs_create_file(&policy->kobj, &cpuinfo_avg_freq.attr); in cpufreq_add_dev_interface()
1139 ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); in cpufreq_add_dev_interface()
1144 ret = sysfs_create_file(&policy->kobj, &bios_limit.attr); in cpufreq_add_dev_interface()
1150 ret = sysfs_create_file(&policy->kobj, &local_boost.attr); in cpufreq_add_dev_interface()
1158 static int cpufreq_init_policy(struct cpufreq_policy *policy) in cpufreq_init_policy() argument
1165 /* Update policy governor to the one used before hotplug. */ in cpufreq_init_policy()
1166 gov = get_governor(policy->last_governor); in cpufreq_init_policy()
1169 gov->name, policy->cpu); in cpufreq_init_policy()
1181 /* Use the default policy if there is no last_policy. */ in cpufreq_init_policy()
1182 if (policy->last_policy) { in cpufreq_init_policy()
1183 pol = policy->last_policy; in cpufreq_init_policy()
1188 * nor "powersave", fall back to the initial policy in cpufreq_init_policy()
1192 pol = policy->policy; in cpufreq_init_policy()
1199 ret = cpufreq_set_policy(policy, gov, pol); in cpufreq_init_policy()
1206 static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu) in cpufreq_add_policy_cpu() argument
1211 if (cpumask_test_cpu(cpu, policy->cpus)) in cpufreq_add_policy_cpu()
1214 down_write(&policy->rwsem); in cpufreq_add_policy_cpu()
1216 cpufreq_stop_governor(policy); in cpufreq_add_policy_cpu()
1218 cpumask_set_cpu(cpu, policy->cpus); in cpufreq_add_policy_cpu()
1221 ret = cpufreq_start_governor(policy); in cpufreq_add_policy_cpu()
1225 up_write(&policy->rwsem); in cpufreq_add_policy_cpu()
1229 void refresh_frequency_limits(struct cpufreq_policy *policy) in refresh_frequency_limits() argument
1231 if (!policy_is_inactive(policy)) { in refresh_frequency_limits()
1232 pr_debug("updating policy for CPU %u\n", policy->cpu); in refresh_frequency_limits()
1234 cpufreq_set_policy(policy, policy->governor, policy->policy); in refresh_frequency_limits()
1241 struct cpufreq_policy *policy = in handle_update() local
1244 pr_debug("handle_update for cpu %u called\n", policy->cpu); in handle_update()
1245 down_write(&policy->rwsem); in handle_update()
1246 refresh_frequency_limits(policy); in handle_update()
1247 up_write(&policy->rwsem); in handle_update()
1253 struct cpufreq_policy *policy = container_of(nb, struct cpufreq_policy, nb_min); in cpufreq_notifier_min() local
1255 schedule_work(&policy->update); in cpufreq_notifier_min()
1262 struct cpufreq_policy *policy = container_of(nb, struct cpufreq_policy, nb_max); in cpufreq_notifier_max() local
1264 schedule_work(&policy->update); in cpufreq_notifier_max()
1268 static void cpufreq_policy_put_kobj(struct cpufreq_policy *policy) in cpufreq_policy_put_kobj() argument
1273 down_write(&policy->rwsem); in cpufreq_policy_put_kobj()
1274 cpufreq_stats_free_table(policy); in cpufreq_policy_put_kobj()
1275 kobj = &policy->kobj; in cpufreq_policy_put_kobj()
1276 cmp = &policy->kobj_unregister; in cpufreq_policy_put_kobj()
1277 up_write(&policy->rwsem); in cpufreq_policy_put_kobj()
1292 struct cpufreq_policy *policy; in cpufreq_policy_alloc() local
1299 policy = kzalloc(sizeof(*policy), GFP_KERNEL); in cpufreq_policy_alloc()
1300 if (!policy) in cpufreq_policy_alloc()
1303 if (!alloc_cpumask_var(&policy->cpus, GFP_KERNEL)) in cpufreq_policy_alloc()
1306 if (!zalloc_cpumask_var(&policy->related_cpus, GFP_KERNEL)) in cpufreq_policy_alloc()
1309 if (!zalloc_cpumask_var(&policy->real_cpus, GFP_KERNEL)) in cpufreq_policy_alloc()
1312 init_completion(&policy->kobj_unregister); in cpufreq_policy_alloc()
1313 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, in cpufreq_policy_alloc()
1314 cpufreq_global_kobject, "policy%u", cpu); in cpufreq_policy_alloc()
1316 dev_err(dev, "%s: failed to init policy->kobj: %d\n", __func__, ret); in cpufreq_policy_alloc()
1318 * The entire policy object will be freed below, but the extra in cpufreq_policy_alloc()
1322 kobject_put(&policy->kobj); in cpufreq_policy_alloc()
1326 freq_constraints_init(&policy->constraints); in cpufreq_policy_alloc()
1328 policy->nb_min.notifier_call = cpufreq_notifier_min; in cpufreq_policy_alloc()
1329 policy->nb_max.notifier_call = cpufreq_notifier_max; in cpufreq_policy_alloc()
1331 ret = freq_qos_add_notifier(&policy->constraints, FREQ_QOS_MIN, in cpufreq_policy_alloc()
1332 &policy->nb_min); in cpufreq_policy_alloc()
1339 ret = freq_qos_add_notifier(&policy->constraints, FREQ_QOS_MAX, in cpufreq_policy_alloc()
1340 &policy->nb_max); in cpufreq_policy_alloc()
1347 INIT_LIST_HEAD(&policy->policy_list); in cpufreq_policy_alloc()
1348 init_rwsem(&policy->rwsem); in cpufreq_policy_alloc()
1349 spin_lock_init(&policy->transition_lock); in cpufreq_policy_alloc()
1350 init_waitqueue_head(&policy->transition_wait); in cpufreq_policy_alloc()
1351 INIT_WORK(&policy->update, handle_update); in cpufreq_policy_alloc()
1353 policy->cpu = cpu; in cpufreq_policy_alloc()
1354 return policy; in cpufreq_policy_alloc()
1357 freq_qos_remove_notifier(&policy->constraints, FREQ_QOS_MIN, in cpufreq_policy_alloc()
1358 &policy->nb_min); in cpufreq_policy_alloc()
1360 cpufreq_policy_put_kobj(policy); in cpufreq_policy_alloc()
1362 free_cpumask_var(policy->real_cpus); in cpufreq_policy_alloc()
1364 free_cpumask_var(policy->related_cpus); in cpufreq_policy_alloc()
1366 free_cpumask_var(policy->cpus); in cpufreq_policy_alloc()
1368 kfree(policy); in cpufreq_policy_alloc()
1373 static void cpufreq_policy_free(struct cpufreq_policy *policy) in cpufreq_policy_free() argument
1379 * The callers must ensure the policy is inactive by now, to avoid any in cpufreq_policy_free()
1382 if (unlikely(!policy_is_inactive(policy))) in cpufreq_policy_free()
1383 pr_warn("%s: Freeing active policy\n", __func__); in cpufreq_policy_free()
1385 /* Remove policy from list */ in cpufreq_policy_free()
1387 list_del(&policy->policy_list); in cpufreq_policy_free()
1389 for_each_cpu(cpu, policy->related_cpus) in cpufreq_policy_free()
1393 freq_qos_remove_notifier(&policy->constraints, FREQ_QOS_MAX, in cpufreq_policy_free()
1394 &policy->nb_max); in cpufreq_policy_free()
1395 freq_qos_remove_notifier(&policy->constraints, FREQ_QOS_MIN, in cpufreq_policy_free()
1396 &policy->nb_min); in cpufreq_policy_free()
1398 /* Cancel any pending policy->update work before freeing the policy. */ in cpufreq_policy_free()
1399 cancel_work_sync(&policy->update); in cpufreq_policy_free()
1401 if (policy->max_freq_req) { in cpufreq_policy_free()
1408 CPUFREQ_REMOVE_POLICY, policy); in cpufreq_policy_free()
1409 freq_qos_remove_request(policy->max_freq_req); in cpufreq_policy_free()
1412 freq_qos_remove_request(policy->min_freq_req); in cpufreq_policy_free()
1413 kfree(policy->min_freq_req); in cpufreq_policy_free()
1415 cpufreq_policy_put_kobj(policy); in cpufreq_policy_free()
1416 free_cpumask_var(policy->real_cpus); in cpufreq_policy_free()
1417 free_cpumask_var(policy->related_cpus); in cpufreq_policy_free()
1418 free_cpumask_var(policy->cpus); in cpufreq_policy_free()
1419 kfree(policy); in cpufreq_policy_free()
1424 struct cpufreq_policy *policy; in cpufreq_online() local
1432 /* Check if this CPU already has a policy to manage it */ in cpufreq_online()
1433 policy = per_cpu(cpufreq_cpu_data, cpu); in cpufreq_online()
1434 if (policy) { in cpufreq_online()
1435 WARN_ON(!cpumask_test_cpu(cpu, policy->related_cpus)); in cpufreq_online()
1436 if (!policy_is_inactive(policy)) in cpufreq_online()
1437 return cpufreq_add_policy_cpu(policy, cpu); in cpufreq_online()
1439 /* This is the only online CPU for the policy. Start over. */ in cpufreq_online()
1441 down_write(&policy->rwsem); in cpufreq_online()
1442 policy->cpu = cpu; in cpufreq_online()
1443 policy->governor = NULL; in cpufreq_online()
1446 policy = cpufreq_policy_alloc(cpu); in cpufreq_online()
1447 if (!policy) in cpufreq_online()
1449 down_write(&policy->rwsem); in cpufreq_online()
1453 /* Recover policy->cpus using related_cpus */ in cpufreq_online()
1454 cpumask_copy(policy->cpus, policy->related_cpus); in cpufreq_online()
1456 ret = cpufreq_driver->online(policy); in cpufreq_online()
1463 cpumask_copy(policy->cpus, cpumask_of(cpu)); in cpufreq_online()
1469 ret = cpufreq_driver->init(policy); in cpufreq_online()
1477 * The initialization has succeeded and the policy is online. in cpufreq_online()
1481 ret = cpufreq_table_validate_and_sort(policy); in cpufreq_online()
1485 /* related_cpus should at least include policy->cpus. */ in cpufreq_online()
1486 cpumask_copy(policy->related_cpus, policy->cpus); in cpufreq_online()
1493 cpumask_and(policy->cpus, policy->cpus, cpu_online_mask); in cpufreq_online()
1496 for_each_cpu(j, policy->related_cpus) { in cpufreq_online()
1497 per_cpu(cpufreq_cpu_data, j) = policy; in cpufreq_online()
1498 add_cpu_dev_symlink(policy, j, get_cpu_device(j)); in cpufreq_online()
1501 policy->min_freq_req = kzalloc(2 * sizeof(*policy->min_freq_req), in cpufreq_online()
1503 if (!policy->min_freq_req) { in cpufreq_online()
1508 ret = freq_qos_add_request(&policy->constraints, in cpufreq_online()
1509 policy->min_freq_req, FREQ_QOS_MIN, in cpufreq_online()
1516 kfree(policy->min_freq_req); in cpufreq_online()
1517 policy->min_freq_req = NULL; in cpufreq_online()
1526 policy->max_freq_req = policy->min_freq_req + 1; in cpufreq_online()
1528 ret = freq_qos_add_request(&policy->constraints, in cpufreq_online()
1529 policy->max_freq_req, FREQ_QOS_MAX, in cpufreq_online()
1532 policy->max_freq_req = NULL; in cpufreq_online()
1537 CPUFREQ_CREATE_POLICY, policy); in cpufreq_online()
1539 ret = freq_qos_update_request(policy->max_freq_req, policy->max); in cpufreq_online()
1545 policy->cur = cpufreq_driver->get(policy->cpu); in cpufreq_online()
1546 if (!policy->cur) { in cpufreq_online()
1563 * for the next freq which is >= policy->cur ('cur' must be set by now, in cpufreq_online()
1567 * We are passing target-freq as "policy->cur - 1" otherwise in cpufreq_online()
1568 * __cpufreq_driver_target() would simply fail, as policy->cur will be in cpufreq_online()
1573 unsigned int old_freq = policy->cur; in cpufreq_online()
1576 ret = cpufreq_frequency_table_get_index(policy, old_freq); in cpufreq_online()
1578 ret = __cpufreq_driver_target(policy, old_freq - 1, in cpufreq_online()
1588 __func__, policy->cpu, old_freq, policy->cur); in cpufreq_online()
1593 ret = cpufreq_add_dev_interface(policy); in cpufreq_online()
1597 cpufreq_stats_create_table(policy); in cpufreq_online()
1600 list_add(&policy->policy_list, &cpufreq_policy_list); in cpufreq_online()
1607 * once the energy model is properly initialized for the policy in cpufreq_online()
1610 * Also, this should be called before the policy is registered in cpufreq_online()
1614 cpufreq_driver->register_em(policy); in cpufreq_online()
1617 ret = cpufreq_init_policy(policy); in cpufreq_online()
1619 pr_err("%s: Failed to initialize policy for cpu: %d (%d)\n", in cpufreq_online()
1624 up_write(&policy->rwsem); in cpufreq_online()
1626 kobject_uevent(&policy->kobj, KOBJ_ADD); in cpufreq_online()
1628 /* Callback for handling stuff after policy is ready */ in cpufreq_online()
1630 cpufreq_driver->ready(policy); in cpufreq_online()
1632 /* Register cpufreq cooling only for a new policy */ in cpufreq_online()
1634 policy->cdev = of_cpufreq_cooling_register(policy); in cpufreq_online()
1636 /* Let the per-policy boost flag mirror the cpufreq_driver boost during init */ in cpufreq_online()
1637 if (cpufreq_driver->set_boost && policy->boost_supported && in cpufreq_online()
1638 policy->boost_enabled != cpufreq_boost_enabled()) { in cpufreq_online()
1639 policy->boost_enabled = cpufreq_boost_enabled(); in cpufreq_online()
1640 ret = cpufreq_driver->set_boost(policy, policy->boost_enabled); in cpufreq_online()
1643 pr_info("%s: CPU%d: Cannot %s BOOST\n", __func__, policy->cpu, in cpufreq_online()
1644 str_enable_disable(policy->boost_enabled)); in cpufreq_online()
1645 policy->boost_enabled = !policy->boost_enabled; in cpufreq_online()
1654 for_each_cpu(j, policy->real_cpus) in cpufreq_online()
1655 remove_cpu_dev_symlink(policy, j, get_cpu_device(j)); in cpufreq_online()
1659 cpufreq_driver->offline(policy); in cpufreq_online()
1663 cpufreq_driver->exit(policy); in cpufreq_online()
1666 cpumask_clear(policy->cpus); in cpufreq_online()
1667 up_write(&policy->rwsem); in cpufreq_online()
1669 cpufreq_policy_free(policy); in cpufreq_online()
1680 struct cpufreq_policy *policy; in cpufreq_add_dev() local
1693 policy = per_cpu(cpufreq_cpu_data, cpu); in cpufreq_add_dev()
1694 if (policy) in cpufreq_add_dev()
1695 add_cpu_dev_symlink(policy, cpu, dev); in cpufreq_add_dev()
1700 static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy) in __cpufreq_offline() argument
1705 cpufreq_stop_governor(policy); in __cpufreq_offline()
1707 cpumask_clear_cpu(cpu, policy->cpus); in __cpufreq_offline()
1709 if (!policy_is_inactive(policy)) { in __cpufreq_offline()
1711 if (cpu == policy->cpu) in __cpufreq_offline()
1712 policy->cpu = cpumask_any(policy->cpus); in __cpufreq_offline()
1714 /* Start the governor again for the active policy. */ in __cpufreq_offline()
1716 ret = cpufreq_start_governor(policy); in __cpufreq_offline()
1725 strscpy(policy->last_governor, policy->governor->name, in __cpufreq_offline()
1728 policy->last_policy = policy->policy; in __cpufreq_offline()
1731 cpufreq_exit_governor(policy); in __cpufreq_offline()
1738 cpufreq_driver->offline(policy); in __cpufreq_offline()
1743 cpufreq_driver->exit(policy); in __cpufreq_offline()
1745 policy->freq_table = NULL; in __cpufreq_offline()
1750 struct cpufreq_policy *policy; in cpufreq_offline() local
1754 policy = cpufreq_cpu_get_raw(cpu); in cpufreq_offline()
1755 if (!policy) { in cpufreq_offline()
1760 down_write(&policy->rwsem); in cpufreq_offline()
1762 __cpufreq_offline(cpu, policy); in cpufreq_offline()
1764 up_write(&policy->rwsem); in cpufreq_offline()
1776 struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); in cpufreq_remove_dev() local
1778 if (!policy) in cpufreq_remove_dev()
1781 down_write(&policy->rwsem); in cpufreq_remove_dev()
1784 __cpufreq_offline(cpu, policy); in cpufreq_remove_dev()
1786 remove_cpu_dev_symlink(policy, cpu, dev); in cpufreq_remove_dev()
1788 if (!cpumask_empty(policy->real_cpus)) { in cpufreq_remove_dev()
1789 up_write(&policy->rwsem); in cpufreq_remove_dev()
1794 * Unregister cpufreq cooling once all the CPUs of the policy are in cpufreq_remove_dev()
1798 cpufreq_cooling_unregister(policy->cdev); in cpufreq_remove_dev()
1799 policy->cdev = NULL; in cpufreq_remove_dev()
1804 cpufreq_driver->exit(policy); in cpufreq_remove_dev()
1806 up_write(&policy->rwsem); in cpufreq_remove_dev()
1808 cpufreq_policy_free(policy); in cpufreq_remove_dev()
1813 * @policy: Policy managing CPUs.
1819 static void cpufreq_out_of_sync(struct cpufreq_policy *policy, in cpufreq_out_of_sync() argument
1825 policy->cur, new_freq); in cpufreq_out_of_sync()
1827 freqs.old = policy->cur; in cpufreq_out_of_sync()
1830 cpufreq_freq_transition_begin(policy, &freqs); in cpufreq_out_of_sync()
1831 cpufreq_freq_transition_end(policy, &freqs, 0); in cpufreq_out_of_sync()
1834 static unsigned int cpufreq_verify_current_freq(struct cpufreq_policy *policy, bool update) in cpufreq_verify_current_freq() argument
1838 new_freq = cpufreq_driver->get(policy->cpu); in cpufreq_verify_current_freq()
1843 * If fast frequency switching is used with the given policy, the check in cpufreq_verify_current_freq()
1844 * against policy->cur is pointless, so skip it in that case. in cpufreq_verify_current_freq()
1846 if (policy->fast_switch_enabled || !has_target()) in cpufreq_verify_current_freq()
1849 if (policy->cur != new_freq) { in cpufreq_verify_current_freq()
1857 if (abs(policy->cur - new_freq) < KHZ_PER_MHZ) in cpufreq_verify_current_freq()
1858 return policy->cur; in cpufreq_verify_current_freq()
1860 cpufreq_out_of_sync(policy, new_freq); in cpufreq_verify_current_freq()
1862 schedule_work(&policy->update); in cpufreq_verify_current_freq()
1869 * cpufreq_quick_get - get the CPU frequency (in kHz) from policy->cur
1877 struct cpufreq_policy *policy; in cpufreq_quick_get() local
1891 policy = cpufreq_cpu_get(cpu); in cpufreq_quick_get()
1892 if (policy) { in cpufreq_quick_get()
1893 ret_freq = policy->cur; in cpufreq_quick_get()
1894 cpufreq_cpu_put(policy); in cpufreq_quick_get()
1909 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); in cpufreq_quick_get_max() local
1912 if (policy) { in cpufreq_quick_get_max()
1913 ret_freq = policy->max; in cpufreq_quick_get_max()
1914 cpufreq_cpu_put(policy); in cpufreq_quick_get_max()
1929 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); in cpufreq_get_hw_max_freq() local
1932 if (policy) { in cpufreq_get_hw_max_freq()
1933 ret_freq = policy->cpuinfo.max_freq; in cpufreq_get_hw_max_freq()
1934 cpufreq_cpu_put(policy); in cpufreq_get_hw_max_freq()
1941 static unsigned int __cpufreq_get(struct cpufreq_policy *policy) in __cpufreq_get() argument
1943 if (unlikely(policy_is_inactive(policy))) in __cpufreq_get()
1946 return cpufreq_verify_current_freq(policy, true); in __cpufreq_get()
1957 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); in cpufreq_get() local
1960 if (policy) { in cpufreq_get()
1961 down_read(&policy->rwsem); in cpufreq_get()
1963 ret_freq = __cpufreq_get(policy); in cpufreq_get()
1964 up_read(&policy->rwsem); in cpufreq_get()
1966 cpufreq_cpu_put(policy); in cpufreq_get()
1984 int cpufreq_generic_suspend(struct cpufreq_policy *policy) in cpufreq_generic_suspend() argument
1988 if (!policy->suspend_freq) { in cpufreq_generic_suspend()
1994 policy->suspend_freq); in cpufreq_generic_suspend()
1996 ret = __cpufreq_driver_target(policy, policy->suspend_freq, in cpufreq_generic_suspend()
2000 __func__, policy->suspend_freq, ret); in cpufreq_generic_suspend()
2016 struct cpufreq_policy *policy; in cpufreq_suspend() local
2026 for_each_active_policy(policy) { in cpufreq_suspend()
2028 down_write(&policy->rwsem); in cpufreq_suspend()
2029 cpufreq_stop_governor(policy); in cpufreq_suspend()
2030 up_write(&policy->rwsem); in cpufreq_suspend()
2033 if (cpufreq_driver->suspend && cpufreq_driver->suspend(policy)) in cpufreq_suspend()
2050 struct cpufreq_policy *policy; in cpufreq_resume() local
2066 for_each_active_policy(policy) { in cpufreq_resume()
2067 if (cpufreq_driver->resume && cpufreq_driver->resume(policy)) { in cpufreq_resume()
2071 down_write(&policy->rwsem); in cpufreq_resume()
2072 ret = cpufreq_start_governor(policy); in cpufreq_resume()
2073 up_write(&policy->rwsem); in cpufreq_resume()
2076 pr_err("%s: Failed to start governor for CPU%u's policy\n", in cpufreq_resume()
2077 __func__, policy->cpu); in cpufreq_resume()
2135 * of notifiers that ron on cpufreq policy changes.
2221 * @policy: cpufreq policy to switch the frequency for.
2231 * This function must not be called if policy->fast_switch_enabled is unset.
2234 * twice in parallel for the same policy and that it will never be called in
2235 * parallel with either ->target() or ->target_index() for the same policy.
2242 unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy, in cpufreq_driver_fast_switch() argument
2248 target_freq = clamp_val(target_freq, policy->min, policy->max); in cpufreq_driver_fast_switch()
2249 freq = cpufreq_driver->fast_switch(policy, target_freq); in cpufreq_driver_fast_switch()
2254 policy->cur = freq; in cpufreq_driver_fast_switch()
2255 arch_set_freq_scale(policy->related_cpus, freq, in cpufreq_driver_fast_switch()
2256 arch_scale_freq_ref(policy->cpu)); in cpufreq_driver_fast_switch()
2257 cpufreq_stats_record_transition(policy, freq); in cpufreq_driver_fast_switch()
2260 for_each_cpu(cpu, policy->cpus) in cpufreq_driver_fast_switch()
2282 * This function must not be called if policy->fast_switch_enabled is unset.
2309 static int __target_intermediate(struct cpufreq_policy *policy, in __target_intermediate() argument
2314 freqs->new = cpufreq_driver->get_intermediate(policy, index); in __target_intermediate()
2321 __func__, policy->cpu, freqs->old, freqs->new); in __target_intermediate()
2323 cpufreq_freq_transition_begin(policy, freqs); in __target_intermediate()
2324 ret = cpufreq_driver->target_intermediate(policy, index); in __target_intermediate()
2325 cpufreq_freq_transition_end(policy, freqs, ret); in __target_intermediate()
2334 static int __target_index(struct cpufreq_policy *policy, int index) in __target_index() argument
2336 struct cpufreq_freqs freqs = {.old = policy->cur, .flags = 0}; in __target_index()
2338 unsigned int newfreq = policy->freq_table[index].frequency; in __target_index()
2342 if (newfreq == policy->cur) in __target_index()
2346 restore_freq = policy->cur; in __target_index()
2352 retval = __target_intermediate(policy, &freqs, index); in __target_index()
2364 __func__, policy->cpu, freqs.old, freqs.new); in __target_index()
2366 cpufreq_freq_transition_begin(policy, &freqs); in __target_index()
2369 retval = cpufreq_driver->target_index(policy, index); in __target_index()
2375 cpufreq_freq_transition_end(policy, &freqs, retval); in __target_index()
2386 cpufreq_freq_transition_begin(policy, &freqs); in __target_index()
2387 cpufreq_freq_transition_end(policy, &freqs, 0); in __target_index()
2394 int __cpufreq_driver_target(struct cpufreq_policy *policy, in __cpufreq_driver_target() argument
2403 target_freq = __resolve_freq(policy, target_freq, policy->min, in __cpufreq_driver_target()
2404 policy->max, relation); in __cpufreq_driver_target()
2407 policy->cpu, target_freq, relation, old_target_freq); in __cpufreq_driver_target()
2415 if (target_freq == policy->cur && in __cpufreq_driver_target()
2424 if (!policy->efficiencies_available) in __cpufreq_driver_target()
2427 return cpufreq_driver->target(policy, target_freq, relation); in __cpufreq_driver_target()
2433 return __target_index(policy, policy->cached_resolved_idx); in __cpufreq_driver_target()
2437 int cpufreq_driver_target(struct cpufreq_policy *policy, in cpufreq_driver_target() argument
2443 down_write(&policy->rwsem); in cpufreq_driver_target()
2445 ret = __cpufreq_driver_target(policy, target_freq, relation); in cpufreq_driver_target()
2447 up_write(&policy->rwsem); in cpufreq_driver_target()
2458 static int cpufreq_init_governor(struct cpufreq_policy *policy) in cpufreq_init_governor() argument
2469 if (!policy->governor) in cpufreq_init_governor()
2473 if (policy->governor->flags & CPUFREQ_GOV_DYNAMIC_SWITCHING && in cpufreq_init_governor()
2479 policy->governor->name, gov->name); in cpufreq_init_governor()
2480 policy->governor = gov; in cpufreq_init_governor()
2486 if (!try_module_get(policy->governor->owner)) in cpufreq_init_governor()
2489 pr_debug("%s: for CPU %u\n", __func__, policy->cpu); in cpufreq_init_governor()
2491 if (policy->governor->init) { in cpufreq_init_governor()
2492 ret = policy->governor->init(policy); in cpufreq_init_governor()
2494 module_put(policy->governor->owner); in cpufreq_init_governor()
2499 policy->strict_target = !!(policy->governor->flags & CPUFREQ_GOV_STRICT_TARGET); in cpufreq_init_governor()
2504 static void cpufreq_exit_governor(struct cpufreq_policy *policy) in cpufreq_exit_governor() argument
2506 if (cpufreq_suspended || !policy->governor) in cpufreq_exit_governor()
2509 pr_debug("%s: for CPU %u\n", __func__, policy->cpu); in cpufreq_exit_governor()
2511 if (policy->governor->exit) in cpufreq_exit_governor()
2512 policy->governor->exit(policy); in cpufreq_exit_governor()
2514 module_put(policy->governor->owner); in cpufreq_exit_governor()
2517 int cpufreq_start_governor(struct cpufreq_policy *policy) in cpufreq_start_governor() argument
2524 if (!policy->governor) in cpufreq_start_governor()
2527 pr_debug("%s: for CPU %u\n", __func__, policy->cpu); in cpufreq_start_governor()
2530 cpufreq_verify_current_freq(policy, false); in cpufreq_start_governor()
2532 if (policy->governor->start) { in cpufreq_start_governor()
2533 ret = policy->governor->start(policy); in cpufreq_start_governor()
2538 if (policy->governor->limits) in cpufreq_start_governor()
2539 policy->governor->limits(policy); in cpufreq_start_governor()
2544 void cpufreq_stop_governor(struct cpufreq_policy *policy) in cpufreq_stop_governor() argument
2546 if (cpufreq_suspended || !policy->governor) in cpufreq_stop_governor()
2549 pr_debug("%s: for CPU %u\n", __func__, policy->cpu); in cpufreq_stop_governor()
2551 if (policy->governor->stop) in cpufreq_stop_governor()
2552 policy->governor->stop(policy); in cpufreq_stop_governor()
2555 static void cpufreq_governor_limits(struct cpufreq_policy *policy) in cpufreq_governor_limits() argument
2557 if (cpufreq_suspended || !policy->governor) in cpufreq_governor_limits()
2560 pr_debug("%s: for CPU %u\n", __func__, policy->cpu); in cpufreq_governor_limits()
2562 if (policy->governor->limits) in cpufreq_governor_limits()
2563 policy->governor->limits(policy); in cpufreq_governor_limits()
2591 struct cpufreq_policy *policy; in cpufreq_unregister_governor() local
2602 for_each_inactive_policy(policy) { in cpufreq_unregister_governor()
2603 if (!strcmp(policy->last_governor, governor->name)) { in cpufreq_unregister_governor()
2604 policy->governor = NULL; in cpufreq_unregister_governor()
2605 strcpy(policy->last_governor, "\0"); in cpufreq_unregister_governor()
2618 * POLICY INTERFACE *
2623 * @policy: struct cpufreq_policy into which the current cpufreq_policy
2625 * @cpu: CPU to find the policy for
2627 * Reads the current cpufreq policy.
2629 int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu) in cpufreq_get_policy() argument
2632 if (!policy) in cpufreq_get_policy()
2639 memcpy(policy, cpu_policy, sizeof(*policy)); in cpufreq_get_policy()
2650 * @policy: cpufreq policy of the CPUs.
2652 * Update the value of cpufreq pressure for all @cpus in the policy.
2654 static void cpufreq_update_pressure(struct cpufreq_policy *policy) in cpufreq_update_pressure() argument
2660 cpu = cpumask_first(policy->related_cpus); in cpufreq_update_pressure()
2662 capped_freq = policy->max; in cpufreq_update_pressure()
2676 for_each_cpu(cpu, policy->related_cpus) in cpufreq_update_pressure()
2681 * cpufreq_set_policy - Modify cpufreq policy parameters.
2682 * @policy: Policy object to modify.
2683 * @new_gov: Policy governor pointer.
2684 * @new_pol: Policy value (for drivers with built-in governors).
2687 * limits to be set for the policy, update @policy with the verified limits
2689 * carry out a governor update for @policy. That is, run the current governor's
2691 * @policy) or replace the governor for @policy with @new_gov.
2693 * The cpuinfo part of @policy is not updated by this function.
2695 static int cpufreq_set_policy(struct cpufreq_policy *policy, in cpufreq_set_policy() argument
2703 memcpy(&new_data.cpuinfo, &policy->cpuinfo, sizeof(policy->cpuinfo)); in cpufreq_set_policy()
2704 new_data.freq_table = policy->freq_table; in cpufreq_set_policy()
2705 new_data.cpu = policy->cpu; in cpufreq_set_policy()
2710 new_data.min = freq_qos_read_value(&policy->constraints, FREQ_QOS_MIN); in cpufreq_set_policy()
2711 new_data.max = freq_qos_read_value(&policy->constraints, FREQ_QOS_MAX); in cpufreq_set_policy()
2713 pr_debug("setting new policy for CPU %u: %u - %u kHz\n", in cpufreq_set_policy()
2725 * Resolve policy min/max to available frequencies. It ensures in cpufreq_set_policy()
2729 * Avoid storing intermediate values in policy->max or policy->min and in cpufreq_set_policy()
2733 WRITE_ONCE(policy->max, __resolve_freq(policy, new_data.max, in cpufreq_set_policy()
2736 new_data.min = __resolve_freq(policy, new_data.min, new_data.min, in cpufreq_set_policy()
2738 WRITE_ONCE(policy->min, new_data.min > policy->max ? policy->max : new_data.min); in cpufreq_set_policy()
2740 trace_cpu_frequency_limits(policy); in cpufreq_set_policy()
2742 cpufreq_update_pressure(policy); in cpufreq_set_policy()
2744 policy->cached_target_freq = UINT_MAX; in cpufreq_set_policy()
2747 policy->min, policy->max); in cpufreq_set_policy()
2750 policy->policy = new_pol; in cpufreq_set_policy()
2752 return cpufreq_driver->setpolicy(policy); in cpufreq_set_policy()
2755 if (new_gov == policy->governor) { in cpufreq_set_policy()
2757 cpufreq_governor_limits(policy); in cpufreq_set_policy()
2764 old_gov = policy->governor; in cpufreq_set_policy()
2767 cpufreq_stop_governor(policy); in cpufreq_set_policy()
2768 cpufreq_exit_governor(policy); in cpufreq_set_policy()
2772 policy->governor = new_gov; in cpufreq_set_policy()
2773 ret = cpufreq_init_governor(policy); in cpufreq_set_policy()
2775 ret = cpufreq_start_governor(policy); in cpufreq_set_policy()
2780 cpufreq_exit_governor(policy); in cpufreq_set_policy()
2784 pr_debug("starting governor %s failed\n", policy->governor->name); in cpufreq_set_policy()
2786 policy->governor = old_gov; in cpufreq_set_policy()
2787 if (cpufreq_init_governor(policy)) in cpufreq_set_policy()
2788 policy->governor = NULL; in cpufreq_set_policy()
2790 cpufreq_start_governor(policy); in cpufreq_set_policy()
2797 * cpufreq_update_policy - Re-evaluate an existing cpufreq policy.
2798 * @cpu: CPU to re-evaluate the policy for.
2800 * Update the current frequency for the cpufreq policy of @cpu and use
2802 * evaluation of policy notifiers and the cpufreq driver's ->verify() callback
2803 * for the policy in question, among other things.
2807 struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpu); in cpufreq_update_policy() local
2809 if (!policy) in cpufreq_update_policy()
2817 (cpufreq_suspended || WARN_ON(!cpufreq_verify_current_freq(policy, false)))) in cpufreq_update_policy()
2820 refresh_frequency_limits(policy); in cpufreq_update_policy()
2823 cpufreq_cpu_release(policy); in cpufreq_update_policy()
2828 * cpufreq_update_limits - Update policy limits for a given CPU.
2829 * @cpu: CPU to update the policy limits for.
2836 struct cpufreq_policy *policy __free(put_cpufreq_policy); in cpufreq_update_limits()
2838 policy = cpufreq_cpu_get(cpu); in cpufreq_update_limits()
2839 if (!policy) in cpufreq_update_limits()
2852 int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state) in cpufreq_boost_set_sw() argument
2856 if (!policy->freq_table) in cpufreq_boost_set_sw()
2859 ret = cpufreq_frequency_table_cpuinfo(policy, policy->freq_table); in cpufreq_boost_set_sw()
2861 pr_err("%s: Policy frequency update failed\n", __func__); in cpufreq_boost_set_sw()
2865 ret = freq_qos_update_request(policy->max_freq_req, policy->max); in cpufreq_boost_set_sw()
2875 struct cpufreq_policy *policy; in cpufreq_boost_trigger_state() local
2887 for_each_active_policy(policy) { in cpufreq_boost_trigger_state()
2888 if (!policy->boost_supported) in cpufreq_boost_trigger_state()
2891 policy->boost_enabled = state; in cpufreq_boost_trigger_state()
2892 ret = cpufreq_driver->set_boost(policy, state); in cpufreq_boost_trigger_state()
2894 policy->boost_enabled = !policy->boost_enabled; in cpufreq_boost_trigger_state()