Lines Matching +full:min +full:- +full:sample +full:- +full:time
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()
100 * struct sample - Store performance sample
102 * performance during last sample period
107 * read from APERF MSR between last and current sample
109 * read from MPERF MSR between last and current sample
110 * @tsc: Difference of time stamp counter between last and
111 * current sample
112 * @time: Current time from scheduler
114 * This structure is used in the cpudata structure to store performance sample
117 struct sample { struct
123 u64 time; member
127 * struct pstate_data - Store P state data
129 * @min_pstate: Min P state possible for this platform
154 * struct vid_data - Stores voltage information data
155 * @min: VID data for this platform corresponding to
159 * @ratio: Ratio of (vid max - vid min) /
160 * (max P state - Min P State)
167 int min; member
174 * struct global_params - Global parameters, mostly tunable via sysfs.
175 * @no_turbo: Whether or not to use turbo P-states.
176 * @turbo_disabled: Whether or not turbo P-states are available at all,
178 * not the maximum reported turbo P-state is different from
179 * the maximum reported non-turbo one.
182 * P-state capacity.
184 * P-state capacity.
195 * struct cpudata - Per CPU instance data storage
200 * @iowait_boost: iowait-related boost fraction
201 * @last_update: Time of the last update.
204 * @last_sample_time: Last Sample time
209 * @prev_cummulative_iowait: IO Wait time difference from last and
210 * current sample
211 * @sample: Storage for storing last Sample data
222 * @epp_cached Cached HWP energy-performance preference value
225 * @last_io_update: Last time when IO wake flag was set
227 * @hwp_boost_min: Last HWP boosted min performance
249 struct sample sample; member
272 * struct pstate_funcs - Per CPU model specific callbacks
356 * update them at any time after it has been called. in intel_pstate_set_itmt_prio()
407 intel_pstate_set_itmt_prio(policy->cpu); in intel_pstate_init_acpi_perf_limits()
414 cpu = all_cpu_data[policy->cpu]; in intel_pstate_init_acpi_perf_limits()
416 ret = acpi_processor_register_performance(&cpu->acpi_perf_data, in intel_pstate_init_acpi_perf_limits()
417 policy->cpu); in intel_pstate_init_acpi_perf_limits()
426 if (cpu->acpi_perf_data.control_register.space_id != in intel_pstate_init_acpi_perf_limits()
434 if (cpu->acpi_perf_data.state_count < 2) in intel_pstate_init_acpi_perf_limits()
437 pr_debug("CPU%u - ACPI _PSS perf data\n", policy->cpu); in intel_pstate_init_acpi_perf_limits()
438 for (i = 0; i < cpu->acpi_perf_data.state_count; i++) { in intel_pstate_init_acpi_perf_limits()
440 (i == cpu->acpi_perf_data.state ? '*' : ' '), i, in intel_pstate_init_acpi_perf_limits()
441 (u32) cpu->acpi_perf_data.states[i].core_frequency, in intel_pstate_init_acpi_perf_limits()
442 (u32) cpu->acpi_perf_data.states[i].power, in intel_pstate_init_acpi_perf_limits()
443 (u32) cpu->acpi_perf_data.states[i].control); in intel_pstate_init_acpi_perf_limits()
458 cpu->acpi_perf_data.states[0].core_frequency = in intel_pstate_init_acpi_perf_limits()
459 policy->cpuinfo.max_freq / 1000; in intel_pstate_init_acpi_perf_limits()
460 cpu->valid_pss_table = true; in intel_pstate_init_acpi_perf_limits()
466 cpu->valid_pss_table = false; in intel_pstate_init_acpi_perf_limits()
467 acpi_processor_unregister_performance(policy->cpu); in intel_pstate_init_acpi_perf_limits()
474 cpu = all_cpu_data[policy->cpu]; in intel_pstate_exit_perf_limits()
475 if (!cpu->valid_pss_table) in intel_pstate_exit_perf_limits()
478 acpi_processor_unregister_performance(policy->cpu); in intel_pstate_exit_perf_limits()
498 return -ENOTSUPP; in intel_pstate_get_cppc_guranteed()
511 cpu->pstate.max_pstate == cpu->pstate.turbo_pstate); in update_turbo_state()
517 int turbo_pstate = cpu->pstate.turbo_pstate; in min_perf_pct_min()
520 (cpu->pstate.min_pstate * 100 / turbo_pstate) : 0; in min_perf_pct_min()
529 return -ENXIO; in intel_pstate_get_epb()
531 ret = rdmsrl_on_cpu(cpu_data->cpu, MSR_IA32_ENERGY_PERF_BIAS, &epb); in intel_pstate_get_epb()
548 epp = rdmsrl_on_cpu(cpu_data->cpu, MSR_HWP_REQUEST, in intel_pstate_get_epp()
568 return -ENXIO; in intel_pstate_set_epb()
584 *-------------------------------------
609 int index = -EINVAL; in intel_pstate_get_energy_pref_index()
630 * 0x00-0x03 : Performance in intel_pstate_get_energy_pref_index()
631 * 0x04-0x07 : Balance performance in intel_pstate_get_energy_pref_index()
632 * 0x08-0x0B : Balance power in intel_pstate_get_energy_pref_index()
633 * 0x0C-0x0F : Power in intel_pstate_get_energy_pref_index()
651 * intel_pstate_hwp_boost_down() at any time. in intel_pstate_set_epp()
653 u64 value = READ_ONCE(cpu->hwp_req_cached); in intel_pstate_set_epp()
662 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_pstate_set_epp()
663 ret = wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value); in intel_pstate_set_epp()
665 cpu->epp_cached = epp; in intel_pstate_set_epp()
674 int epp = -EINVAL; in intel_pstate_set_energy_pref_index()
678 epp = cpu_data->epp_default; in intel_pstate_set_energy_pref_index()
683 else if (epp == -EINVAL) in intel_pstate_set_energy_pref_index()
684 epp = epp_values[pref_index - 1]; in intel_pstate_set_energy_pref_index()
691 if (epp > 0 && cpu_data->policy == CPUFREQ_POLICY_PERFORMANCE) in intel_pstate_set_energy_pref_index()
692 return -EBUSY; in intel_pstate_set_energy_pref_index()
696 if (epp == -EINVAL) in intel_pstate_set_energy_pref_index()
697 epp = (pref_index - 1) << 2; in intel_pstate_set_energy_pref_index()
698 ret = intel_pstate_set_epb(cpu_data->cpu, epp); in intel_pstate_set_energy_pref_index()
725 struct cpudata *cpu = all_cpu_data[policy->cpu]; in store_energy_performance_preference()
733 return -EINVAL; in store_energy_performance_preference()
735 ret = match_string(energy_perf_strings, -1, str_preference); in store_energy_performance_preference()
745 return -EINVAL; in store_energy_performance_preference()
756 return -EAGAIN; in store_energy_performance_preference()
766 * which is super-heavy-weight, so make sure it is worth doing in store_energy_performance_preference()
770 epp = ret ? epp_values[ret - 1] : cpu->epp_default; in store_energy_performance_preference()
772 if (cpu->epp_cached != epp) { in store_energy_performance_preference()
791 struct cpudata *cpu_data = all_cpu_data[policy->cpu]; in show_energy_performance_preference()
812 ratio = intel_pstate_get_cppc_guranteed(policy->cpu); in show_base_frequency()
814 rdmsrl_on_cpu(policy->cpu, MSR_HWP_CAPABILITIES, &cap); in show_base_frequency()
818 cpu = all_cpu_data[policy->cpu]; in show_base_frequency()
820 return sprintf(buf, "%d\n", ratio * cpu->pstate.scaling); in show_base_frequency()
837 rdmsrl_on_cpu(cpu->cpu, MSR_HWP_CAPABILITIES, &cap); in intel_pstate_get_hwp_max()
838 WRITE_ONCE(cpu->hwp_cap_cached, cap); in intel_pstate_get_hwp_max()
850 int max, min; in intel_pstate_hwp_set() local
854 max = cpu_data->max_perf_ratio; in intel_pstate_hwp_set()
855 min = cpu_data->min_perf_ratio; in intel_pstate_hwp_set()
857 if (cpu_data->policy == CPUFREQ_POLICY_PERFORMANCE) in intel_pstate_hwp_set()
858 min = max; in intel_pstate_hwp_set()
863 value |= HWP_MIN_PERF(min); in intel_pstate_hwp_set()
868 if (cpu_data->epp_policy == cpu_data->policy) in intel_pstate_hwp_set()
871 cpu_data->epp_policy = cpu_data->policy; in intel_pstate_hwp_set()
873 if (cpu_data->policy == CPUFREQ_POLICY_PERFORMANCE) { in intel_pstate_hwp_set()
875 cpu_data->epp_powersave = epp; in intel_pstate_hwp_set()
883 if (cpu_data->epp_powersave < 0) in intel_pstate_hwp_set()
889 * - Policy is not changed in intel_pstate_hwp_set()
890 * - user has manually changed in intel_pstate_hwp_set()
891 * - Error reading EPB in intel_pstate_hwp_set()
897 epp = cpu_data->epp_powersave; in intel_pstate_hwp_set()
906 WRITE_ONCE(cpu_data->hwp_req_cached, value); in intel_pstate_hwp_set()
912 u64 value = READ_ONCE(cpu->hwp_req_cached); in intel_pstate_hwp_offline()
922 value |= HWP_ENERGY_PERF_PREFERENCE(cpu->epp_cached); in intel_pstate_hwp_offline()
923 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_pstate_hwp_offline()
927 min_perf = HWP_LOWEST_PERF(cpu->hwp_cap_cached); in intel_pstate_hwp_offline()
933 /* Set EPP to min */ in intel_pstate_hwp_offline()
937 wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value); in intel_pstate_hwp_offline()
967 wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, READ_ONCE(cpu->hwp_req_cached)); in intel_pstate_hwp_reenable()
972 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_suspend()
974 pr_debug("CPU %d suspending\n", cpu->cpu); in intel_pstate_suspend()
976 cpu->suspended = true; in intel_pstate_suspend()
983 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_resume()
985 pr_debug("CPU %d resuming\n", cpu->cpu); in intel_pstate_resume()
993 if (cpu->suspended && hwp_active) { in intel_pstate_resume()
996 /* Re-enable HWP, because "online" has not done that. */ in intel_pstate_resume()
1002 cpu->suspended = false; in intel_pstate_resume()
1024 policy->cpuinfo.max_freq = global.turbo_disabled_mf ? in intel_pstate_update_max_freq()
1025 cpudata->pstate.max_freq : cpudata->pstate.turbo_freq; in intel_pstate_update_max_freq()
1083 ret = intel_pstate_update_status(buf, p ? p - buf : count); in store_status()
1100 return -EAGAIN; in show_turbo_pct()
1105 total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate + 1; in show_turbo_pct()
1106 no_turbo = cpu->pstate.max_pstate - cpu->pstate.min_pstate + 1; in show_turbo_pct()
1108 turbo_pct = 100 - fp_toint(mul_fp(turbo_fp, int_tofp(100))); in show_turbo_pct()
1125 return -EAGAIN; in show_num_pstates()
1129 total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate + 1; in show_num_pstates()
1145 return -EAGAIN; in show_no_turbo()
1167 return -EINVAL; in store_no_turbo()
1173 return -EAGAIN; in store_no_turbo()
1183 return -EPERM; in store_no_turbo()
1190 int pct = cpu->pstate.max_pstate * 100 / cpu->pstate.turbo_pstate; in store_no_turbo()
1219 req = policy->driver_data; in update_qos_request()
1228 turbo_max = cpu->pstate.turbo_pstate; in update_qos_request()
1238 freq *= cpu->pstate.scaling; in update_qos_request()
1253 return -EINVAL; in store_max_perf_pct()
1259 return -EAGAIN; in store_max_perf_pct()
1286 return -EINVAL; in store_min_perf_pct()
1292 return -EAGAIN; in store_min_perf_pct()
1396 &cpu_subsys.dev_root->kobj); in intel_pstate_sysfs_expose_params()
1466 wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x00); in intel_pstate_hwp_enable()
1468 wrmsrl_on_cpu(cpudata->cpu, MSR_PM_ENABLE, 0x1); in intel_pstate_hwp_enable()
1469 if (cpudata->epp_default == -EINVAL) in intel_pstate_hwp_enable()
1470 cpudata->epp_default = intel_pstate_get_epp(cpudata, 0); in intel_pstate_hwp_enable()
1507 vid_fp = cpudata->vid.min + mul_fp( in atom_get_val()
1508 int_tofp(pstate - cpudata->pstate.min_pstate), in atom_get_val()
1509 cpudata->vid.ratio); in atom_get_val()
1511 vid_fp = clamp_t(int32_t, vid_fp, cpudata->vid.min, cpudata->vid.max); in atom_get_val()
1514 if (pstate > cpudata->pstate.max_pstate) in atom_get_val()
1515 vid = cpudata->vid.turbo; in atom_get_val()
1524 /* Defined in Table 35-6 from SDM (Sept 2015) */ in silvermont_get_scaling()
1539 /* Defined in Table 35-10 from SDM (Sept 2015) */ in airmont_get_scaling()
1556 cpudata->vid.min = int_tofp((value >> 8) & 0x7f); in atom_get_vid()
1557 cpudata->vid.max = int_tofp((value >> 16) & 0x7f); in atom_get_vid()
1558 cpudata->vid.ratio = div_fp( in atom_get_vid()
1559 cpudata->vid.max - cpudata->vid.min, in atom_get_vid()
1560 int_tofp(cpudata->pstate.max_pstate - in atom_get_vid()
1561 cpudata->pstate.min_pstate)); in atom_get_vid()
1564 cpudata->vid.turbo = value & 0x7f; in atom_get_vid()
1613 return -ENXIO; in core_get_tdp_ratio()
1642 if (tdp_ratio - 1 == tar_levels) { in core_get_max_pstate()
1700 trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu); in intel_pstate_set_pstate()
1701 cpu->pstate.current_pstate = pstate; in intel_pstate_set_pstate()
1707 wrmsrl_on_cpu(cpu->cpu, MSR_IA32_PERF_CTL, in intel_pstate_set_pstate()
1713 intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate); in intel_pstate_set_min_pstate()
1718 int pstate = max(cpu->pstate.min_pstate, cpu->max_perf_ratio); in intel_pstate_max_within_limits()
1726 cpu->pstate.min_pstate = pstate_funcs.get_min(); in intel_pstate_get_cpu_pstates()
1727 cpu->pstate.max_pstate_physical = pstate_funcs.get_max_physical(); in intel_pstate_get_cpu_pstates()
1728 cpu->pstate.turbo_pstate = pstate_funcs.get_turbo(); in intel_pstate_get_cpu_pstates()
1729 cpu->pstate.scaling = pstate_funcs.get_scaling(); in intel_pstate_get_cpu_pstates()
1735 cpu->pstate.turbo_freq = phy_max * cpu->pstate.scaling; in intel_pstate_get_cpu_pstates()
1736 cpu->pstate.turbo_pstate = phy_max; in intel_pstate_get_cpu_pstates()
1737 cpu->pstate.max_pstate = HWP_GUARANTEED_PERF(READ_ONCE(cpu->hwp_cap_cached)); in intel_pstate_get_cpu_pstates()
1739 cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * cpu->pstate.scaling; in intel_pstate_get_cpu_pstates()
1740 cpu->pstate.max_pstate = pstate_funcs.get_max(); in intel_pstate_get_cpu_pstates()
1742 cpu->pstate.max_freq = cpu->pstate.max_pstate * cpu->pstate.scaling; in intel_pstate_get_cpu_pstates()
1745 cpu->aperf_mperf_shift = pstate_funcs.get_aperf_mperf_shift(); in intel_pstate_get_cpu_pstates()
1754 * Long hold time will keep high perf limits for long time,
1763 u64 hwp_req = READ_ONCE(cpu->hwp_req_cached); in intel_pstate_hwp_boost_up()
1769 * Cases to consider (User changes via sysfs or boot time): in intel_pstate_hwp_boost_up()
1770 * If, P0 (Turbo max) = P1 (Guaranteed max) = min: in intel_pstate_hwp_boost_up()
1772 * If, P0 (Turbo max) > P1 (Guaranteed max) = min: in intel_pstate_hwp_boost_up()
1774 * If, P0 (Turbo max) = P1 (Guaranteed max) > min: in intel_pstate_hwp_boost_up()
1776 * (min + p1)/2 and P1. in intel_pstate_hwp_boost_up()
1777 * If, P0 (Turbo max) > P1 (Guaranteed max) > min: in intel_pstate_hwp_boost_up()
1779 * (min + p1)/2, P1 and P0. in intel_pstate_hwp_boost_up()
1782 /* If max and min are equal or already at max, nothing to boost */ in intel_pstate_hwp_boost_up()
1783 if (max_limit == min_limit || cpu->hwp_boost_min >= max_limit) in intel_pstate_hwp_boost_up()
1786 if (!cpu->hwp_boost_min) in intel_pstate_hwp_boost_up()
1787 cpu->hwp_boost_min = min_limit; in intel_pstate_hwp_boost_up()
1789 /* level at half way mark between min and guranteed */ in intel_pstate_hwp_boost_up()
1790 boost_level1 = (HWP_GUARANTEED_PERF(cpu->hwp_cap_cached) + min_limit) >> 1; in intel_pstate_hwp_boost_up()
1792 if (cpu->hwp_boost_min < boost_level1) in intel_pstate_hwp_boost_up()
1793 cpu->hwp_boost_min = boost_level1; in intel_pstate_hwp_boost_up()
1794 else if (cpu->hwp_boost_min < HWP_GUARANTEED_PERF(cpu->hwp_cap_cached)) in intel_pstate_hwp_boost_up()
1795 cpu->hwp_boost_min = HWP_GUARANTEED_PERF(cpu->hwp_cap_cached); in intel_pstate_hwp_boost_up()
1796 else if (cpu->hwp_boost_min == HWP_GUARANTEED_PERF(cpu->hwp_cap_cached) && in intel_pstate_hwp_boost_up()
1797 max_limit != HWP_GUARANTEED_PERF(cpu->hwp_cap_cached)) in intel_pstate_hwp_boost_up()
1798 cpu->hwp_boost_min = max_limit; in intel_pstate_hwp_boost_up()
1802 hwp_req = (hwp_req & ~GENMASK_ULL(7, 0)) | cpu->hwp_boost_min; in intel_pstate_hwp_boost_up()
1804 cpu->last_update = cpu->sample.time; in intel_pstate_hwp_boost_up()
1809 if (cpu->hwp_boost_min) { in intel_pstate_hwp_boost_down()
1812 /* Check if we are idle for hold time to boost down */ in intel_pstate_hwp_boost_down()
1813 expired = time_after64(cpu->sample.time, cpu->last_update + in intel_pstate_hwp_boost_down()
1816 wrmsrl(MSR_HWP_REQUEST, cpu->hwp_req_cached); in intel_pstate_hwp_boost_down()
1817 cpu->hwp_boost_min = 0; in intel_pstate_hwp_boost_down()
1820 cpu->last_update = cpu->sample.time; in intel_pstate_hwp_boost_down()
1824 u64 time) in intel_pstate_update_util_hwp_local() argument
1826 cpu->sample.time = time; in intel_pstate_update_util_hwp_local()
1828 if (cpu->sched_flags & SCHED_CPUFREQ_IOWAIT) { in intel_pstate_update_util_hwp_local()
1831 cpu->sched_flags = 0; in intel_pstate_update_util_hwp_local()
1833 * Set iowait_boost flag and update time. Since IO WAIT flag in intel_pstate_update_util_hwp_local()
1834 * is set all the time, we can't just conclude that there is in intel_pstate_update_util_hwp_local()
1839 if (time_before64(time, cpu->last_io_update + 2 * TICK_NSEC)) in intel_pstate_update_util_hwp_local()
1842 cpu->last_io_update = time; in intel_pstate_update_util_hwp_local()
1853 u64 time, unsigned int flags) in intel_pstate_update_util_hwp() argument
1857 cpu->sched_flags |= flags; in intel_pstate_update_util_hwp()
1859 if (smp_processor_id() == cpu->cpu) in intel_pstate_update_util_hwp()
1860 intel_pstate_update_util_hwp_local(cpu, time); in intel_pstate_update_util_hwp()
1865 struct sample *sample = &cpu->sample; in intel_pstate_calc_avg_perf() local
1867 sample->core_avg_perf = div_ext_fp(sample->aperf, sample->mperf); in intel_pstate_calc_avg_perf()
1870 static inline bool intel_pstate_sample(struct cpudata *cpu, u64 time) in intel_pstate_sample() argument
1880 if (cpu->prev_mperf == mperf || cpu->prev_tsc == tsc) { in intel_pstate_sample()
1886 cpu->last_sample_time = cpu->sample.time; in intel_pstate_sample()
1887 cpu->sample.time = time; in intel_pstate_sample()
1888 cpu->sample.aperf = aperf; in intel_pstate_sample()
1889 cpu->sample.mperf = mperf; in intel_pstate_sample()
1890 cpu->sample.tsc = tsc; in intel_pstate_sample()
1891 cpu->sample.aperf -= cpu->prev_aperf; in intel_pstate_sample()
1892 cpu->sample.mperf -= cpu->prev_mperf; in intel_pstate_sample()
1893 cpu->sample.tsc -= cpu->prev_tsc; in intel_pstate_sample()
1895 cpu->prev_aperf = aperf; in intel_pstate_sample()
1896 cpu->prev_mperf = mperf; in intel_pstate_sample()
1897 cpu->prev_tsc = tsc; in intel_pstate_sample()
1899 * First time this function is invoked in a given cycle, all of the in intel_pstate_sample()
1900 * previous sample data fields are equal to zero or stale and they must in intel_pstate_sample()
1902 * that sample.time will always be reset before setting the utilization in intel_pstate_sample()
1903 * update hook and make the caller skip the sample then. in intel_pstate_sample()
1905 if (cpu->last_sample_time) { in intel_pstate_sample()
1914 return mul_ext_fp(cpu->sample.core_avg_perf, cpu_khz); in get_avg_frequency()
1919 return mul_ext_fp(cpu->pstate.max_pstate_physical, in get_avg_pstate()
1920 cpu->sample.core_avg_perf); in get_avg_pstate()
1925 struct sample *sample = &cpu->sample; in get_target_pstate() local
1929 busy_frac = div_fp(sample->mperf << cpu->aperf_mperf_shift, in get_target_pstate()
1930 sample->tsc); in get_target_pstate()
1932 if (busy_frac < cpu->iowait_boost) in get_target_pstate()
1933 busy_frac = cpu->iowait_boost; in get_target_pstate()
1935 sample->busy_scaled = busy_frac * 100; in get_target_pstate()
1938 cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; in get_target_pstate()
1941 if (target < cpu->pstate.min_pstate) in get_target_pstate()
1942 target = cpu->pstate.min_pstate; in get_target_pstate()
1945 * If the average P-state during the previous cycle was higher than the in get_target_pstate()
1953 target += (avg_pstate - target) >> 1; in get_target_pstate()
1960 int min_pstate = max(cpu->pstate.min_pstate, cpu->min_perf_ratio); in intel_pstate_prepare_request()
1961 int max_pstate = max(min_pstate, cpu->max_perf_ratio); in intel_pstate_prepare_request()
1968 if (pstate == cpu->pstate.current_pstate) in intel_pstate_update_pstate()
1971 cpu->pstate.current_pstate = pstate; in intel_pstate_update_pstate()
1977 int from = cpu->pstate.current_pstate; in intel_pstate_adjust_pstate()
1978 struct sample *sample; in intel_pstate_adjust_pstate() local
1985 trace_cpu_frequency(target_pstate * cpu->pstate.scaling, cpu->cpu); in intel_pstate_adjust_pstate()
1988 sample = &cpu->sample; in intel_pstate_adjust_pstate()
1989 trace_pstate_sample(mul_ext_fp(100, sample->core_avg_perf), in intel_pstate_adjust_pstate()
1990 fp_toint(sample->busy_scaled), in intel_pstate_adjust_pstate()
1992 cpu->pstate.current_pstate, in intel_pstate_adjust_pstate()
1993 sample->mperf, in intel_pstate_adjust_pstate()
1994 sample->aperf, in intel_pstate_adjust_pstate()
1995 sample->tsc, in intel_pstate_adjust_pstate()
1997 fp_toint(cpu->iowait_boost * 100)); in intel_pstate_adjust_pstate()
2000 static void intel_pstate_update_util(struct update_util_data *data, u64 time, in intel_pstate_update_util() argument
2007 if (smp_processor_id() != cpu->cpu) in intel_pstate_update_util()
2010 delta_ns = time - cpu->last_update; in intel_pstate_update_util()
2014 cpu->iowait_boost = ONE_EIGHTH_FP; in intel_pstate_update_util()
2015 } else if (cpu->iowait_boost >= ONE_EIGHTH_FP) { in intel_pstate_update_util()
2016 cpu->iowait_boost <<= 1; in intel_pstate_update_util()
2017 if (cpu->iowait_boost > int_tofp(1)) in intel_pstate_update_util()
2018 cpu->iowait_boost = int_tofp(1); in intel_pstate_update_util()
2020 cpu->iowait_boost = ONE_EIGHTH_FP; in intel_pstate_update_util()
2022 } else if (cpu->iowait_boost) { in intel_pstate_update_util()
2025 cpu->iowait_boost = 0; in intel_pstate_update_util()
2027 cpu->iowait_boost >>= 1; in intel_pstate_update_util()
2029 cpu->last_update = time; in intel_pstate_update_util()
2030 delta_ns = time - cpu->sample.time; in intel_pstate_update_util()
2034 if (intel_pstate_sample(cpu, time)) in intel_pstate_update_util()
2134 return -ENOMEM; in intel_pstate_init_cpu()
2138 cpu->cpu = cpunum; in intel_pstate_init_cpu()
2140 cpu->epp_default = -EINVAL; in intel_pstate_init_cpu()
2153 * Re-enable HWP in case this happens after a resume from ACPI in intel_pstate_init_cpu()
2160 cpu->epp_powersave = -EINVAL; in intel_pstate_init_cpu()
2161 cpu->epp_policy = 0; in intel_pstate_init_cpu()
2177 if (cpu->update_util_set) in intel_pstate_set_update_util_hook()
2181 cpu->sample.time = 0; in intel_pstate_set_update_util_hook()
2182 cpufreq_add_update_util_hook(cpu_num, &cpu->update_util, in intel_pstate_set_update_util_hook()
2186 cpu->update_util_set = true; in intel_pstate_set_update_util_hook()
2193 if (!cpu_data->update_util_set) in intel_pstate_clear_update_util_hook()
2197 cpu_data->update_util_set = false; in intel_pstate_clear_update_util_hook()
2204 cpu->pstate.max_freq : cpu->pstate.turbo_freq; in intel_pstate_get_max_freq()
2224 cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; in intel_pstate_update_perf_limits()
2225 turbo_max = cpu->pstate.turbo_pstate; in intel_pstate_update_perf_limits()
2227 max_freq = max_state * cpu->pstate.scaling; in intel_pstate_update_perf_limits()
2239 cpu->cpu, max_state, min_policy_perf, max_policy_perf); in intel_pstate_update_perf_limits()
2243 cpu->min_perf_ratio = min_policy_perf; in intel_pstate_update_perf_limits()
2244 cpu->max_perf_ratio = max_policy_perf; in intel_pstate_update_perf_limits()
2248 /* Global limits are in percent of the maximum turbo P-state. */ in intel_pstate_update_perf_limits()
2253 pr_debug("cpu:%d global_min:%d global_max:%d\n", cpu->cpu, in intel_pstate_update_perf_limits()
2256 cpu->min_perf_ratio = max(min_policy_perf, global_min); in intel_pstate_update_perf_limits()
2257 cpu->min_perf_ratio = min(cpu->min_perf_ratio, max_policy_perf); in intel_pstate_update_perf_limits()
2258 cpu->max_perf_ratio = min(max_policy_perf, global_max); in intel_pstate_update_perf_limits()
2259 cpu->max_perf_ratio = max(min_policy_perf, cpu->max_perf_ratio); in intel_pstate_update_perf_limits()
2262 cpu->min_perf_ratio = min(cpu->min_perf_ratio, in intel_pstate_update_perf_limits()
2263 cpu->max_perf_ratio); in intel_pstate_update_perf_limits()
2266 pr_debug("cpu:%d max_perf_ratio:%d min_perf_ratio:%d\n", cpu->cpu, in intel_pstate_update_perf_limits()
2267 cpu->max_perf_ratio, in intel_pstate_update_perf_limits()
2268 cpu->min_perf_ratio); in intel_pstate_update_perf_limits()
2275 if (!policy->cpuinfo.max_freq) in intel_pstate_set_policy()
2276 return -ENODEV; in intel_pstate_set_policy()
2278 pr_debug("set_policy cpuinfo.max %u policy->max %u\n", in intel_pstate_set_policy()
2279 policy->cpuinfo.max_freq, policy->max); in intel_pstate_set_policy()
2281 cpu = all_cpu_data[policy->cpu]; in intel_pstate_set_policy()
2282 cpu->policy = policy->policy; in intel_pstate_set_policy()
2286 intel_pstate_update_perf_limits(cpu, policy->min, policy->max); in intel_pstate_set_policy()
2288 if (cpu->policy == CPUFREQ_POLICY_PERFORMANCE) { in intel_pstate_set_policy()
2293 intel_pstate_clear_update_util_hook(policy->cpu); in intel_pstate_set_policy()
2296 intel_pstate_set_update_util_hook(policy->cpu); in intel_pstate_set_policy()
2306 intel_pstate_clear_update_util_hook(policy->cpu); in intel_pstate_set_policy()
2307 intel_pstate_hwp_set(policy->cpu); in intel_pstate_set_policy()
2319 cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate && in intel_pstate_adjust_policy_max()
2320 policy->max < policy->cpuinfo.max_freq && in intel_pstate_adjust_policy_max()
2321 policy->max > cpu->pstate.max_freq) { in intel_pstate_adjust_policy_max()
2322 pr_debug("policy->max > max non turbo frequency\n"); in intel_pstate_adjust_policy_max()
2323 policy->max = policy->cpuinfo.max_freq; in intel_pstate_adjust_policy_max()
2337 max_freq = max_state * cpu->pstate.scaling; in intel_pstate_verify_cpu_policy()
2341 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, max_freq); in intel_pstate_verify_cpu_policy()
2348 intel_pstate_verify_cpu_policy(all_cpu_data[policy->cpu], policy); in intel_pstate_verify_policy()
2355 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_cpu_offline()
2357 pr_debug("CPU %d going offline\n", cpu->cpu); in intel_pstate_cpu_offline()
2359 if (cpu->suspended) in intel_pstate_cpu_offline()
2380 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_cpu_online()
2382 pr_debug("CPU %d going online\n", cpu->cpu); in intel_pstate_cpu_online()
2388 * Re-enable HWP and clear the "suspended" flag to let "resume" in intel_pstate_cpu_online()
2392 cpu->suspended = false; in intel_pstate_cpu_online()
2400 pr_debug("CPU %d stopping\n", policy->cpu); in intel_pstate_stop_cpu()
2402 intel_pstate_clear_update_util_hook(policy->cpu); in intel_pstate_stop_cpu()
2407 pr_debug("CPU %d exiting\n", policy->cpu); in intel_pstate_cpu_exit()
2409 policy->fast_switch_possible = false; in intel_pstate_cpu_exit()
2419 rc = intel_pstate_init_cpu(policy->cpu); in __intel_pstate_cpu_init()
2423 cpu = all_cpu_data[policy->cpu]; in __intel_pstate_cpu_init()
2425 cpu->max_perf_ratio = 0xFF; in __intel_pstate_cpu_init()
2426 cpu->min_perf_ratio = 0; in __intel_pstate_cpu_init()
2428 policy->min = cpu->pstate.min_pstate * cpu->pstate.scaling; in __intel_pstate_cpu_init()
2429 policy->max = cpu->pstate.turbo_pstate * cpu->pstate.scaling; in __intel_pstate_cpu_init()
2432 policy->cpuinfo.min_freq = cpu->pstate.min_pstate * cpu->pstate.scaling; in __intel_pstate_cpu_init()
2435 policy->cpuinfo.max_freq = global.turbo_disabled ? in __intel_pstate_cpu_init()
2436 cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; in __intel_pstate_cpu_init()
2437 policy->cpuinfo.max_freq *= cpu->pstate.scaling; in __intel_pstate_cpu_init()
2443 cpu->pstate.max_freq : cpu->pstate.turbo_freq; in __intel_pstate_cpu_init()
2444 if (max_freq < policy->cpuinfo.max_freq) in __intel_pstate_cpu_init()
2445 policy->cpuinfo.max_freq = max_freq; in __intel_pstate_cpu_init()
2450 policy->fast_switch_possible = true; in __intel_pstate_cpu_init()
2466 policy->policy = CPUFREQ_POLICY_POWERSAVE; in intel_pstate_cpu_init()
2469 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_cpu_init()
2471 cpu->epp_cached = intel_pstate_get_epp(cpu, 0); in intel_pstate_cpu_init()
2494 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_verify_policy()
2497 intel_pstate_update_perf_limits(cpu, policy->min, policy->max); in intel_cpufreq_verify_policy()
2506 * core_avg_perf) is not needed and so is re-assigned to indicate if the
2509 * (or performance or core_avg_perf) have a fixed y-axis from 0 to 100%,
2520 struct sample *sample; in intel_cpufreq_trace() local
2528 sample = &cpu->sample; in intel_cpufreq_trace()
2532 cpu->pstate.current_pstate, in intel_cpufreq_trace()
2533 sample->mperf, in intel_cpufreq_trace()
2534 sample->aperf, in intel_cpufreq_trace()
2535 sample->tsc, in intel_cpufreq_trace()
2537 fp_toint(cpu->iowait_boost * 100)); in intel_cpufreq_trace()
2543 u64 prev = READ_ONCE(cpu->hwp_req_cached), value = prev; in intel_cpufreq_adjust_hwp()
2549 * The entire MSR needs to be updated in order to update the HWP min in intel_cpufreq_adjust_hwp()
2553 value |= HWP_MAX_PERF(strict ? target_pstate : cpu->max_perf_ratio); in intel_cpufreq_adjust_hwp()
2558 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_cpufreq_adjust_hwp()
2562 wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value); in intel_cpufreq_adjust_hwp()
2572 wrmsrl_on_cpu(cpu->cpu, MSR_IA32_PERF_CTL, in intel_cpufreq_adjust_perf_ctl()
2579 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_update_pstate()
2580 int old_pstate = cpu->pstate.current_pstate; in intel_cpufreq_update_pstate()
2585 policy->strict_target, fast_switch); in intel_cpufreq_update_pstate()
2586 cpu->pstate.current_pstate = target_pstate; in intel_cpufreq_update_pstate()
2589 cpu->pstate.current_pstate = target_pstate; in intel_cpufreq_update_pstate()
2602 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_target()
2608 freqs.old = policy->cur; in intel_cpufreq_target()
2615 target_pstate = DIV_ROUND_UP(freqs.new, cpu->pstate.scaling); in intel_cpufreq_target()
2618 target_pstate = freqs.new / cpu->pstate.scaling; in intel_cpufreq_target()
2621 target_pstate = DIV_ROUND_CLOSEST(freqs.new, cpu->pstate.scaling); in intel_cpufreq_target()
2627 freqs.new = target_pstate * cpu->pstate.scaling; in intel_cpufreq_target()
2637 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_fast_switch()
2642 target_pstate = DIV_ROUND_UP(target_freq, cpu->pstate.scaling); in intel_cpufreq_fast_switch()
2646 return target_pstate * cpu->pstate.scaling; in intel_cpufreq_fast_switch()
2656 dev = get_cpu_device(policy->cpu); in intel_cpufreq_cpu_init()
2658 return -ENODEV; in intel_cpufreq_cpu_init()
2664 policy->cpuinfo.transition_latency = INTEL_CPUFREQ_TRANSITION_LATENCY; in intel_cpufreq_cpu_init()
2666 policy->cur = policy->cpuinfo.min_freq; in intel_cpufreq_cpu_init()
2670 ret = -ENOMEM; in intel_cpufreq_cpu_init()
2674 cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_cpu_init()
2680 policy->transition_delay_us = INTEL_CPUFREQ_TRANSITION_DELAY_HWP; in intel_cpufreq_cpu_init()
2681 rdmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, &value); in intel_cpufreq_cpu_init()
2682 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_cpufreq_cpu_init()
2683 cpu->epp_cached = intel_pstate_get_epp(cpu, value); in intel_cpufreq_cpu_init()
2685 turbo_max = cpu->pstate.turbo_pstate; in intel_cpufreq_cpu_init()
2686 policy->transition_delay_us = INTEL_CPUFREQ_TRANSITION_DELAY; in intel_cpufreq_cpu_init()
2690 min_freq *= cpu->pstate.scaling; in intel_cpufreq_cpu_init()
2692 max_freq *= cpu->pstate.scaling; in intel_cpufreq_cpu_init()
2694 ret = freq_qos_add_request(&policy->constraints, req, FREQ_QOS_MIN, in intel_cpufreq_cpu_init()
2697 dev_err(dev, "Failed to add min-freq constraint (%d)\n", ret); in intel_cpufreq_cpu_init()
2701 ret = freq_qos_add_request(&policy->constraints, req + 1, FREQ_QOS_MAX, in intel_cpufreq_cpu_init()
2704 dev_err(dev, "Failed to add max-freq constraint (%d)\n", ret); in intel_cpufreq_cpu_init()
2708 policy->driver_data = req; in intel_cpufreq_cpu_init()
2726 req = policy->driver_data; in intel_cpufreq_cpu_exit()
2806 return -EINVAL; in intel_pstate_update_status()
2809 return -EBUSY; in intel_pstate_update_status()
2839 return -EINVAL; in intel_pstate_update_status()
2852 return -ENODEV; in intel_pstate_msrs_not_valid()
2859 pstate_funcs.get_max = funcs->get_max; in copy_cpu_funcs()
2860 pstate_funcs.get_max_physical = funcs->get_max_physical; in copy_cpu_funcs()
2861 pstate_funcs.get_min = funcs->get_min; in copy_cpu_funcs()
2862 pstate_funcs.get_turbo = funcs->get_turbo; in copy_cpu_funcs()
2863 pstate_funcs.get_scaling = funcs->get_scaling; in copy_cpu_funcs()
2864 pstate_funcs.get_val = funcs->get_val; in copy_cpu_funcs()
2865 pstate_funcs.get_vid = funcs->get_vid; in copy_cpu_funcs()
2866 pstate_funcs.get_aperf_mperf_shift = funcs->get_aperf_mperf_shift; in copy_cpu_funcs()
2884 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer); in intel_pstate_no_acpi_pss()
2889 if (pss && pss->type == ACPI_TYPE_PACKAGE) { in intel_pstate_no_acpi_pss()
2927 if (acpi_has_method(pr->handle, "_PPC")) in intel_pstate_has_acpi_ppc()
2939 /* Hardware vendor-specific info that has its own power management modes */
2942 {"ORACLE", "X4-2 ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
2943 {"ORACLE", "X4-2L ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
2944 {"ORACLE", "X4-2B ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
2945 {"ORACLE", "X3-2 ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
2946 {"ORACLE", "X3-2L ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
2947 {"ORACLE", "X3-2B ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
2954 {"ORACLE", "X6-2 ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
2997 * It may be unsafe to request P-states control from SMM if _PPC support in intel_pstate_request_control_from_smm()
3036 return -ENODEV; in intel_pstate_init()
3045 return -ENODEV; in intel_pstate_init()
3058 hwp_mode_bdw = id->driver_data; in intel_pstate_init()
3070 return -ENODEV; in intel_pstate_init()
3075 return -ENODEV; in intel_pstate_init()
3078 copy_cpu_funcs((struct pstate_funcs *)id->driver_data); in intel_pstate_init()
3083 return -ENODEV; in intel_pstate_init()
3095 pr_info("P-states controlled by the platform\n"); in intel_pstate_init()
3096 return -ENODEV; in intel_pstate_init()
3100 return -ENOTSUPP; in intel_pstate_init()
3102 pr_info("Intel P-state driver initializing\n"); in intel_pstate_init()
3106 return -ENOMEM; in intel_pstate_init()
3139 return -EINVAL; in intel_pstate_setup()
3168 MODULE_DESCRIPTION("'intel_pstate' - P state driver Intel Core processors");