Lines Matching +full:turbo +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-only
34 #include <asm/intel-family.h>
51 #define ONE_EIGHTH_FP ((int64_t)1 << (FRAC_BITS - 3))
73 mask = (1 << FRAC_BITS) - 1; in ceiling_fp()
90 * struct sample - Store performance sample
117 * struct pstate_data - Store P state data
124 * @perf_ctl_scaling: PERF_CTL P-state to frequency scaling factor
126 * @turbo_pstate: Max Turbo P state possible for this platform
147 * struct vid_data - Stores voltage information data
151 * @turbo: VID data for turbo P state
152 * @ratio: Ratio of (vid max - vid min) /
153 * (max P state - Min P State)
162 int turbo; member
167 * struct global_params - Global parameters, mostly tunable via sysfs.
168 * @no_turbo: Whether or not to use turbo P-states.
169 * @turbo_disabled: Whether or not turbo P-states are available at all,
171 * not the maximum reported turbo P-state is different from
172 * the maximum reported non-turbo one.
174 * @min_perf_pct: Minimum capacity limit in percent of the maximum turbo
175 * P-state capacity.
176 * @max_perf_pct: Maximum capacity limit in percent of the maximum turbo
177 * P-state capacity.
188 * struct cpudata - Per CPU instance data storage
193 * @iowait_boost: iowait-related boost fraction
215 * @epp_cached Cached HWP energy-performance preference value
265 * struct pstate_funcs - Per CPU model specific callbacks
266 * @get_max: Callback to get maximum non turbo effective P state
267 * @get_max_physical: Callback to get maximum non turbo physical P state
269 * @get_turbo: Callback to get turbo P state
411 intel_pstate_set_itmt_prio(policy->cpu); in intel_pstate_init_acpi_perf_limits()
418 cpu = all_cpu_data[policy->cpu]; in intel_pstate_init_acpi_perf_limits()
420 ret = acpi_processor_register_performance(&cpu->acpi_perf_data, in intel_pstate_init_acpi_perf_limits()
421 policy->cpu); in intel_pstate_init_acpi_perf_limits()
430 if (cpu->acpi_perf_data.control_register.space_id != in intel_pstate_init_acpi_perf_limits()
438 if (cpu->acpi_perf_data.state_count < 2) in intel_pstate_init_acpi_perf_limits()
441 pr_debug("CPU%u - ACPI _PSS perf data\n", policy->cpu); in intel_pstate_init_acpi_perf_limits()
442 for (i = 0; i < cpu->acpi_perf_data.state_count; i++) { in intel_pstate_init_acpi_perf_limits()
444 (i == cpu->acpi_perf_data.state ? '*' : ' '), i, in intel_pstate_init_acpi_perf_limits()
445 (u32) cpu->acpi_perf_data.states[i].core_frequency, in intel_pstate_init_acpi_perf_limits()
446 (u32) cpu->acpi_perf_data.states[i].power, in intel_pstate_init_acpi_perf_limits()
447 (u32) cpu->acpi_perf_data.states[i].control); in intel_pstate_init_acpi_perf_limits()
451 * The _PSS table doesn't contain whole turbo frequency range. in intel_pstate_init_acpi_perf_limits()
452 * This just contains +1 MHZ above the max non turbo frequency, in intel_pstate_init_acpi_perf_limits()
453 * with control value corresponding to max turbo ratio. But in intel_pstate_init_acpi_perf_limits()
456 * this driver uses real max turbo frequency as the max in intel_pstate_init_acpi_perf_limits()
458 * correct max turbo frequency based on the turbo state. in intel_pstate_init_acpi_perf_limits()
462 cpu->acpi_perf_data.states[0].core_frequency = in intel_pstate_init_acpi_perf_limits()
463 policy->cpuinfo.max_freq / 1000; in intel_pstate_init_acpi_perf_limits()
464 cpu->valid_pss_table = true; in intel_pstate_init_acpi_perf_limits()
470 cpu->valid_pss_table = false; in intel_pstate_init_acpi_perf_limits()
471 acpi_processor_unregister_performance(policy->cpu); in intel_pstate_init_acpi_perf_limits()
478 cpu = all_cpu_data[policy->cpu]; in intel_pstate_exit_perf_limits()
479 if (!cpu->valid_pss_table) in intel_pstate_exit_perf_limits()
482 acpi_processor_unregister_performance(policy->cpu); in intel_pstate_exit_perf_limits()
502 return -ENOTSUPP; in intel_pstate_get_cppc_guaranteed()
507 * intel_pstate_hybrid_hwp_adjust - Calibrate HWP performance levels.
511 * P-states accessible through the PERF_CTL interface. If that happens, the
513 * than the scaling factor between P-state values and CPU frequency.
519 int perf_ctl_max_phys = cpu->pstate.max_pstate_physical; in intel_pstate_hybrid_hwp_adjust()
520 int perf_ctl_scaling = cpu->pstate.perf_ctl_scaling; in intel_pstate_hybrid_hwp_adjust()
523 int scaling = cpu->pstate.scaling; in intel_pstate_hybrid_hwp_adjust()
525 pr_debug("CPU%d: perf_ctl_max_phys = %d\n", cpu->cpu, perf_ctl_max_phys); in intel_pstate_hybrid_hwp_adjust()
526 pr_debug("CPU%d: perf_ctl_max = %d\n", cpu->cpu, pstate_funcs.get_max()); in intel_pstate_hybrid_hwp_adjust()
527 pr_debug("CPU%d: perf_ctl_turbo = %d\n", cpu->cpu, perf_ctl_turbo); in intel_pstate_hybrid_hwp_adjust()
528 pr_debug("CPU%d: perf_ctl_scaling = %d\n", cpu->cpu, perf_ctl_scaling); in intel_pstate_hybrid_hwp_adjust()
529 pr_debug("CPU%d: HWP_CAP guaranteed = %d\n", cpu->cpu, cpu->pstate.max_pstate); in intel_pstate_hybrid_hwp_adjust()
530 pr_debug("CPU%d: HWP_CAP highest = %d\n", cpu->cpu, cpu->pstate.turbo_pstate); in intel_pstate_hybrid_hwp_adjust()
531 pr_debug("CPU%d: HWP-to-frequency scaling factor: %d\n", cpu->cpu, scaling); in intel_pstate_hybrid_hwp_adjust()
535 * highest performance is greater than the maximum turbo frequency in intel_pstate_hybrid_hwp_adjust()
538 * highest performance correspond to the maximum turbo frequency. in intel_pstate_hybrid_hwp_adjust()
540 if (turbo_freq < cpu->pstate.turbo_pstate * scaling) { in intel_pstate_hybrid_hwp_adjust()
541 cpu->pstate.turbo_freq = turbo_freq; in intel_pstate_hybrid_hwp_adjust()
542 scaling = DIV_ROUND_UP(turbo_freq, cpu->pstate.turbo_pstate); in intel_pstate_hybrid_hwp_adjust()
543 cpu->pstate.scaling = scaling; in intel_pstate_hybrid_hwp_adjust()
545 pr_debug("CPU%d: refined HWP-to-frequency scaling factor: %d\n", in intel_pstate_hybrid_hwp_adjust()
546 cpu->cpu, scaling); in intel_pstate_hybrid_hwp_adjust()
549 cpu->pstate.max_freq = rounddown(cpu->pstate.max_pstate * scaling, in intel_pstate_hybrid_hwp_adjust()
552 cpu->pstate.max_pstate_physical = in intel_pstate_hybrid_hwp_adjust()
556 cpu->pstate.min_freq = cpu->pstate.min_pstate * perf_ctl_scaling; in intel_pstate_hybrid_hwp_adjust()
558 * Cast the min P-state value retrieved via pstate_funcs.get_min() to in intel_pstate_hybrid_hwp_adjust()
561 cpu->pstate.min_pstate = DIV_ROUND_UP(cpu->pstate.min_freq, scaling); in intel_pstate_hybrid_hwp_adjust()
573 cpu->pstate.max_pstate == cpu->pstate.turbo_pstate); in update_turbo_state()
579 int turbo_pstate = cpu->pstate.turbo_pstate; in min_perf_pct_min()
582 (cpu->pstate.min_pstate * 100 / turbo_pstate) : 0; in min_perf_pct_min()
591 return -ENXIO; in intel_pstate_get_epb()
593 ret = rdmsrl_on_cpu(cpu_data->cpu, MSR_IA32_ENERGY_PERF_BIAS, &epb); in intel_pstate_get_epb()
610 epp = rdmsrl_on_cpu(cpu_data->cpu, MSR_HWP_REQUEST, in intel_pstate_get_epp()
630 return -ENXIO; in intel_pstate_set_epb()
646 *-------------------------------------
671 int index = -EINVAL; in intel_pstate_get_energy_pref_index()
692 * 0x00-0x03 : Performance in intel_pstate_get_energy_pref_index()
693 * 0x04-0x07 : Balance performance in intel_pstate_get_energy_pref_index()
694 * 0x08-0x0B : Balance power in intel_pstate_get_energy_pref_index()
695 * 0x0C-0x0F : Power in intel_pstate_get_energy_pref_index()
711 * Use the cached HWP Request MSR value, because in the active mode the in intel_pstate_set_epp()
715 u64 value = READ_ONCE(cpu->hwp_req_cached); in intel_pstate_set_epp()
720 * The only other updater of hwp_req_cached in the active mode, in intel_pstate_set_epp()
724 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_pstate_set_epp()
725 ret = wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value); in intel_pstate_set_epp()
727 cpu->epp_cached = epp; in intel_pstate_set_epp()
736 int epp = -EINVAL; in intel_pstate_set_energy_pref_index()
740 epp = cpu_data->epp_default; in intel_pstate_set_energy_pref_index()
745 else if (epp == -EINVAL) in intel_pstate_set_energy_pref_index()
746 epp = epp_values[pref_index - 1]; in intel_pstate_set_energy_pref_index()
753 if (epp > 0 && cpu_data->policy == CPUFREQ_POLICY_PERFORMANCE) in intel_pstate_set_energy_pref_index()
754 return -EBUSY; in intel_pstate_set_energy_pref_index()
758 if (epp == -EINVAL) in intel_pstate_set_energy_pref_index()
759 epp = (pref_index - 1) << 2; in intel_pstate_set_energy_pref_index()
760 ret = intel_pstate_set_epb(cpu_data->cpu, epp); in intel_pstate_set_energy_pref_index()
787 struct cpudata *cpu = all_cpu_data[policy->cpu]; in store_energy_performance_preference()
795 return -EINVAL; in store_energy_performance_preference()
797 ret = match_string(energy_perf_strings, -1, str_preference); in store_energy_performance_preference()
807 return -EINVAL; in store_energy_performance_preference()
818 return -EAGAIN; in store_energy_performance_preference()
826 * In the passive mode the governor needs to be stopped on the in store_energy_performance_preference()
828 * which is super-heavy-weight, so make sure it is worth doing in store_energy_performance_preference()
832 epp = ret ? epp_values[ret - 1] : cpu->epp_default; in store_energy_performance_preference()
834 if (cpu->epp_cached != epp) { in store_energy_performance_preference()
853 struct cpudata *cpu_data = all_cpu_data[policy->cpu]; in show_energy_performance_preference()
870 struct cpudata *cpu = all_cpu_data[policy->cpu]; in show_base_frequency()
873 ratio = intel_pstate_get_cppc_guaranteed(policy->cpu); in show_base_frequency()
877 rdmsrl_on_cpu(policy->cpu, MSR_HWP_CAPABILITIES, &cap); in show_base_frequency()
881 freq = ratio * cpu->pstate.scaling; in show_base_frequency()
882 if (cpu->pstate.scaling != cpu->pstate.perf_ctl_scaling) in show_base_frequency()
883 freq = rounddown(freq, cpu->pstate.perf_ctl_scaling); in show_base_frequency()
901 rdmsrl_on_cpu(cpu->cpu, MSR_HWP_CAPABILITIES, &cap); in __intel_pstate_get_hwp_cap()
902 WRITE_ONCE(cpu->hwp_cap_cached, cap); in __intel_pstate_get_hwp_cap()
903 cpu->pstate.max_pstate = HWP_GUARANTEED_PERF(cap); in __intel_pstate_get_hwp_cap()
904 cpu->pstate.turbo_pstate = HWP_HIGHEST_PERF(cap); in __intel_pstate_get_hwp_cap()
909 int scaling = cpu->pstate.scaling; in intel_pstate_get_hwp_cap()
913 cpu->pstate.max_freq = cpu->pstate.max_pstate * scaling; in intel_pstate_get_hwp_cap()
914 cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * scaling; in intel_pstate_get_hwp_cap()
915 if (scaling != cpu->pstate.perf_ctl_scaling) { in intel_pstate_get_hwp_cap()
916 int perf_ctl_scaling = cpu->pstate.perf_ctl_scaling; in intel_pstate_get_hwp_cap()
918 cpu->pstate.max_freq = rounddown(cpu->pstate.max_freq, in intel_pstate_get_hwp_cap()
920 cpu->pstate.turbo_freq = rounddown(cpu->pstate.turbo_freq, in intel_pstate_get_hwp_cap()
932 max = cpu_data->max_perf_ratio; in intel_pstate_hwp_set()
933 min = cpu_data->min_perf_ratio; in intel_pstate_hwp_set()
935 if (cpu_data->policy == CPUFREQ_POLICY_PERFORMANCE) in intel_pstate_hwp_set()
946 if (cpu_data->epp_policy == cpu_data->policy) in intel_pstate_hwp_set()
949 cpu_data->epp_policy = cpu_data->policy; in intel_pstate_hwp_set()
951 if (cpu_data->policy == CPUFREQ_POLICY_PERFORMANCE) { in intel_pstate_hwp_set()
953 cpu_data->epp_powersave = epp; in intel_pstate_hwp_set()
961 if (cpu_data->epp_powersave < 0) in intel_pstate_hwp_set()
967 * - Policy is not changed in intel_pstate_hwp_set()
968 * - user has manually changed in intel_pstate_hwp_set()
969 * - Error reading EPB in intel_pstate_hwp_set()
975 epp = cpu_data->epp_powersave; in intel_pstate_hwp_set()
984 WRITE_ONCE(cpu_data->hwp_req_cached, value); in intel_pstate_hwp_set()
990 u64 value = READ_ONCE(cpu->hwp_req_cached); in intel_pstate_hwp_offline()
996 * active mode "performance" scaling algorithm, replace that in intel_pstate_hwp_offline()
1000 value |= HWP_ENERGY_PERF_PREFERENCE(cpu->epp_cached); in intel_pstate_hwp_offline()
1001 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_pstate_hwp_offline()
1005 min_perf = HWP_LOWEST_PERF(READ_ONCE(cpu->hwp_cap_cached)); in intel_pstate_hwp_offline()
1015 wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value); in intel_pstate_hwp_offline()
1045 wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, READ_ONCE(cpu->hwp_req_cached)); in intel_pstate_hwp_reenable()
1050 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_suspend()
1052 pr_debug("CPU %d suspending\n", cpu->cpu); in intel_pstate_suspend()
1054 cpu->suspended = true; in intel_pstate_suspend()
1061 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_resume()
1063 pr_debug("CPU %d resuming\n", cpu->cpu); in intel_pstate_resume()
1071 if (cpu->suspended && hwp_active) { in intel_pstate_resume()
1074 /* Re-enable HWP, because "online" has not done that. */ in intel_pstate_resume()
1080 cpu->suspended = false; in intel_pstate_resume()
1102 policy->cpuinfo.max_freq = global.turbo_disabled_mf ? in intel_pstate_update_max_freq()
1103 cpudata->pstate.max_freq : cpudata->pstate.turbo_freq; in intel_pstate_update_max_freq()
1116 * If turbo has been turned on or off globally, policy limits for in intel_pstate_update_limits()
1161 ret = intel_pstate_update_status(buf, p ? p - buf : count); in store_status()
1178 return -EAGAIN; in show_turbo_pct()
1183 total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate + 1; in show_turbo_pct()
1184 no_turbo = cpu->pstate.max_pstate - cpu->pstate.min_pstate + 1; in show_turbo_pct()
1186 turbo_pct = 100 - fp_toint(mul_fp(turbo_fp, int_tofp(100))); in show_turbo_pct()
1203 return -EAGAIN; in show_num_pstates()
1207 total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate + 1; in show_num_pstates()
1223 return -EAGAIN; in show_no_turbo()
1245 return -EINVAL; in store_no_turbo()
1251 return -EAGAIN; in store_no_turbo()
1258 pr_notice_once("Turbo disabled by BIOS or unavailable on processor\n"); in store_no_turbo()
1261 return -EPERM; in store_no_turbo()
1268 int pct = cpu->pstate.max_pstate * 100 / cpu->pstate.turbo_pstate; in store_no_turbo()
1298 req = policy->driver_data; in update_qos_request()
1314 freq = DIV_ROUND_UP(cpu->pstate.turbo_freq * perf_pct, 100); in update_qos_request()
1329 return -EINVAL; in store_max_perf_pct()
1335 return -EAGAIN; in store_max_perf_pct()
1362 return -EINVAL; in store_min_perf_pct()
1368 return -EAGAIN; in store_min_perf_pct()
1470 &cpu_subsys.dev_root->kobj); in intel_pstate_sysfs_expose_params()
1553 wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x00); in intel_pstate_hwp_enable()
1555 wrmsrl_on_cpu(cpudata->cpu, MSR_PM_ENABLE, 0x1); in intel_pstate_hwp_enable()
1556 if (cpudata->epp_default == -EINVAL) in intel_pstate_hwp_enable()
1557 cpudata->epp_default = intel_pstate_get_epp(cpudata, 0); in intel_pstate_hwp_enable()
1594 vid_fp = cpudata->vid.min + mul_fp( in atom_get_val()
1595 int_tofp(pstate - cpudata->pstate.min_pstate), in atom_get_val()
1596 cpudata->vid.ratio); in atom_get_val()
1598 vid_fp = clamp_t(int32_t, vid_fp, cpudata->vid.min, cpudata->vid.max); in atom_get_val()
1601 if (pstate > cpudata->pstate.max_pstate) in atom_get_val()
1602 vid = cpudata->vid.turbo; in atom_get_val()
1611 /* Defined in Table 35-6 from SDM (Sept 2015) */ in silvermont_get_scaling()
1626 /* Defined in Table 35-10 from SDM (Sept 2015) */ in airmont_get_scaling()
1643 cpudata->vid.min = int_tofp((value >> 8) & 0x7f); in atom_get_vid()
1644 cpudata->vid.max = int_tofp((value >> 16) & 0x7f); in atom_get_vid()
1645 cpudata->vid.ratio = div_fp( in atom_get_vid()
1646 cpudata->vid.max - cpudata->vid.min, in atom_get_vid()
1647 int_tofp(cpudata->pstate.max_pstate - in atom_get_vid()
1648 cpudata->pstate.min_pstate)); in atom_get_vid()
1651 cpudata->vid.turbo = value & 0x7f; in atom_get_vid()
1700 return -ENXIO; in core_get_tdp_ratio()
1719 /* Turbo activation ratio is not used on HWP platforms */ in core_get_max_pstate()
1729 if (tdp_ratio - 1 == tar_levels) { in core_get_max_pstate()
1819 trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu); in intel_pstate_set_pstate()
1820 cpu->pstate.current_pstate = pstate; in intel_pstate_set_pstate()
1826 wrmsrl_on_cpu(cpu->cpu, MSR_IA32_PERF_CTL, in intel_pstate_set_pstate()
1832 intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate); in intel_pstate_set_min_pstate()
1837 int pstate = max(cpu->pstate.min_pstate, cpu->max_perf_ratio); in intel_pstate_max_within_limits()
1848 cpu->pstate.min_pstate = pstate_funcs.get_min(); in intel_pstate_get_cpu_pstates()
1849 cpu->pstate.max_pstate_physical = perf_ctl_max_phys; in intel_pstate_get_cpu_pstates()
1850 cpu->pstate.perf_ctl_scaling = perf_ctl_scaling; in intel_pstate_get_cpu_pstates()
1856 cpu->pstate.scaling = pstate_funcs.get_cpu_scaling(cpu->cpu); in intel_pstate_get_cpu_pstates()
1857 if (cpu->pstate.scaling != perf_ctl_scaling) in intel_pstate_get_cpu_pstates()
1860 cpu->pstate.scaling = perf_ctl_scaling; in intel_pstate_get_cpu_pstates()
1863 cpu->pstate.scaling = perf_ctl_scaling; in intel_pstate_get_cpu_pstates()
1864 cpu->pstate.max_pstate = pstate_funcs.get_max(); in intel_pstate_get_cpu_pstates()
1865 cpu->pstate.turbo_pstate = pstate_funcs.get_turbo(); in intel_pstate_get_cpu_pstates()
1868 if (cpu->pstate.scaling == perf_ctl_scaling) { in intel_pstate_get_cpu_pstates()
1869 cpu->pstate.min_freq = cpu->pstate.min_pstate * perf_ctl_scaling; in intel_pstate_get_cpu_pstates()
1870 cpu->pstate.max_freq = cpu->pstate.max_pstate * perf_ctl_scaling; in intel_pstate_get_cpu_pstates()
1871 cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * perf_ctl_scaling; in intel_pstate_get_cpu_pstates()
1875 cpu->aperf_mperf_shift = pstate_funcs.get_aperf_mperf_shift(); in intel_pstate_get_cpu_pstates()
1893 u64 hwp_req = READ_ONCE(cpu->hwp_req_cached); in intel_pstate_hwp_boost_up()
1894 u64 hwp_cap = READ_ONCE(cpu->hwp_cap_cached); in intel_pstate_hwp_boost_up()
1901 * If, P0 (Turbo max) = P1 (Guaranteed max) = min: in intel_pstate_hwp_boost_up()
1903 * If, P0 (Turbo max) > P1 (Guaranteed max) = min: in intel_pstate_hwp_boost_up()
1905 * If, P0 (Turbo max) = P1 (Guaranteed max) > min: in intel_pstate_hwp_boost_up()
1908 * If, P0 (Turbo max) > P1 (Guaranteed max) > min: in intel_pstate_hwp_boost_up()
1914 if (max_limit == min_limit || cpu->hwp_boost_min >= max_limit) in intel_pstate_hwp_boost_up()
1917 if (!cpu->hwp_boost_min) in intel_pstate_hwp_boost_up()
1918 cpu->hwp_boost_min = min_limit; in intel_pstate_hwp_boost_up()
1923 if (cpu->hwp_boost_min < boost_level1) in intel_pstate_hwp_boost_up()
1924 cpu->hwp_boost_min = boost_level1; in intel_pstate_hwp_boost_up()
1925 else if (cpu->hwp_boost_min < HWP_GUARANTEED_PERF(hwp_cap)) in intel_pstate_hwp_boost_up()
1926 cpu->hwp_boost_min = HWP_GUARANTEED_PERF(hwp_cap); in intel_pstate_hwp_boost_up()
1927 else if (cpu->hwp_boost_min == HWP_GUARANTEED_PERF(hwp_cap) && in intel_pstate_hwp_boost_up()
1929 cpu->hwp_boost_min = max_limit; in intel_pstate_hwp_boost_up()
1933 hwp_req = (hwp_req & ~GENMASK_ULL(7, 0)) | cpu->hwp_boost_min; in intel_pstate_hwp_boost_up()
1935 cpu->last_update = cpu->sample.time; in intel_pstate_hwp_boost_up()
1940 if (cpu->hwp_boost_min) { in intel_pstate_hwp_boost_down()
1944 expired = time_after64(cpu->sample.time, cpu->last_update + in intel_pstate_hwp_boost_down()
1947 wrmsrl(MSR_HWP_REQUEST, cpu->hwp_req_cached); in intel_pstate_hwp_boost_down()
1948 cpu->hwp_boost_min = 0; in intel_pstate_hwp_boost_down()
1951 cpu->last_update = cpu->sample.time; in intel_pstate_hwp_boost_down()
1957 cpu->sample.time = time; in intel_pstate_update_util_hwp_local()
1959 if (cpu->sched_flags & SCHED_CPUFREQ_IOWAIT) { in intel_pstate_update_util_hwp_local()
1962 cpu->sched_flags = 0; in intel_pstate_update_util_hwp_local()
1970 if (time_before64(time, cpu->last_io_update + 2 * TICK_NSEC)) in intel_pstate_update_util_hwp_local()
1973 cpu->last_io_update = time; in intel_pstate_update_util_hwp_local()
1988 cpu->sched_flags |= flags; in intel_pstate_update_util_hwp()
1990 if (smp_processor_id() == cpu->cpu) in intel_pstate_update_util_hwp()
1996 struct sample *sample = &cpu->sample; in intel_pstate_calc_avg_perf()
1998 sample->core_avg_perf = div_ext_fp(sample->aperf, sample->mperf); in intel_pstate_calc_avg_perf()
2011 if (cpu->prev_mperf == mperf || cpu->prev_tsc == tsc) { in intel_pstate_sample()
2017 cpu->last_sample_time = cpu->sample.time; in intel_pstate_sample()
2018 cpu->sample.time = time; in intel_pstate_sample()
2019 cpu->sample.aperf = aperf; in intel_pstate_sample()
2020 cpu->sample.mperf = mperf; in intel_pstate_sample()
2021 cpu->sample.tsc = tsc; in intel_pstate_sample()
2022 cpu->sample.aperf -= cpu->prev_aperf; in intel_pstate_sample()
2023 cpu->sample.mperf -= cpu->prev_mperf; in intel_pstate_sample()
2024 cpu->sample.tsc -= cpu->prev_tsc; in intel_pstate_sample()
2026 cpu->prev_aperf = aperf; in intel_pstate_sample()
2027 cpu->prev_mperf = mperf; in intel_pstate_sample()
2028 cpu->prev_tsc = tsc; in intel_pstate_sample()
2036 if (cpu->last_sample_time) { in intel_pstate_sample()
2045 return mul_ext_fp(cpu->sample.core_avg_perf, cpu_khz); in get_avg_frequency()
2050 return mul_ext_fp(cpu->pstate.max_pstate_physical, in get_avg_pstate()
2051 cpu->sample.core_avg_perf); in get_avg_pstate()
2056 struct sample *sample = &cpu->sample; in get_target_pstate()
2060 busy_frac = div_fp(sample->mperf << cpu->aperf_mperf_shift, in get_target_pstate()
2061 sample->tsc); in get_target_pstate()
2063 if (busy_frac < cpu->iowait_boost) in get_target_pstate()
2064 busy_frac = cpu->iowait_boost; in get_target_pstate()
2066 sample->busy_scaled = busy_frac * 100; in get_target_pstate()
2069 cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; in get_target_pstate()
2072 if (target < cpu->pstate.min_pstate) in get_target_pstate()
2073 target = cpu->pstate.min_pstate; in get_target_pstate()
2076 * If the average P-state during the previous cycle was higher than the in get_target_pstate()
2084 target += (avg_pstate - target) >> 1; in get_target_pstate()
2091 int min_pstate = max(cpu->pstate.min_pstate, cpu->min_perf_ratio); in intel_pstate_prepare_request()
2092 int max_pstate = max(min_pstate, cpu->max_perf_ratio); in intel_pstate_prepare_request()
2099 if (pstate == cpu->pstate.current_pstate) in intel_pstate_update_pstate()
2102 cpu->pstate.current_pstate = pstate; in intel_pstate_update_pstate()
2108 int from = cpu->pstate.current_pstate; in intel_pstate_adjust_pstate()
2116 trace_cpu_frequency(target_pstate * cpu->pstate.scaling, cpu->cpu); in intel_pstate_adjust_pstate()
2119 sample = &cpu->sample; in intel_pstate_adjust_pstate()
2120 trace_pstate_sample(mul_ext_fp(100, sample->core_avg_perf), in intel_pstate_adjust_pstate()
2121 fp_toint(sample->busy_scaled), in intel_pstate_adjust_pstate()
2123 cpu->pstate.current_pstate, in intel_pstate_adjust_pstate()
2124 sample->mperf, in intel_pstate_adjust_pstate()
2125 sample->aperf, in intel_pstate_adjust_pstate()
2126 sample->tsc, in intel_pstate_adjust_pstate()
2128 fp_toint(cpu->iowait_boost * 100)); in intel_pstate_adjust_pstate()
2138 if (smp_processor_id() != cpu->cpu) in intel_pstate_update_util()
2141 delta_ns = time - cpu->last_update; in intel_pstate_update_util()
2145 cpu->iowait_boost = ONE_EIGHTH_FP; in intel_pstate_update_util()
2146 } else if (cpu->iowait_boost >= ONE_EIGHTH_FP) { in intel_pstate_update_util()
2147 cpu->iowait_boost <<= 1; in intel_pstate_update_util()
2148 if (cpu->iowait_boost > int_tofp(1)) in intel_pstate_update_util()
2149 cpu->iowait_boost = int_tofp(1); in intel_pstate_update_util()
2151 cpu->iowait_boost = ONE_EIGHTH_FP; in intel_pstate_update_util()
2153 } else if (cpu->iowait_boost) { in intel_pstate_update_util()
2156 cpu->iowait_boost = 0; in intel_pstate_update_util()
2158 cpu->iowait_boost >>= 1; in intel_pstate_update_util()
2160 cpu->last_update = time; in intel_pstate_update_util()
2161 delta_ns = time - cpu->sample.time; in intel_pstate_update_util()
2267 return -ENOMEM; in intel_pstate_init_cpu()
2271 cpu->cpu = cpunum; in intel_pstate_init_cpu()
2273 cpu->epp_default = -EINVAL; in intel_pstate_init_cpu()
2286 * Re-enable HWP in case this happens after a resume from ACPI in intel_pstate_init_cpu()
2293 cpu->epp_powersave = -EINVAL; in intel_pstate_init_cpu()
2294 cpu->epp_policy = 0; in intel_pstate_init_cpu()
2310 if (cpu->update_util_set) in intel_pstate_set_update_util_hook()
2314 cpu->sample.time = 0; in intel_pstate_set_update_util_hook()
2315 cpufreq_add_update_util_hook(cpu_num, &cpu->update_util, in intel_pstate_set_update_util_hook()
2319 cpu->update_util_set = true; in intel_pstate_set_update_util_hook()
2326 if (!cpu_data->update_util_set) in intel_pstate_clear_update_util_hook()
2330 cpu_data->update_util_set = false; in intel_pstate_clear_update_util_hook()
2337 cpu->pstate.max_freq : cpu->pstate.turbo_freq; in intel_pstate_get_max_freq()
2344 int perf_ctl_scaling = cpu->pstate.perf_ctl_scaling; in intel_pstate_update_perf_limits()
2363 if (cpu->pstate.scaling != perf_ctl_scaling) { in intel_pstate_update_perf_limits()
2364 int scaling = cpu->pstate.scaling; in intel_pstate_update_perf_limits()
2375 cpu->cpu, min_policy_perf, max_policy_perf); in intel_pstate_update_perf_limits()
2379 cpu->min_perf_ratio = min_policy_perf; in intel_pstate_update_perf_limits()
2380 cpu->max_perf_ratio = max_policy_perf; in intel_pstate_update_perf_limits()
2382 int turbo_max = cpu->pstate.turbo_pstate; in intel_pstate_update_perf_limits()
2385 /* Global limits are in percent of the maximum turbo P-state. */ in intel_pstate_update_perf_limits()
2390 pr_debug("cpu:%d global_min:%d global_max:%d\n", cpu->cpu, in intel_pstate_update_perf_limits()
2393 cpu->min_perf_ratio = max(min_policy_perf, global_min); in intel_pstate_update_perf_limits()
2394 cpu->min_perf_ratio = min(cpu->min_perf_ratio, max_policy_perf); in intel_pstate_update_perf_limits()
2395 cpu->max_perf_ratio = min(max_policy_perf, global_max); in intel_pstate_update_perf_limits()
2396 cpu->max_perf_ratio = max(min_policy_perf, cpu->max_perf_ratio); in intel_pstate_update_perf_limits()
2399 cpu->min_perf_ratio = min(cpu->min_perf_ratio, in intel_pstate_update_perf_limits()
2400 cpu->max_perf_ratio); in intel_pstate_update_perf_limits()
2403 pr_debug("cpu:%d max_perf_ratio:%d min_perf_ratio:%d\n", cpu->cpu, in intel_pstate_update_perf_limits()
2404 cpu->max_perf_ratio, in intel_pstate_update_perf_limits()
2405 cpu->min_perf_ratio); in intel_pstate_update_perf_limits()
2412 if (!policy->cpuinfo.max_freq) in intel_pstate_set_policy()
2413 return -ENODEV; in intel_pstate_set_policy()
2415 pr_debug("set_policy cpuinfo.max %u policy->max %u\n", in intel_pstate_set_policy()
2416 policy->cpuinfo.max_freq, policy->max); in intel_pstate_set_policy()
2418 cpu = all_cpu_data[policy->cpu]; in intel_pstate_set_policy()
2419 cpu->policy = policy->policy; in intel_pstate_set_policy()
2423 intel_pstate_update_perf_limits(cpu, policy->min, policy->max); in intel_pstate_set_policy()
2425 if (cpu->policy == CPUFREQ_POLICY_PERFORMANCE) { in intel_pstate_set_policy()
2430 intel_pstate_clear_update_util_hook(policy->cpu); in intel_pstate_set_policy()
2433 intel_pstate_set_update_util_hook(policy->cpu); in intel_pstate_set_policy()
2443 intel_pstate_clear_update_util_hook(policy->cpu); in intel_pstate_set_policy()
2444 intel_pstate_hwp_set(policy->cpu); in intel_pstate_set_policy()
2456 cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate && in intel_pstate_adjust_policy_max()
2457 policy->max < policy->cpuinfo.max_freq && in intel_pstate_adjust_policy_max()
2458 policy->max > cpu->pstate.max_freq) { in intel_pstate_adjust_policy_max()
2459 pr_debug("policy->max > max non turbo frequency\n"); in intel_pstate_adjust_policy_max()
2460 policy->max = policy->cpuinfo.max_freq; in intel_pstate_adjust_policy_max()
2473 cpu->pstate.max_freq : cpu->pstate.turbo_freq; in intel_pstate_verify_cpu_policy()
2477 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, max_freq); in intel_pstate_verify_cpu_policy()
2484 intel_pstate_verify_cpu_policy(all_cpu_data[policy->cpu], policy); in intel_pstate_verify_policy()
2491 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_cpu_offline()
2493 pr_debug("CPU %d going offline\n", cpu->cpu); in intel_cpufreq_cpu_offline()
2495 if (cpu->suspended) in intel_cpufreq_cpu_offline()
2516 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_cpu_online()
2518 pr_debug("CPU %d going online\n", cpu->cpu); in intel_pstate_cpu_online()
2524 * Re-enable HWP and clear the "suspended" flag to let "resume" in intel_pstate_cpu_online()
2528 cpu->suspended = false; in intel_pstate_cpu_online()
2536 intel_pstate_clear_update_util_hook(policy->cpu); in intel_pstate_cpu_offline()
2543 pr_debug("CPU %d exiting\n", policy->cpu); in intel_pstate_cpu_exit()
2545 policy->fast_switch_possible = false; in intel_pstate_cpu_exit()
2555 rc = intel_pstate_init_cpu(policy->cpu); in __intel_pstate_cpu_init()
2559 cpu = all_cpu_data[policy->cpu]; in __intel_pstate_cpu_init()
2561 cpu->max_perf_ratio = 0xFF; in __intel_pstate_cpu_init()
2562 cpu->min_perf_ratio = 0; in __intel_pstate_cpu_init()
2565 policy->cpuinfo.min_freq = cpu->pstate.min_freq; in __intel_pstate_cpu_init()
2568 policy->cpuinfo.max_freq = global.turbo_disabled ? in __intel_pstate_cpu_init()
2569 cpu->pstate.max_freq : cpu->pstate.turbo_freq; in __intel_pstate_cpu_init()
2571 policy->min = policy->cpuinfo.min_freq; in __intel_pstate_cpu_init()
2572 policy->max = policy->cpuinfo.max_freq; in __intel_pstate_cpu_init()
2576 policy->fast_switch_possible = true; in __intel_pstate_cpu_init()
2592 policy->policy = CPUFREQ_POLICY_POWERSAVE; in intel_pstate_cpu_init()
2595 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_cpu_init()
2597 cpu->epp_cached = intel_pstate_get_epp(cpu, 0); in intel_pstate_cpu_init()
2619 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_verify_policy()
2622 intel_pstate_update_perf_limits(cpu, policy->min, policy->max); in intel_cpufreq_verify_policy()
2627 /* Use of trace in passive mode:
2629 * In passive mode the trace core_busy field (also known as the
2631 * core_avg_perf) is not needed and so is re-assigned to indicate if the
2634 * (or performance or core_avg_perf) have a fixed y-axis from 0 to 100%,
2653 sample = &cpu->sample; in intel_cpufreq_trace()
2657 cpu->pstate.current_pstate, in intel_cpufreq_trace()
2658 sample->mperf, in intel_cpufreq_trace()
2659 sample->aperf, in intel_cpufreq_trace()
2660 sample->tsc, in intel_cpufreq_trace()
2662 fp_toint(cpu->iowait_boost * 100)); in intel_cpufreq_trace()
2668 u64 prev = READ_ONCE(cpu->hwp_req_cached), value = prev; in intel_cpufreq_hwp_update()
2682 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_cpufreq_hwp_update()
2686 wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value); in intel_cpufreq_hwp_update()
2696 wrmsrl_on_cpu(cpu->cpu, MSR_IA32_PERF_CTL, in intel_cpufreq_perf_ctl_update()
2703 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_update_pstate()
2704 int old_pstate = cpu->pstate.current_pstate; in intel_cpufreq_update_pstate()
2708 int max_pstate = policy->strict_target ? in intel_cpufreq_update_pstate()
2709 target_pstate : cpu->max_perf_ratio; in intel_cpufreq_update_pstate()
2717 cpu->pstate.current_pstate = target_pstate; in intel_cpufreq_update_pstate()
2729 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_target()
2735 freqs.old = policy->cur; in intel_cpufreq_target()
2742 target_pstate = DIV_ROUND_UP(freqs.new, cpu->pstate.scaling); in intel_cpufreq_target()
2745 target_pstate = freqs.new / cpu->pstate.scaling; in intel_cpufreq_target()
2748 target_pstate = DIV_ROUND_CLOSEST(freqs.new, cpu->pstate.scaling); in intel_cpufreq_target()
2754 freqs.new = target_pstate * cpu->pstate.scaling; in intel_cpufreq_target()
2764 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_fast_switch()
2769 target_pstate = DIV_ROUND_UP(target_freq, cpu->pstate.scaling); in intel_cpufreq_fast_switch()
2773 return target_pstate * cpu->pstate.scaling; in intel_cpufreq_fast_switch()
2782 u64 hwp_cap = READ_ONCE(cpu->hwp_cap_cached); in intel_cpufreq_adjust_perf()
2783 int old_pstate = cpu->pstate.current_pstate; in intel_cpufreq_adjust_perf()
2800 if (min_pstate < cpu->pstate.min_pstate) in intel_cpufreq_adjust_perf()
2801 min_pstate = cpu->pstate.min_pstate; in intel_cpufreq_adjust_perf()
2803 if (min_pstate < cpu->min_perf_ratio) in intel_cpufreq_adjust_perf()
2804 min_pstate = cpu->min_perf_ratio; in intel_cpufreq_adjust_perf()
2806 max_pstate = min(cap_pstate, cpu->max_perf_ratio); in intel_cpufreq_adjust_perf()
2814 cpu->pstate.current_pstate = target_pstate; in intel_cpufreq_adjust_perf()
2825 dev = get_cpu_device(policy->cpu); in intel_cpufreq_cpu_init()
2827 return -ENODEV; in intel_cpufreq_cpu_init()
2833 policy->cpuinfo.transition_latency = INTEL_CPUFREQ_TRANSITION_LATENCY; in intel_cpufreq_cpu_init()
2835 policy->cur = policy->cpuinfo.min_freq; in intel_cpufreq_cpu_init()
2839 ret = -ENOMEM; in intel_cpufreq_cpu_init()
2843 cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_cpu_init()
2848 policy->transition_delay_us = INTEL_CPUFREQ_TRANSITION_DELAY_HWP; in intel_cpufreq_cpu_init()
2852 rdmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, &value); in intel_cpufreq_cpu_init()
2853 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_cpufreq_cpu_init()
2855 cpu->epp_cached = intel_pstate_get_epp(cpu, value); in intel_cpufreq_cpu_init()
2857 policy->transition_delay_us = INTEL_CPUFREQ_TRANSITION_DELAY; in intel_cpufreq_cpu_init()
2860 freq = DIV_ROUND_UP(cpu->pstate.turbo_freq * global.min_perf_pct, 100); in intel_cpufreq_cpu_init()
2862 ret = freq_qos_add_request(&policy->constraints, req, FREQ_QOS_MIN, in intel_cpufreq_cpu_init()
2865 dev_err(dev, "Failed to add min-freq constraint (%d)\n", ret); in intel_cpufreq_cpu_init()
2869 freq = DIV_ROUND_UP(cpu->pstate.turbo_freq * global.max_perf_pct, 100); in intel_cpufreq_cpu_init()
2871 ret = freq_qos_add_request(&policy->constraints, req + 1, FREQ_QOS_MAX, in intel_cpufreq_cpu_init()
2874 dev_err(dev, "Failed to add max-freq constraint (%d)\n", ret); in intel_cpufreq_cpu_init()
2878 policy->driver_data = req; in intel_cpufreq_cpu_init()
2896 req = policy->driver_data; in intel_cpufreq_cpu_exit()
2976 return -EINVAL; in intel_pstate_update_status()
2979 return -EBUSY; in intel_pstate_update_status()
3009 return -EINVAL; in intel_pstate_update_status()
3022 return -ENODEV; in intel_pstate_msrs_not_valid()
3029 pstate_funcs.get_max = funcs->get_max; in copy_cpu_funcs()
3030 pstate_funcs.get_max_physical = funcs->get_max_physical; in copy_cpu_funcs()
3031 pstate_funcs.get_min = funcs->get_min; in copy_cpu_funcs()
3032 pstate_funcs.get_turbo = funcs->get_turbo; in copy_cpu_funcs()
3033 pstate_funcs.get_scaling = funcs->get_scaling; in copy_cpu_funcs()
3034 pstate_funcs.get_val = funcs->get_val; in copy_cpu_funcs()
3035 pstate_funcs.get_vid = funcs->get_vid; in copy_cpu_funcs()
3036 pstate_funcs.get_aperf_mperf_shift = funcs->get_aperf_mperf_shift; in copy_cpu_funcs()
3054 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer); in intel_pstate_no_acpi_pss()
3059 if (pss && pss->type == ACPI_TYPE_PACKAGE) { in intel_pstate_no_acpi_pss()
3097 if (acpi_has_method(pr->handle, "_PPC")) in intel_pstate_has_acpi_ppc()
3109 /* Hardware vendor-specific info that has its own power management modes */
3112 {"ORACLE", "X4-2 ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
3113 {"ORACLE", "X4-2L ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
3114 {"ORACLE", "X4-2B ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
3115 {"ORACLE", "X3-2 ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
3116 {"ORACLE", "X3-2L ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
3117 {"ORACLE", "X3-2B ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
3124 {"ORACLE", "X6-2 ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
3142 pr_debug("P states are controlled in Out of Band mode by the firmware/hardware\n"); in intel_pstate_platform_pwr_mgmt_exists()
3167 * It may be unsafe to request P-states control from SMM if _PPC support in intel_pstate_request_control_from_smm()
3206 return -ENODEV; in intel_pstate_init()
3215 return -ENODEV; in intel_pstate_init()
3228 hwp_mode_bdw = id->driver_data; in intel_pstate_init()
3244 return -ENODEV; in intel_pstate_init()
3249 return -ENODEV; in intel_pstate_init()
3252 copy_cpu_funcs((struct pstate_funcs *)id->driver_data); in intel_pstate_init()
3257 return -ENODEV; in intel_pstate_init()
3259 /* Without HWP start in the passive mode. */ in intel_pstate_init()
3269 pr_info("P-states controlled by the platform\n"); in intel_pstate_init()
3270 return -ENODEV; in intel_pstate_init()
3274 return -ENOTSUPP; in intel_pstate_init()
3276 pr_info("Intel P-state driver initializing\n"); in intel_pstate_init()
3280 return -ENOMEM; in intel_pstate_init()
3315 return -EINVAL; in intel_pstate_setup()
3344 MODULE_DESCRIPTION("'intel_pstate' - P state driver Intel Core processors");