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

1 // SPDX-License-Identifier: GPL-2.0-only
6 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
9 * Oct 2005 - Ashok Raj <ashok.raj@intel.com>
11 * Feb 2006 - Jacob Shin <jacob.shin@amd.com>
12 * Fix handling for CPU hotplug -- affected CPUs
55 * The "cpufreq driver" - the arch- or hardware-dependent low
74 return cpufreq_driver->target_index || cpufreq_driver->target; in has_target()
79 return !!cpufreq_driver->target_index; in has_target_index()
116 return !!(cpufreq_driver->flags & CPUFREQ_HAVE_GOVERNOR_PER_POLICY); in have_governor_per_policy()
125 return &policy->kobj; in get_governor_parent_kobj()
149 idle_time = cur_wall_time - busy_time; in get_cpu_idle_time_jiffy()
160 if (idle_time == -1ULL) in get_cpu_idle_time()
172 * - validate & show freq table passed
173 * - set policies transition latency
174 * - policy->cpus with all possible CPUs
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()
195 return policy && cpumask_test_cpu(cpu, policy->cpus) ? policy : NULL; in cpufreq_cpu_get_raw()
203 if (!policy || IS_ERR(policy->clk)) { 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.
239 kobject_get(&policy->kobj); in cpufreq_cpu_get()
249 * cpufreq_cpu_put - Decrement kobject usage counter for cpufreq policy.
254 kobject_put(&policy->kobj); in cpufreq_cpu_put()
259 * cpufreq_cpu_release - Unlock a policy and decrement its usage counter.
267 lockdep_assert_held(&policy->rwsem); in cpufreq_cpu_release()
269 up_write(&policy->rwsem); in cpufreq_cpu_release()
275 * cpufreq_cpu_acquire - Find policy for a CPU, mark it as busy and lock it.
293 down_write(&policy->rwsem); in cpufreq_cpu_acquire()
308 * adjust_jiffies - Adjust the system "loops_per_jiffy".
315 * per-CPU loops_per_jiffy value wherever possible.
323 if (ci->flags & CPUFREQ_CONST_LOOPS) in adjust_jiffies()
328 l_p_j_ref_freq = ci->old; in adjust_jiffies()
329 pr_debug("saving %lu as reference value for loops_per_jiffy; freq is %u kHz\n", in adjust_jiffies()
332 if (val == CPUFREQ_POSTCHANGE && ci->old != ci->new) { in adjust_jiffies()
334 ci->new); in adjust_jiffies()
336 loops_per_jiffy, ci->new); in adjust_jiffies()
342 * cpufreq_notify_transition - Notify frequency transition and adjust jiffies.
343 * @policy: cpufreq policy to enable fast frequency switching for.
362 freqs->policy = policy; in cpufreq_notify_transition()
363 freqs->flags = cpufreq_driver->flags; in cpufreq_notify_transition()
365 state, freqs->new); 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()
388 pr_debug("FREQ: %u - CPUs: %*pbl\n", freqs->new, 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()
392 trace_cpu_frequency(freqs->new, cpu); 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()
410 swap(freqs->old, freqs->new); in cpufreq_notify_post_transition()
420 * Catch double invocations of _begin() which lead to self-deadlock. in cpufreq_freq_transition_begin()
424 * where these checks can emit false-positive warnings in these in cpufreq_freq_transition_begin()
427 WARN_ON(!(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION) in cpufreq_freq_transition_begin()
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()
452 if (WARN_ON(!policy->transition_ongoing)) 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()
471 * Fast frequency switching status count. Positive means "enabled", negative
485 for (nb = cpufreq_transition_notifier_list.head; nb; nb = nb->next) in cpufreq_list_transition_notifiers()
486 pr_info("%pS\n", nb->notifier_call); in cpufreq_list_transition_notifiers()
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.
498 * at this point, as fast frequency switching is quite fundamentally at odds
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()
514 pr_warn("CPU%u: Fast frequency switching not enabled\n", 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.
529 if (policy->fast_switch_enabled) { in cpufreq_disable_fast_switch()
530 policy->fast_switch_enabled = false; in cpufreq_disable_fast_switch()
532 cpufreq_fast_switch_count--; in cpufreq_disable_fast_switch()
547 if (!policy->freq_table) 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()
557 * cpufreq_driver_resolve_freq - Map a target frequency to a driver-supported
564 * Return: Lowest driver-supported frequency greater than or equal to the
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()
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()
610 return sysfs_emit(buf, "%d\n", cpufreq_driver->boost_enabled); in show_boost()
619 return -EINVAL; in store_boost()
624 return -EINVAL; in store_boost()
636 return sysfs_emit(buf, "%d\n", policy->boost_enabled); in show_local_boost()
646 return -EINVAL; in store_local_boost()
648 if (!cpufreq_driver->boost_enabled) in store_local_boost()
649 return -EINVAL; in store_local_boost()
651 if (!policy->boost_supported) in store_local_boost()
652 return -EINVAL; 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()
678 if (!strncasecmp(str_governor, t->name, CPUFREQ_NAME_LEN)) in find_governor()
693 if (!try_module_get(t->owner)) in get_governor()
714 * cpufreq_parse_governor - parse a governor string only for has_target()
732 * cpufreq_per_cpu_attr_read() / show_##file_name() -
735 * Write out information from cpufreq_driver->policy[cpu]; object must be
743 return sysfs_emit(buf, "%u\n", policy->object); \
754 return -EOPNOTSUPP; in arch_freq_get_on_cpu()
759 return arch_freq_get_on_cpu(policy->cpu) != -EOPNOTSUPP; in cpufreq_avg_freq_supported()
765 int freq; in show_scaling_cur_freq() local
767 freq = IS_ENABLED(CONFIG_CPUFREQ_ARCH_CUR_FREQ) in show_scaling_cur_freq()
768 ? arch_freq_get_on_cpu(policy->cpu) in show_scaling_cur_freq()
771 if (freq > 0) in show_scaling_cur_freq()
772 ret = sysfs_emit(buf, "%u\n", freq); in show_scaling_cur_freq()
773 else if (cpufreq_driver->setpolicy && cpufreq_driver->get) 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()
781 * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access
794 ret = freq_qos_update_request(policy->object##_freq_req, val);\
802 * show_cpuinfo_cur_freq - current CPU frequency as detected by hardware
816 * show_cpuinfo_avg_freq - average CPU frequency as detected by hardware
821 int avg_freq = arch_freq_get_on_cpu(policy->cpu); in show_cpuinfo_avg_freq()
825 return avg_freq != 0 ? avg_freq : -EINVAL; in show_cpuinfo_avg_freq()
829 * show_scaling_governor - show the current policy for the specified CPU
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()
839 return -EINVAL; in show_scaling_governor()
843 * store_scaling_governor - store policy for the specified CPU
853 return -EINVAL; in store_scaling_governor()
855 if (cpufreq_driver->setpolicy) { in store_scaling_governor()
860 return -EINVAL; in store_scaling_governor()
868 return -EINVAL; in store_scaling_governor()
873 module_put(new_gov->owner); in store_scaling_governor()
880 * show_scaling_driver - show the cpufreq driver currently loaded
884 return scnprintf(buf, CPUFREQ_NAME_PLEN, "%s\n", cpufreq_driver->name); in show_scaling_driver()
888 * show_scaling_available_governors - show the available CPUfreq governors
904 - (CPUFREQ_NAME_LEN + 2))) in show_scaling_available_governors()
906 i += sysfs_emit_at(buf, i, "%s ", t->name); in show_scaling_available_governors()
921 if (i >= (PAGE_SIZE - 5)) in cpufreq_show_cpus()
926 i--; in cpufreq_show_cpus()
934 * show_related_cpus - show the CPUs affected by each transition even if
939 return cpufreq_show_cpus(policy->related_cpus, buf); in show_related_cpus()
943 * show_affected_cpus - show the CPUs affected by each transition
947 return cpufreq_show_cpus(policy->cpus, buf); in show_affected_cpus()
953 unsigned int freq = 0; in store_scaling_setspeed() local
956 if (!policy->governor || !policy->governor->store_setspeed) in store_scaling_setspeed()
957 return -EINVAL; in store_scaling_setspeed()
959 ret = sscanf(buf, "%u", &freq); in store_scaling_setspeed()
961 return -EINVAL; in store_scaling_setspeed()
963 policy->governor->store_setspeed(policy, freq); in store_scaling_setspeed()
970 if (!policy->governor || !policy->governor->show_setspeed) in show_scaling_setspeed()
973 return policy->governor->show_setspeed(policy, buf); in show_scaling_setspeed()
977 * show_bios_limit - show the current cpufreq HW/BIOS limitation
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()
1028 ssize_t ret = -EBUSY; in show()
1030 if (!fattr->show) in show()
1031 return -EIO; in show()
1033 down_read(&policy->rwsem); in show()
1035 ret = fattr->show(policy, buf); in show()
1036 up_read(&policy->rwsem); in show()
1046 ssize_t ret = -EBUSY; in store()
1048 if (!fattr->store) in store()
1049 return -EIO; in store()
1051 down_write(&policy->rwsem); in store()
1053 ret = fattr->store(policy, buf, count); in store()
1054 up_write(&policy->rwsem); in store()
1063 complete(&policy->kobj_unregister); in cpufreq_sysfs_release()
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()
1095 sysfs_remove_link(&dev->kobj, "cpufreq"); in remove_cpu_dev_symlink()
1096 cpumask_clear_cpu(cpu, policy->real_cpus); in remove_cpu_dev_symlink()
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()
1120 drv_attr = cpufreq_driver->attr; in cpufreq_add_dev_interface()
1122 ret = sysfs_create_file(&policy->kobj, &((*drv_attr)->attr)); in cpufreq_add_dev_interface()
1127 if (cpufreq_driver->get) { in cpufreq_add_dev_interface()
1128 ret = sysfs_create_file(&policy->kobj, &cpuinfo_cur_freq.attr); 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()
1143 if (cpufreq_driver->bios_limit) { 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()
1166 gov = get_governor(policy->last_governor); in cpufreq_init_policy()
1169 gov->name, policy->cpu); in cpufreq_init_policy()
1176 __module_get(gov->owner); in cpufreq_init_policy()
1182 if (policy->last_policy) { in cpufreq_init_policy()
1183 pol = policy->last_policy; in cpufreq_init_policy()
1192 pol = policy->policy; in cpufreq_init_policy()
1196 return -ENODATA; in cpufreq_init_policy()
1201 module_put(gov->owner); in cpufreq_init_policy()
1211 if (cpumask_test_cpu(cpu, policy->cpus)) in cpufreq_add_policy_cpu()
1214 down_write(&policy->rwsem); in cpufreq_add_policy_cpu()
1218 cpumask_set_cpu(cpu, policy->cpus); in cpufreq_add_policy_cpu()
1225 up_write(&policy->rwsem); in cpufreq_add_policy_cpu()
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()
1244 pr_debug("handle_update for cpu %u called\n", policy->cpu); in handle_update()
1245 down_write(&policy->rwsem); in handle_update()
1247 up_write(&policy->rwsem); in handle_update()
1250 static int cpufreq_notifier_min(struct notifier_block *nb, unsigned long freq, in cpufreq_notifier_min() argument
1255 schedule_work(&policy->update); in cpufreq_notifier_min()
1259 static int cpufreq_notifier_max(struct notifier_block *nb, unsigned long freq, in cpufreq_notifier_max() argument
1264 schedule_work(&policy->update); in cpufreq_notifier_max()
1273 down_write(&policy->rwsem); 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()
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()
1316 dev_err(dev, "%s: failed to init policy->kobj: %d\n", __func__, ret); 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()
1357 freq_qos_remove_notifier(&policy->constraints, FREQ_QOS_MIN, in cpufreq_policy_alloc()
1358 &policy->nb_min); 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()
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()
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()
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()
1435 WARN_ON(!cpumask_test_cpu(cpu, policy->related_cpus)); 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()
1448 return -ENOMEM; in cpufreq_online()
1449 down_write(&policy->rwsem); in cpufreq_online()
1452 if (!new_policy && cpufreq_driver->online) { 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()
1467 * to accept all calls to ->verify and ->setpolicy for this CPU. in cpufreq_online()
1469 ret = cpufreq_driver->init(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()
1501 policy->min_freq_req = kzalloc(2 * sizeof(*policy->min_freq_req), in cpufreq_online()
1503 if (!policy->min_freq_req) { in cpufreq_online()
1504 ret = -ENOMEM; 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()
1539 ret = freq_qos_update_request(policy->max_freq_req, policy->max); in cpufreq_online()
1544 if (cpufreq_driver->get && has_target()) { in cpufreq_online()
1545 policy->cur = cpufreq_driver->get(policy->cpu); in cpufreq_online()
1546 if (!policy->cur) { in cpufreq_online()
1547 ret = -EIO; in cpufreq_online()
1548 pr_err("%s: ->get() failed\n", __func__); in cpufreq_online()
1558 * freq-table. This also makes cpufreq stats inconsistent as in cpufreq_online()
1559 * cpufreq-stats would fail to register because current frequency of CPU in cpufreq_online()
1560 * isn't found in freq-table. in cpufreq_online()
1563 * for the next freq which is >= policy->cur ('cur' must be set by now, in cpufreq_online()
1564 * otherwise we will end up setting freq to lowest of the table as 'cur' 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()
1569 * equal to target-freq. in cpufreq_online()
1571 if ((cpufreq_driver->flags & CPUFREQ_NEED_INITIAL_FREQ_CHECK) in cpufreq_online()
1573 unsigned int old_freq = policy->cur; in cpufreq_online()
1577 if (ret == -EINVAL) { 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()
1600 list_add(&policy->policy_list, &cpufreq_policy_list); in cpufreq_online()
1613 if (cpufreq_driver->register_em) in cpufreq_online()
1614 cpufreq_driver->register_em(policy); in cpufreq_online()
1624 up_write(&policy->rwsem); in cpufreq_online()
1626 kobject_uevent(&policy->kobj, KOBJ_ADD); in cpufreq_online()
1629 if (cpufreq_driver->ready) in cpufreq_online()
1630 cpufreq_driver->ready(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()
1658 if (cpufreq_driver->offline) in cpufreq_online()
1659 cpufreq_driver->offline(policy); in cpufreq_online()
1662 if (cpufreq_driver->exit) 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()
1674 * cpufreq_add_dev - the cpufreq interface for a CPU device.
1681 unsigned cpu = dev->id; in cpufreq_add_dev()
1707 cpumask_clear_cpu(cpu, policy->cpus); in __cpufreq_offline()
1711 if (cpu == policy->cpu) in __cpufreq_offline()
1712 policy->cpu = cpumask_any(policy->cpus); in __cpufreq_offline()
1725 strscpy(policy->last_governor, policy->governor->name, in __cpufreq_offline()
1728 policy->last_policy = policy->policy; in __cpufreq_offline()
1734 * Perform the ->offline() during light-weight tear-down, as in __cpufreq_offline()
1737 if (cpufreq_driver->offline) { in __cpufreq_offline()
1738 cpufreq_driver->offline(policy); in __cpufreq_offline()
1742 if (cpufreq_driver->exit) in __cpufreq_offline()
1743 cpufreq_driver->exit(policy); in __cpufreq_offline()
1745 policy->freq_table = NULL; in __cpufreq_offline()
1760 down_write(&policy->rwsem); in cpufreq_offline()
1764 up_write(&policy->rwsem); in cpufreq_offline()
1769 * cpufreq_remove_dev - remove a CPU device
1775 unsigned int cpu = dev->id; in cpufreq_remove_dev()
1781 down_write(&policy->rwsem); in cpufreq_remove_dev()
1788 if (!cpumask_empty(policy->real_cpus)) { in cpufreq_remove_dev()
1789 up_write(&policy->rwsem); in cpufreq_remove_dev()
1798 cpufreq_cooling_unregister(policy->cdev); in cpufreq_remove_dev()
1799 policy->cdev = NULL; in cpufreq_remove_dev()
1802 /* We did light-weight exit earlier, do full tear down now */ in cpufreq_remove_dev()
1803 if (cpufreq_driver->offline && cpufreq_driver->exit) in cpufreq_remove_dev()
1804 cpufreq_driver->exit(policy); in cpufreq_remove_dev()
1806 up_write(&policy->rwsem); in cpufreq_remove_dev()
1812 * cpufreq_out_of_sync - Fix up actual and saved CPU frequency difference.
1825 policy->cur, new_freq); in cpufreq_out_of_sync()
1827 freqs.old = policy->cur; in cpufreq_out_of_sync()
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()
1862 schedule_work(&policy->update); in cpufreq_verify_current_freq()
1869 * cpufreq_quick_get - get the CPU frequency (in kHz) from policy->cur
1872 * This is the last known freq, without actually getting it from the driver.
1883 if (cpufreq_driver && cpufreq_driver->setpolicy && cpufreq_driver->get) { in cpufreq_quick_get()
1884 ret_freq = cpufreq_driver->get(cpu); in cpufreq_quick_get()
1893 ret_freq = policy->cur; in cpufreq_quick_get()
1902 * cpufreq_quick_get_max - get the max reported CPU frequency for this CPU
1913 ret_freq = policy->max; in cpufreq_quick_get_max()
1922 * cpufreq_get_hw_max_freq - get the max hardware frequency of the CPU
1933 ret_freq = policy->cpuinfo.max_freq; in cpufreq_get_hw_max_freq()
1950 * cpufreq_get - get the current CPU frequency (in kHz)
1961 down_read(&policy->rwsem); in cpufreq_get()
1962 if (cpufreq_driver->get) in cpufreq_get()
1964 up_read(&policy->rwsem); in cpufreq_get()
1988 if (!policy->suspend_freq) { in cpufreq_generic_suspend()
1993 pr_debug("%s: Setting suspend-freq: %u\n", __func__, 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()
1999 pr_err("%s: unable to set suspend-freq: %u. err: %d\n", in cpufreq_generic_suspend()
2000 __func__, policy->suspend_freq, ret); in cpufreq_generic_suspend()
2007 * cpufreq_suspend() - Suspend CPUFreq governors.
2021 if (!has_target() && !cpufreq_driver->suspend) in cpufreq_suspend()
2028 down_write(&policy->rwsem); in cpufreq_suspend()
2030 up_write(&policy->rwsem); in cpufreq_suspend()
2033 if (cpufreq_driver->suspend && cpufreq_driver->suspend(policy)) in cpufreq_suspend()
2035 cpufreq_driver->name); in cpufreq_suspend()
2043 * cpufreq_resume() - Resume CPUFreq governors.
2061 if (!has_target() && !cpufreq_driver->resume) in cpufreq_resume()
2067 if (cpufreq_driver->resume && cpufreq_driver->resume(policy)) { in cpufreq_resume()
2069 cpufreq_driver->name); in cpufreq_resume()
2071 down_write(&policy->rwsem); in cpufreq_resume()
2073 up_write(&policy->rwsem); in cpufreq_resume()
2077 __func__, policy->cpu); in cpufreq_resume()
2083 * cpufreq_driver_test_flags - Test cpufreq driver's flags against given ones.
2091 return !!(cpufreq_driver->flags & flags); in cpufreq_driver_test_flags()
2095 * cpufreq_get_current_driver - Return the current driver's name.
2103 return cpufreq_driver->name; in cpufreq_get_current_driver()
2110 * cpufreq_get_driver_data - Return current driver data.
2118 return cpufreq_driver->driver_data; in cpufreq_get_driver_data()
2129 * cpufreq_register_notifier - Register a notifier with cpufreq.
2145 return -EINVAL; in cpufreq_register_notifier()
2153 return -EBUSY; in cpufreq_register_notifier()
2158 cpufreq_fast_switch_count--; in cpufreq_register_notifier()
2167 ret = -EINVAL; in cpufreq_register_notifier()
2175 * cpufreq_unregister_notifier - Unregister a notifier from cpufreq.
2189 return -EINVAL; in cpufreq_unregister_notifier()
2207 ret = -EINVAL; in cpufreq_unregister_notifier()
2220 * cpufreq_driver_fast_switch - Carry out a fast CPU frequency switch.
2226 * The driver's ->fast_switch() callback invoked by this function must be
2227 * suitable for being called from within RCU-sched read-side critical sections
2231 * This function must not be called if policy->fast_switch_enabled is unset.
2235 * parallel with either ->target() or ->target_index() for the same policy.
2239 * If 0 is returned by the driver's ->fast_switch() callback to indicate an
2245 unsigned int freq; in cpufreq_driver_fast_switch() local
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()
2251 if (!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()
2261 trace_cpu_frequency(freq, cpu); in cpufreq_driver_fast_switch()
2264 return freq; in cpufreq_driver_fast_switch()
2269 * cpufreq_driver_adjust_perf - Adjust CPU performance level in one go.
2277 * The driver's ->adjust_perf() callback invoked by this function must be
2278 * suitable for being called from within RCU-sched read-side critical sections
2282 * This function must not be called if policy->fast_switch_enabled is unset.
2286 * parallel with either ->target() or ->target_index() or ->fast_switch() for
2294 cpufreq_driver->adjust_perf(cpu, min_perf, target_perf, capacity); in cpufreq_driver_adjust_perf()
2298 * cpufreq_driver_has_adjust_perf - Check "direct fast switch" callback.
2300 * Return 'true' if the ->adjust_perf callback is present for the
2305 return !!cpufreq_driver->adjust_perf; in cpufreq_driver_has_adjust_perf()
2308 /* Must set freqs->new to intermediate frequency */
2314 freqs->new = cpufreq_driver->get_intermediate(policy, index); in __target_intermediate()
2316 /* We don't need to switch to intermediate freq */ in __target_intermediate()
2317 if (!freqs->new) in __target_intermediate()
2320 pr_debug("%s: cpu: %d, switching to intermediate freq: oldfreq: %u, intermediate freq: %u\n", in __target_intermediate()
2321 __func__, policy->cpu, freqs->old, freqs->new); in __target_intermediate()
2324 ret = cpufreq_driver->target_intermediate(policy, index); in __target_intermediate()
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()
2339 int retval = -EINVAL; in __target_index()
2342 if (newfreq == policy->cur) in __target_index()
2346 restore_freq = policy->cur; in __target_index()
2348 notify = !(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION); in __target_index()
2350 /* Handle switching to intermediate frequency */ in __target_index()
2351 if (cpufreq_driver->get_intermediate) { in __target_index()
2357 /* Set old freq to intermediate */ in __target_index()
2363 pr_debug("%s: cpu: %d, oldfreq: %u, new freq: %u\n", in __target_index()
2364 __func__, policy->cpu, freqs.old, freqs.new); in __target_index()
2369 retval = cpufreq_driver->target_index(policy, index); in __target_index()
2378 * Failed after setting to intermediate freq? Driver should have in __target_index()
2381 * case we haven't switched to intermediate freq at all. in __target_index()
2401 return -ENODEV; in __cpufreq_driver_target()
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()
2412 * exactly same freq is called again and so we can save on few function in __cpufreq_driver_target()
2415 if (target_freq == policy->cur && in __cpufreq_driver_target()
2416 !(cpufreq_driver->flags & CPUFREQ_NEED_UPDATE_LIMITS)) in __cpufreq_driver_target()
2419 if (cpufreq_driver->target) { 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()
2430 if (!cpufreq_driver->target_index) in __cpufreq_driver_target()
2431 return -EINVAL; in __cpufreq_driver_target()
2433 return __target_index(policy, policy->cached_resolved_idx); in __cpufreq_driver_target()
2443 down_write(&policy->rwsem); in cpufreq_driver_target()
2447 up_write(&policy->rwsem); in cpufreq_driver_target()
2469 if (!policy->governor) in cpufreq_init_governor()
2470 return -EINVAL; in cpufreq_init_governor()
2472 /* Platform doesn't want dynamic frequency switching ? */ in cpufreq_init_governor()
2473 if (policy->governor->flags & CPUFREQ_GOV_DYNAMIC_SWITCHING && in cpufreq_init_governor()
2474 cpufreq_driver->flags & CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING) { in cpufreq_init_governor()
2478 pr_warn("Can't use %s governor as dynamic switching is disallowed. Fallback to %s governor\n", in cpufreq_init_governor()
2479 policy->governor->name, gov->name); in cpufreq_init_governor()
2480 policy->governor = gov; in cpufreq_init_governor()
2482 return -EINVAL; in cpufreq_init_governor()
2486 if (!try_module_get(policy->governor->owner)) in cpufreq_init_governor()
2487 return -EINVAL; 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()
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()
2524 if (!policy->governor) in cpufreq_start_governor()
2525 return -EINVAL; in cpufreq_start_governor()
2527 pr_debug("%s: for CPU %u\n", __func__, policy->cpu); in cpufreq_start_governor()
2529 if (cpufreq_driver->get) 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()
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()
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()
2571 return -EINVAL; in cpufreq_register_governor()
2574 return -ENODEV; in cpufreq_register_governor()
2578 err = -EBUSY; in cpufreq_register_governor()
2579 if (!find_governor(governor->name)) { in cpufreq_register_governor()
2581 list_add(&governor->governor_list, &cpufreq_governor_list); in cpufreq_register_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()
2611 list_del(&governor->governor_list); in cpufreq_unregister_governor()
2622 * cpufreq_get_policy - get the current cpufreq_policy
2633 return -EINVAL; in cpufreq_get_policy()
2637 return -EINVAL; in cpufreq_get_policy()
2649 * cpufreq_update_pressure() - Update cpufreq pressure for CPUs
2660 cpu = cpumask_first(policy->related_cpus); in cpufreq_update_pressure()
2662 capped_freq = policy->max; in cpufreq_update_pressure()
2672 pressure = max_capacity - in cpufreq_update_pressure()
2676 for_each_cpu(cpu, policy->related_cpus) in cpufreq_update_pressure()
2681 * cpufreq_set_policy - Modify cpufreq policy parameters.
2684 * @new_pol: Policy value (for drivers with built-in governors).
2686 * Invoke the cpufreq driver's ->verify() callback to sanity-check the frequency
2688 * values and either invoke the driver's ->setpolicy() callback (if present) or
2690 * ->limits() callback (if @new_gov points to the same object as the one in
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()
2720 ret = cpufreq_driver->verify(&new_data); 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()
2738 WRITE_ONCE(policy->min, new_data.min > policy->max ? policy->max : new_data.min); in cpufreq_set_policy()
2744 policy->cached_target_freq = UINT_MAX; in cpufreq_set_policy()
2746 pr_debug("new min and max freqs are %u - %u kHz\n", in cpufreq_set_policy()
2747 policy->min, policy->max); in cpufreq_set_policy()
2749 if (cpufreq_driver->setpolicy) { 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()
2764 old_gov = policy->governor; in cpufreq_set_policy()
2772 policy->governor = new_gov; in cpufreq_set_policy()
2783 /* new governor failed, so re-start old one */ 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()
2788 policy->governor = NULL; in cpufreq_set_policy()
2797 * cpufreq_update_policy - Re-evaluate an existing cpufreq policy.
2798 * @cpu: CPU to re-evaluate the policy for.
2801 * cpufreq_set_policy() to re-apply the min and max limits, which triggers the
2802 * evaluation of policy notifiers and the cpufreq driver's ->verify() callback
2813 * BIOS might change freq behind our back in cpufreq_update_policy()
2814 * -> ask driver for current freq and notify governors about a change in cpufreq_update_policy()
2816 if (cpufreq_driver->get && has_target() && in cpufreq_update_policy()
2828 * cpufreq_update_limits - Update policy limits for a given CPU.
2831 * Invoke the driver's ->update_limits callback if present or call
2842 if (cpufreq_driver->update_limits) in cpufreq_update_limits()
2843 cpufreq_driver->update_limits(cpu); in cpufreq_update_limits()
2856 if (!policy->freq_table) in cpufreq_boost_set_sw()
2857 return -ENXIO; in cpufreq_boost_set_sw()
2859 ret = cpufreq_frequency_table_cpuinfo(policy, policy->freq_table); in cpufreq_boost_set_sw()
2865 ret = freq_qos_update_request(policy->max_freq_req, policy->max); in cpufreq_boost_set_sw()
2879 if (cpufreq_driver->boost_enabled == state) in cpufreq_boost_trigger_state()
2883 cpufreq_driver->boost_enabled = state; 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()
2906 cpufreq_driver->boost_enabled = !state; in cpufreq_boost_trigger_state()
2917 return cpufreq_driver->set_boost; in cpufreq_boost_supported()
2940 return cpufreq_driver->boost_enabled; in cpufreq_boost_enabled()
2964 * cpufreq_register_driver - register a CPU Frequency driver
2969 * returns zero on success, -EEXIST when another driver got here first
2979 return -ENODEV; in cpufreq_register_driver()
2986 return -EPROBE_DEFER; in cpufreq_register_driver()
2988 if (!driver_data || !driver_data->verify || !driver_data->init || in cpufreq_register_driver()
2989 !(driver_data->setpolicy || driver_data->target_index || in cpufreq_register_driver()
2990 driver_data->target) || in cpufreq_register_driver()
2991 (driver_data->setpolicy && (driver_data->target_index || in cpufreq_register_driver()
2992 driver_data->target)) || in cpufreq_register_driver()
2993 (!driver_data->get_intermediate != !driver_data->target_intermediate) || in cpufreq_register_driver()
2994 (!driver_data->online != !driver_data->offline) || in cpufreq_register_driver()
2995 (driver_data->adjust_perf && !driver_data->fast_switch)) in cpufreq_register_driver()
2996 return -EINVAL; in cpufreq_register_driver()
2998 pr_debug("trying to register driver %s\n", driver_data->name); in cpufreq_register_driver()
3006 ret = -EEXIST; in cpufreq_register_driver()
3016 if (!cpufreq_driver->setpolicy) { in cpufreq_register_driver()
3021 if (driver_data->setpolicy) in cpufreq_register_driver()
3022 driver_data->flags |= CPUFREQ_CONST_LOOPS; in cpufreq_register_driver()
3035 /* if all ->init() calls failed, unregister */ in cpufreq_register_driver()
3036 ret = -ENODEV; in cpufreq_register_driver()
3038 driver_data->name); in cpufreq_register_driver()
3051 pr_debug("driver %s up and running\n", driver_data->name); in cpufreq_register_driver()
3069 * cpufreq_unregister_driver - unregister the current CPUFreq driver
3073 * Returns zero if successful, and -EINVAL if the cpufreq_driver is
3083 pr_debug("unregistering driver %s\n", driver->name); in cpufreq_unregister_driver()
3107 return -ENODEV; in cpufreq_core_init()
3111 cpufreq_global_kobject = kobject_create_and_add("cpufreq", &dev_root->kobj); in cpufreq_core_init()
3117 strscpy(default_governor, gov->name, CPUFREQ_NAME_LEN); in cpufreq_core_init()