• Home
  • Raw
  • Download

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()
446 cpu->valid_pss_table = true; in intel_pstate_init_acpi_perf_limits()
452 cpu->valid_pss_table = false; in intel_pstate_init_acpi_perf_limits()
453 acpi_processor_unregister_performance(policy->cpu); in intel_pstate_init_acpi_perf_limits()
460 cpu = all_cpu_data[policy->cpu]; in intel_pstate_exit_perf_limits()
461 if (!cpu->valid_pss_table) in intel_pstate_exit_perf_limits()
464 acpi_processor_unregister_performance(policy->cpu); in intel_pstate_exit_perf_limits()
484 return -ENOTSUPP; in intel_pstate_get_cppc_guranteed()
497 cpu->pstate.max_pstate == cpu->pstate.turbo_pstate); in update_turbo_state()
503 int turbo_pstate = cpu->pstate.turbo_pstate; in min_perf_pct_min()
506 (cpu->pstate.min_pstate * 100 / turbo_pstate) : 0; in min_perf_pct_min()
515 return -ENXIO; in intel_pstate_get_epb()
517 ret = rdmsrl_on_cpu(cpu_data->cpu, MSR_IA32_ENERGY_PERF_BIAS, &epb); in intel_pstate_get_epb()
534 epp = rdmsrl_on_cpu(cpu_data->cpu, MSR_HWP_REQUEST, in intel_pstate_get_epp()
554 return -ENXIO; in intel_pstate_set_epb()
570 *-------------------------------------
595 int index = -EINVAL; in intel_pstate_get_energy_pref_index()
616 * 0x00-0x03 : Performance in intel_pstate_get_energy_pref_index()
617 * 0x04-0x07 : Balance performance in intel_pstate_get_energy_pref_index()
618 * 0x08-0x0B : Balance power in intel_pstate_get_energy_pref_index()
619 * 0x0C-0x0F : Power in intel_pstate_get_energy_pref_index()
637 * intel_pstate_hwp_boost_down() at any time. in intel_pstate_set_epp()
639 u64 value = READ_ONCE(cpu->hwp_req_cached); in intel_pstate_set_epp()
648 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_pstate_set_epp()
649 ret = wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value); in intel_pstate_set_epp()
651 cpu->epp_cached = epp; in intel_pstate_set_epp()
660 int epp = -EINVAL; in intel_pstate_set_energy_pref_index()
664 epp = cpu_data->epp_default; in intel_pstate_set_energy_pref_index()
669 else if (epp == -EINVAL) in intel_pstate_set_energy_pref_index()
670 epp = epp_values[pref_index - 1]; in intel_pstate_set_energy_pref_index()
677 if (epp > 0 && cpu_data->policy == CPUFREQ_POLICY_PERFORMANCE) in intel_pstate_set_energy_pref_index()
678 return -EBUSY; in intel_pstate_set_energy_pref_index()
682 if (epp == -EINVAL) in intel_pstate_set_energy_pref_index()
683 epp = (pref_index - 1) << 2; in intel_pstate_set_energy_pref_index()
684 ret = intel_pstate_set_epb(cpu_data->cpu, epp); in intel_pstate_set_energy_pref_index()
711 struct cpudata *cpu = all_cpu_data[policy->cpu]; in store_energy_performance_preference()
719 return -EINVAL; in store_energy_performance_preference()
721 ret = match_string(energy_perf_strings, -1, str_preference); in store_energy_performance_preference()
731 return -EINVAL; in store_energy_performance_preference()
742 return -EAGAIN; in store_energy_performance_preference()
752 * which is super-heavy-weight, so make sure it is worth doing in store_energy_performance_preference()
756 epp = ret ? epp_values[ret - 1] : cpu->epp_default; in store_energy_performance_preference()
758 if (cpu->epp_cached != epp) { in store_energy_performance_preference()
779 struct cpudata *cpu_data = all_cpu_data[policy->cpu]; in show_energy_performance_preference()
800 ratio = intel_pstate_get_cppc_guranteed(policy->cpu); in show_base_frequency()
802 rdmsrl_on_cpu(policy->cpu, MSR_HWP_CAPABILITIES, &cap); in show_base_frequency()
806 cpu = all_cpu_data[policy->cpu]; in show_base_frequency()
808 return sprintf(buf, "%d\n", ratio * cpu->pstate.scaling); in show_base_frequency()
825 rdmsrl_on_cpu(cpu->cpu, MSR_HWP_CAPABILITIES, &cap); in intel_pstate_get_hwp_max()
826 WRITE_ONCE(cpu->hwp_cap_cached, cap); in intel_pstate_get_hwp_max()
838 int max, min; in intel_pstate_hwp_set() local
842 max = cpu_data->max_perf_ratio; in intel_pstate_hwp_set()
843 min = cpu_data->min_perf_ratio; in intel_pstate_hwp_set()
845 if (cpu_data->policy == CPUFREQ_POLICY_PERFORMANCE) in intel_pstate_hwp_set()
846 min = max; in intel_pstate_hwp_set()
851 value |= HWP_MIN_PERF(min); in intel_pstate_hwp_set()
856 if (cpu_data->epp_policy == cpu_data->policy) in intel_pstate_hwp_set()
859 cpu_data->epp_policy = cpu_data->policy; in intel_pstate_hwp_set()
861 if (cpu_data->policy == CPUFREQ_POLICY_PERFORMANCE) { in intel_pstate_hwp_set()
863 cpu_data->epp_powersave = epp; in intel_pstate_hwp_set()
871 if (cpu_data->epp_powersave < 0) in intel_pstate_hwp_set()
877 * - Policy is not changed in intel_pstate_hwp_set()
878 * - user has manually changed in intel_pstate_hwp_set()
879 * - Error reading EPB in intel_pstate_hwp_set()
885 epp = cpu_data->epp_powersave; in intel_pstate_hwp_set()
894 WRITE_ONCE(cpu_data->hwp_req_cached, value); in intel_pstate_hwp_set()
900 u64 value = READ_ONCE(cpu->hwp_req_cached); in intel_pstate_hwp_offline()
910 value |= HWP_ENERGY_PERF_PREFERENCE(cpu->epp_cached); in intel_pstate_hwp_offline()
911 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_pstate_hwp_offline()
915 min_perf = HWP_LOWEST_PERF(cpu->hwp_cap_cached); in intel_pstate_hwp_offline()
921 /* Set EPP to min */ in intel_pstate_hwp_offline()
925 wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value); in intel_pstate_hwp_offline()
955 wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, READ_ONCE(cpu->hwp_req_cached)); in intel_pstate_hwp_reenable()
960 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_suspend()
962 pr_debug("CPU %d suspending\n", cpu->cpu); in intel_pstate_suspend()
964 cpu->suspended = true; in intel_pstate_suspend()
971 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_resume()
973 pr_debug("CPU %d resuming\n", cpu->cpu); in intel_pstate_resume()
981 if (cpu->suspended && hwp_active) { in intel_pstate_resume()
984 /* Re-enable HWP, because "online" has not done that. */ in intel_pstate_resume()
990 cpu->suspended = false; in intel_pstate_resume()
1012 policy->cpuinfo.max_freq = global.turbo_disabled_mf ? in intel_pstate_update_max_freq()
1013 cpudata->pstate.max_freq : cpudata->pstate.turbo_freq; in intel_pstate_update_max_freq()
1071 ret = intel_pstate_update_status(buf, p ? p - buf : count); in store_status()
1088 return -EAGAIN; in show_turbo_pct()
1093 total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate + 1; in show_turbo_pct()
1094 no_turbo = cpu->pstate.max_pstate - cpu->pstate.min_pstate + 1; in show_turbo_pct()
1096 turbo_pct = 100 - fp_toint(mul_fp(turbo_fp, int_tofp(100))); in show_turbo_pct()
1113 return -EAGAIN; in show_num_pstates()
1117 total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate + 1; in show_num_pstates()
1133 return -EAGAIN; in show_no_turbo()
1155 return -EINVAL; in store_no_turbo()
1161 return -EAGAIN; in store_no_turbo()
1171 return -EPERM; in store_no_turbo()
1178 int pct = cpu->pstate.max_pstate * 100 / cpu->pstate.turbo_pstate; in store_no_turbo()
1207 req = policy->driver_data; in update_qos_request()
1216 turbo_max = cpu->pstate.turbo_pstate; in update_qos_request()
1226 freq *= cpu->pstate.scaling; in update_qos_request()
1241 return -EINVAL; in store_max_perf_pct()
1247 return -EAGAIN; in store_max_perf_pct()
1274 return -EINVAL; in store_min_perf_pct()
1280 return -EAGAIN; in store_min_perf_pct()
1384 &cpu_subsys.dev_root->kobj); in intel_pstate_sysfs_expose_params()
1454 wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x00); in intel_pstate_hwp_enable()
1456 wrmsrl_on_cpu(cpudata->cpu, MSR_PM_ENABLE, 0x1); in intel_pstate_hwp_enable()
1457 if (cpudata->epp_default == -EINVAL) in intel_pstate_hwp_enable()
1458 cpudata->epp_default = intel_pstate_get_epp(cpudata, 0); in intel_pstate_hwp_enable()
1495 vid_fp = cpudata->vid.min + mul_fp( in atom_get_val()
1496 int_tofp(pstate - cpudata->pstate.min_pstate), in atom_get_val()
1497 cpudata->vid.ratio); in atom_get_val()
1499 vid_fp = clamp_t(int32_t, vid_fp, cpudata->vid.min, cpudata->vid.max); in atom_get_val()
1502 if (pstate > cpudata->pstate.max_pstate) in atom_get_val()
1503 vid = cpudata->vid.turbo; in atom_get_val()
1512 /* Defined in Table 35-6 from SDM (Sept 2015) */ in silvermont_get_scaling()
1527 /* Defined in Table 35-10 from SDM (Sept 2015) */ in airmont_get_scaling()
1544 cpudata->vid.min = int_tofp((value >> 8) & 0x7f); in atom_get_vid()
1545 cpudata->vid.max = int_tofp((value >> 16) & 0x7f); in atom_get_vid()
1546 cpudata->vid.ratio = div_fp( in atom_get_vid()
1547 cpudata->vid.max - cpudata->vid.min, in atom_get_vid()
1548 int_tofp(cpudata->pstate.max_pstate - in atom_get_vid()
1549 cpudata->pstate.min_pstate)); in atom_get_vid()
1552 cpudata->vid.turbo = value & 0x7f; in atom_get_vid()
1601 return -ENXIO; in core_get_tdp_ratio()
1630 if (tdp_ratio - 1 == tar_levels) { in core_get_max_pstate()
1688 trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu); in intel_pstate_set_pstate()
1689 cpu->pstate.current_pstate = pstate; in intel_pstate_set_pstate()
1695 wrmsrl_on_cpu(cpu->cpu, MSR_IA32_PERF_CTL, in intel_pstate_set_pstate()
1701 intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate); in intel_pstate_set_min_pstate()
1706 int pstate = max(cpu->pstate.min_pstate, cpu->max_perf_ratio); in intel_pstate_max_within_limits()
1714 cpu->pstate.min_pstate = pstate_funcs.get_min(); in intel_pstate_get_cpu_pstates()
1715 cpu->pstate.max_pstate_physical = pstate_funcs.get_max_physical(); in intel_pstate_get_cpu_pstates()
1716 cpu->pstate.turbo_pstate = pstate_funcs.get_turbo(); in intel_pstate_get_cpu_pstates()
1717 cpu->pstate.scaling = pstate_funcs.get_scaling(); in intel_pstate_get_cpu_pstates()
1723 cpu->pstate.turbo_freq = phy_max * cpu->pstate.scaling; in intel_pstate_get_cpu_pstates()
1724 cpu->pstate.turbo_pstate = phy_max; in intel_pstate_get_cpu_pstates()
1725 cpu->pstate.max_pstate = HWP_GUARANTEED_PERF(READ_ONCE(cpu->hwp_cap_cached)); in intel_pstate_get_cpu_pstates()
1727 cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * cpu->pstate.scaling; in intel_pstate_get_cpu_pstates()
1728 cpu->pstate.max_pstate = pstate_funcs.get_max(); in intel_pstate_get_cpu_pstates()
1730 cpu->pstate.max_freq = cpu->pstate.max_pstate * cpu->pstate.scaling; in intel_pstate_get_cpu_pstates()
1733 cpu->aperf_mperf_shift = pstate_funcs.get_aperf_mperf_shift(); in intel_pstate_get_cpu_pstates()
1742 * Long hold time will keep high perf limits for long time,
1751 u64 hwp_req = READ_ONCE(cpu->hwp_req_cached); in intel_pstate_hwp_boost_up()
1757 * Cases to consider (User changes via sysfs or boot time): in intel_pstate_hwp_boost_up()
1758 * If, P0 (Turbo max) = P1 (Guaranteed max) = min: in intel_pstate_hwp_boost_up()
1760 * If, P0 (Turbo max) > P1 (Guaranteed max) = min: in intel_pstate_hwp_boost_up()
1762 * If, P0 (Turbo max) = P1 (Guaranteed max) > min: in intel_pstate_hwp_boost_up()
1764 * (min + p1)/2 and P1. in intel_pstate_hwp_boost_up()
1765 * If, P0 (Turbo max) > P1 (Guaranteed max) > min: in intel_pstate_hwp_boost_up()
1767 * (min + p1)/2, P1 and P0. in intel_pstate_hwp_boost_up()
1770 /* If max and min are equal or already at max, nothing to boost */ in intel_pstate_hwp_boost_up()
1771 if (max_limit == min_limit || cpu->hwp_boost_min >= max_limit) in intel_pstate_hwp_boost_up()
1774 if (!cpu->hwp_boost_min) in intel_pstate_hwp_boost_up()
1775 cpu->hwp_boost_min = min_limit; in intel_pstate_hwp_boost_up()
1777 /* level at half way mark between min and guranteed */ in intel_pstate_hwp_boost_up()
1778 boost_level1 = (HWP_GUARANTEED_PERF(cpu->hwp_cap_cached) + min_limit) >> 1; in intel_pstate_hwp_boost_up()
1780 if (cpu->hwp_boost_min < boost_level1) in intel_pstate_hwp_boost_up()
1781 cpu->hwp_boost_min = boost_level1; in intel_pstate_hwp_boost_up()
1782 else if (cpu->hwp_boost_min < HWP_GUARANTEED_PERF(cpu->hwp_cap_cached)) in intel_pstate_hwp_boost_up()
1783 cpu->hwp_boost_min = HWP_GUARANTEED_PERF(cpu->hwp_cap_cached); in intel_pstate_hwp_boost_up()
1784 else if (cpu->hwp_boost_min == HWP_GUARANTEED_PERF(cpu->hwp_cap_cached) && in intel_pstate_hwp_boost_up()
1785 max_limit != HWP_GUARANTEED_PERF(cpu->hwp_cap_cached)) in intel_pstate_hwp_boost_up()
1786 cpu->hwp_boost_min = max_limit; in intel_pstate_hwp_boost_up()
1790 hwp_req = (hwp_req & ~GENMASK_ULL(7, 0)) | cpu->hwp_boost_min; in intel_pstate_hwp_boost_up()
1792 cpu->last_update = cpu->sample.time; in intel_pstate_hwp_boost_up()
1797 if (cpu->hwp_boost_min) { in intel_pstate_hwp_boost_down()
1800 /* Check if we are idle for hold time to boost down */ in intel_pstate_hwp_boost_down()
1801 expired = time_after64(cpu->sample.time, cpu->last_update + in intel_pstate_hwp_boost_down()
1804 wrmsrl(MSR_HWP_REQUEST, cpu->hwp_req_cached); in intel_pstate_hwp_boost_down()
1805 cpu->hwp_boost_min = 0; in intel_pstate_hwp_boost_down()
1808 cpu->last_update = cpu->sample.time; in intel_pstate_hwp_boost_down()
1812 u64 time) in intel_pstate_update_util_hwp_local() argument
1814 cpu->sample.time = time; in intel_pstate_update_util_hwp_local()
1816 if (cpu->sched_flags & SCHED_CPUFREQ_IOWAIT) { in intel_pstate_update_util_hwp_local()
1819 cpu->sched_flags = 0; in intel_pstate_update_util_hwp_local()
1821 * Set iowait_boost flag and update time. Since IO WAIT flag in intel_pstate_update_util_hwp_local()
1822 * is set all the time, we can't just conclude that there is in intel_pstate_update_util_hwp_local()
1827 if (time_before64(time, cpu->last_io_update + 2 * TICK_NSEC)) in intel_pstate_update_util_hwp_local()
1830 cpu->last_io_update = time; in intel_pstate_update_util_hwp_local()
1841 u64 time, unsigned int flags) in intel_pstate_update_util_hwp() argument
1845 cpu->sched_flags |= flags; in intel_pstate_update_util_hwp()
1847 if (smp_processor_id() == cpu->cpu) in intel_pstate_update_util_hwp()
1848 intel_pstate_update_util_hwp_local(cpu, time); in intel_pstate_update_util_hwp()
1853 struct sample *sample = &cpu->sample; in intel_pstate_calc_avg_perf() local
1855 sample->core_avg_perf = div_ext_fp(sample->aperf, sample->mperf); in intel_pstate_calc_avg_perf()
1858 static inline bool intel_pstate_sample(struct cpudata *cpu, u64 time) in intel_pstate_sample() argument
1868 if (cpu->prev_mperf == mperf || cpu->prev_tsc == tsc) { in intel_pstate_sample()
1874 cpu->last_sample_time = cpu->sample.time; in intel_pstate_sample()
1875 cpu->sample.time = time; in intel_pstate_sample()
1876 cpu->sample.aperf = aperf; in intel_pstate_sample()
1877 cpu->sample.mperf = mperf; in intel_pstate_sample()
1878 cpu->sample.tsc = tsc; in intel_pstate_sample()
1879 cpu->sample.aperf -= cpu->prev_aperf; in intel_pstate_sample()
1880 cpu->sample.mperf -= cpu->prev_mperf; in intel_pstate_sample()
1881 cpu->sample.tsc -= cpu->prev_tsc; in intel_pstate_sample()
1883 cpu->prev_aperf = aperf; in intel_pstate_sample()
1884 cpu->prev_mperf = mperf; in intel_pstate_sample()
1885 cpu->prev_tsc = tsc; in intel_pstate_sample()
1887 * First time this function is invoked in a given cycle, all of the in intel_pstate_sample()
1888 * previous sample data fields are equal to zero or stale and they must in intel_pstate_sample()
1890 * that sample.time will always be reset before setting the utilization in intel_pstate_sample()
1891 * update hook and make the caller skip the sample then. in intel_pstate_sample()
1893 if (cpu->last_sample_time) { in intel_pstate_sample()
1902 return mul_ext_fp(cpu->sample.core_avg_perf, cpu_khz); in get_avg_frequency()
1907 return mul_ext_fp(cpu->pstate.max_pstate_physical, in get_avg_pstate()
1908 cpu->sample.core_avg_perf); in get_avg_pstate()
1913 struct sample *sample = &cpu->sample; in get_target_pstate() local
1917 busy_frac = div_fp(sample->mperf << cpu->aperf_mperf_shift, in get_target_pstate()
1918 sample->tsc); in get_target_pstate()
1920 if (busy_frac < cpu->iowait_boost) in get_target_pstate()
1921 busy_frac = cpu->iowait_boost; in get_target_pstate()
1923 sample->busy_scaled = busy_frac * 100; in get_target_pstate()
1926 cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; in get_target_pstate()
1929 if (target < cpu->pstate.min_pstate) in get_target_pstate()
1930 target = cpu->pstate.min_pstate; in get_target_pstate()
1933 * If the average P-state during the previous cycle was higher than the in get_target_pstate()
1941 target += (avg_pstate - target) >> 1; in get_target_pstate()
1948 int min_pstate = max(cpu->pstate.min_pstate, cpu->min_perf_ratio); in intel_pstate_prepare_request()
1949 int max_pstate = max(min_pstate, cpu->max_perf_ratio); in intel_pstate_prepare_request()
1956 if (pstate == cpu->pstate.current_pstate) in intel_pstate_update_pstate()
1959 cpu->pstate.current_pstate = pstate; in intel_pstate_update_pstate()
1965 int from = cpu->pstate.current_pstate; in intel_pstate_adjust_pstate()
1966 struct sample *sample; in intel_pstate_adjust_pstate() local
1973 trace_cpu_frequency(target_pstate * cpu->pstate.scaling, cpu->cpu); in intel_pstate_adjust_pstate()
1976 sample = &cpu->sample; in intel_pstate_adjust_pstate()
1977 trace_pstate_sample(mul_ext_fp(100, sample->core_avg_perf), in intel_pstate_adjust_pstate()
1978 fp_toint(sample->busy_scaled), in intel_pstate_adjust_pstate()
1980 cpu->pstate.current_pstate, in intel_pstate_adjust_pstate()
1981 sample->mperf, in intel_pstate_adjust_pstate()
1982 sample->aperf, in intel_pstate_adjust_pstate()
1983 sample->tsc, in intel_pstate_adjust_pstate()
1985 fp_toint(cpu->iowait_boost * 100)); in intel_pstate_adjust_pstate()
1988 static void intel_pstate_update_util(struct update_util_data *data, u64 time, in intel_pstate_update_util() argument
1995 if (smp_processor_id() != cpu->cpu) in intel_pstate_update_util()
1998 delta_ns = time - cpu->last_update; in intel_pstate_update_util()
2002 cpu->iowait_boost = ONE_EIGHTH_FP; in intel_pstate_update_util()
2003 } else if (cpu->iowait_boost >= ONE_EIGHTH_FP) { in intel_pstate_update_util()
2004 cpu->iowait_boost <<= 1; in intel_pstate_update_util()
2005 if (cpu->iowait_boost > int_tofp(1)) in intel_pstate_update_util()
2006 cpu->iowait_boost = int_tofp(1); in intel_pstate_update_util()
2008 cpu->iowait_boost = ONE_EIGHTH_FP; in intel_pstate_update_util()
2010 } else if (cpu->iowait_boost) { in intel_pstate_update_util()
2013 cpu->iowait_boost = 0; in intel_pstate_update_util()
2015 cpu->iowait_boost >>= 1; in intel_pstate_update_util()
2017 cpu->last_update = time; in intel_pstate_update_util()
2018 delta_ns = time - cpu->sample.time; in intel_pstate_update_util()
2022 if (intel_pstate_sample(cpu, time)) in intel_pstate_update_util()
2122 return -ENOMEM; in intel_pstate_init_cpu()
2126 cpu->cpu = cpunum; in intel_pstate_init_cpu()
2128 cpu->epp_default = -EINVAL; in intel_pstate_init_cpu()
2141 * Re-enable HWP in case this happens after a resume from ACPI in intel_pstate_init_cpu()
2148 cpu->epp_powersave = -EINVAL; in intel_pstate_init_cpu()
2149 cpu->epp_policy = 0; in intel_pstate_init_cpu()
2165 if (cpu->update_util_set) in intel_pstate_set_update_util_hook()
2169 cpu->sample.time = 0; in intel_pstate_set_update_util_hook()
2170 cpufreq_add_update_util_hook(cpu_num, &cpu->update_util, in intel_pstate_set_update_util_hook()
2174 cpu->update_util_set = true; in intel_pstate_set_update_util_hook()
2181 if (!cpu_data->update_util_set) in intel_pstate_clear_update_util_hook()
2185 cpu_data->update_util_set = false; in intel_pstate_clear_update_util_hook()
2192 cpu->pstate.max_freq : cpu->pstate.turbo_freq; in intel_pstate_get_max_freq()
2212 cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; in intel_pstate_update_perf_limits()
2213 turbo_max = cpu->pstate.turbo_pstate; in intel_pstate_update_perf_limits()
2215 max_freq = max_state * cpu->pstate.scaling; in intel_pstate_update_perf_limits()
2227 cpu->cpu, max_state, min_policy_perf, max_policy_perf); in intel_pstate_update_perf_limits()
2231 cpu->min_perf_ratio = min_policy_perf; in intel_pstate_update_perf_limits()
2232 cpu->max_perf_ratio = max_policy_perf; in intel_pstate_update_perf_limits()
2236 /* Global limits are in percent of the maximum turbo P-state. */ in intel_pstate_update_perf_limits()
2241 pr_debug("cpu:%d global_min:%d global_max:%d\n", cpu->cpu, in intel_pstate_update_perf_limits()
2244 cpu->min_perf_ratio = max(min_policy_perf, global_min); in intel_pstate_update_perf_limits()
2245 cpu->min_perf_ratio = min(cpu->min_perf_ratio, max_policy_perf); in intel_pstate_update_perf_limits()
2246 cpu->max_perf_ratio = min(max_policy_perf, global_max); in intel_pstate_update_perf_limits()
2247 cpu->max_perf_ratio = max(min_policy_perf, cpu->max_perf_ratio); in intel_pstate_update_perf_limits()
2250 cpu->min_perf_ratio = min(cpu->min_perf_ratio, in intel_pstate_update_perf_limits()
2251 cpu->max_perf_ratio); in intel_pstate_update_perf_limits()
2254 pr_debug("cpu:%d max_perf_ratio:%d min_perf_ratio:%d\n", cpu->cpu, in intel_pstate_update_perf_limits()
2255 cpu->max_perf_ratio, in intel_pstate_update_perf_limits()
2256 cpu->min_perf_ratio); in intel_pstate_update_perf_limits()
2263 if (!policy->cpuinfo.max_freq) in intel_pstate_set_policy()
2264 return -ENODEV; in intel_pstate_set_policy()
2266 pr_debug("set_policy cpuinfo.max %u policy->max %u\n", in intel_pstate_set_policy()
2267 policy->cpuinfo.max_freq, policy->max); in intel_pstate_set_policy()
2269 cpu = all_cpu_data[policy->cpu]; in intel_pstate_set_policy()
2270 cpu->policy = policy->policy; in intel_pstate_set_policy()
2274 intel_pstate_update_perf_limits(cpu, policy->min, policy->max); in intel_pstate_set_policy()
2276 if (cpu->policy == CPUFREQ_POLICY_PERFORMANCE) { in intel_pstate_set_policy()
2281 intel_pstate_clear_update_util_hook(policy->cpu); in intel_pstate_set_policy()
2284 intel_pstate_set_update_util_hook(policy->cpu); in intel_pstate_set_policy()
2294 intel_pstate_clear_update_util_hook(policy->cpu); in intel_pstate_set_policy()
2295 intel_pstate_hwp_set(policy->cpu); in intel_pstate_set_policy()
2307 cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate && in intel_pstate_adjust_policy_max()
2308 policy->max < policy->cpuinfo.max_freq && in intel_pstate_adjust_policy_max()
2309 policy->max > cpu->pstate.max_freq) { in intel_pstate_adjust_policy_max()
2310 pr_debug("policy->max > max non turbo frequency\n"); in intel_pstate_adjust_policy_max()
2311 policy->max = policy->cpuinfo.max_freq; in intel_pstate_adjust_policy_max()
2325 max_freq = max_state * cpu->pstate.scaling; in intel_pstate_verify_cpu_policy()
2329 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, max_freq); in intel_pstate_verify_cpu_policy()
2336 intel_pstate_verify_cpu_policy(all_cpu_data[policy->cpu], policy); in intel_pstate_verify_policy()
2343 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_cpu_offline()
2345 pr_debug("CPU %d going offline\n", cpu->cpu); in intel_pstate_cpu_offline()
2347 if (cpu->suspended) in intel_pstate_cpu_offline()
2368 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_cpu_online()
2370 pr_debug("CPU %d going online\n", cpu->cpu); in intel_pstate_cpu_online()
2376 * Re-enable HWP and clear the "suspended" flag to let "resume" in intel_pstate_cpu_online()
2380 cpu->suspended = false; in intel_pstate_cpu_online()
2388 pr_debug("CPU %d stopping\n", policy->cpu); in intel_pstate_stop_cpu()
2390 intel_pstate_clear_update_util_hook(policy->cpu); in intel_pstate_stop_cpu()
2395 pr_debug("CPU %d exiting\n", policy->cpu); in intel_pstate_cpu_exit()
2397 policy->fast_switch_possible = false; in intel_pstate_cpu_exit()
2407 rc = intel_pstate_init_cpu(policy->cpu); in __intel_pstate_cpu_init()
2411 cpu = all_cpu_data[policy->cpu]; in __intel_pstate_cpu_init()
2413 cpu->max_perf_ratio = 0xFF; in __intel_pstate_cpu_init()
2414 cpu->min_perf_ratio = 0; in __intel_pstate_cpu_init()
2416 policy->min = cpu->pstate.min_pstate * cpu->pstate.scaling; in __intel_pstate_cpu_init()
2417 policy->max = cpu->pstate.turbo_pstate * cpu->pstate.scaling; in __intel_pstate_cpu_init()
2420 policy->cpuinfo.min_freq = cpu->pstate.min_pstate * cpu->pstate.scaling; in __intel_pstate_cpu_init()
2423 policy->cpuinfo.max_freq = global.turbo_disabled ? in __intel_pstate_cpu_init()
2424 cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; in __intel_pstate_cpu_init()
2425 policy->cpuinfo.max_freq *= cpu->pstate.scaling; in __intel_pstate_cpu_init()
2431 cpu->pstate.max_freq : cpu->pstate.turbo_freq; in __intel_pstate_cpu_init()
2432 if (max_freq < policy->cpuinfo.max_freq) in __intel_pstate_cpu_init()
2433 policy->cpuinfo.max_freq = max_freq; in __intel_pstate_cpu_init()
2438 policy->fast_switch_possible = true; in __intel_pstate_cpu_init()
2454 policy->policy = CPUFREQ_POLICY_POWERSAVE; in intel_pstate_cpu_init()
2457 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_cpu_init()
2459 cpu->epp_cached = intel_pstate_get_epp(cpu, 0); in intel_pstate_cpu_init()
2482 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_verify_policy()
2485 intel_pstate_update_perf_limits(cpu, policy->min, policy->max); in intel_cpufreq_verify_policy()
2494 * core_avg_perf) is not needed and so is re-assigned to indicate if the
2497 * (or performance or core_avg_perf) have a fixed y-axis from 0 to 100%,
2508 struct sample *sample; in intel_cpufreq_trace() local
2516 sample = &cpu->sample; in intel_cpufreq_trace()
2520 cpu->pstate.current_pstate, in intel_cpufreq_trace()
2521 sample->mperf, in intel_cpufreq_trace()
2522 sample->aperf, in intel_cpufreq_trace()
2523 sample->tsc, in intel_cpufreq_trace()
2525 fp_toint(cpu->iowait_boost * 100)); in intel_cpufreq_trace()
2531 u64 prev = READ_ONCE(cpu->hwp_req_cached), value = prev; in intel_cpufreq_adjust_hwp()
2537 * The entire MSR needs to be updated in order to update the HWP min in intel_cpufreq_adjust_hwp()
2541 value |= HWP_MAX_PERF(strict ? target_pstate : cpu->max_perf_ratio); in intel_cpufreq_adjust_hwp()
2546 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_cpufreq_adjust_hwp()
2550 wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value); in intel_cpufreq_adjust_hwp()
2560 wrmsrl_on_cpu(cpu->cpu, MSR_IA32_PERF_CTL, in intel_cpufreq_adjust_perf_ctl()
2567 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_update_pstate()
2568 int old_pstate = cpu->pstate.current_pstate; in intel_cpufreq_update_pstate()
2573 policy->strict_target, fast_switch); in intel_cpufreq_update_pstate()
2574 cpu->pstate.current_pstate = target_pstate; in intel_cpufreq_update_pstate()
2577 cpu->pstate.current_pstate = target_pstate; in intel_cpufreq_update_pstate()
2590 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_target()
2596 freqs.old = policy->cur; in intel_cpufreq_target()
2603 target_pstate = DIV_ROUND_UP(freqs.new, cpu->pstate.scaling); in intel_cpufreq_target()
2606 target_pstate = freqs.new / cpu->pstate.scaling; in intel_cpufreq_target()
2609 target_pstate = DIV_ROUND_CLOSEST(freqs.new, cpu->pstate.scaling); in intel_cpufreq_target()
2615 freqs.new = target_pstate * cpu->pstate.scaling; in intel_cpufreq_target()
2625 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_fast_switch()
2630 target_pstate = DIV_ROUND_UP(target_freq, cpu->pstate.scaling); in intel_cpufreq_fast_switch()
2634 return target_pstate * cpu->pstate.scaling; in intel_cpufreq_fast_switch()
2644 dev = get_cpu_device(policy->cpu); in intel_cpufreq_cpu_init()
2646 return -ENODEV; in intel_cpufreq_cpu_init()
2652 policy->cpuinfo.transition_latency = INTEL_CPUFREQ_TRANSITION_LATENCY; in intel_cpufreq_cpu_init()
2654 policy->cur = policy->cpuinfo.min_freq; in intel_cpufreq_cpu_init()
2658 ret = -ENOMEM; in intel_cpufreq_cpu_init()
2662 cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_cpu_init()
2668 policy->transition_delay_us = INTEL_CPUFREQ_TRANSITION_DELAY_HWP; in intel_cpufreq_cpu_init()
2669 rdmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, &value); in intel_cpufreq_cpu_init()
2670 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_cpufreq_cpu_init()
2671 cpu->epp_cached = intel_pstate_get_epp(cpu, value); in intel_cpufreq_cpu_init()
2673 turbo_max = cpu->pstate.turbo_pstate; in intel_cpufreq_cpu_init()
2674 policy->transition_delay_us = INTEL_CPUFREQ_TRANSITION_DELAY; in intel_cpufreq_cpu_init()
2678 min_freq *= cpu->pstate.scaling; in intel_cpufreq_cpu_init()
2680 max_freq *= cpu->pstate.scaling; in intel_cpufreq_cpu_init()
2682 ret = freq_qos_add_request(&policy->constraints, req, FREQ_QOS_MIN, in intel_cpufreq_cpu_init()
2685 dev_err(dev, "Failed to add min-freq constraint (%d)\n", ret); in intel_cpufreq_cpu_init()
2689 ret = freq_qos_add_request(&policy->constraints, req + 1, FREQ_QOS_MAX, in intel_cpufreq_cpu_init()
2692 dev_err(dev, "Failed to add max-freq constraint (%d)\n", ret); in intel_cpufreq_cpu_init()
2696 policy->driver_data = req; in intel_cpufreq_cpu_init()
2714 req = policy->driver_data; in intel_cpufreq_cpu_exit()
2794 return -EINVAL; in intel_pstate_update_status()
2797 return -EBUSY; in intel_pstate_update_status()
2827 return -EINVAL; in intel_pstate_update_status()
2840 return -ENODEV; in intel_pstate_msrs_not_valid()
2847 pstate_funcs.get_max = funcs->get_max; in copy_cpu_funcs()
2848 pstate_funcs.get_max_physical = funcs->get_max_physical; in copy_cpu_funcs()
2849 pstate_funcs.get_min = funcs->get_min; in copy_cpu_funcs()
2850 pstate_funcs.get_turbo = funcs->get_turbo; in copy_cpu_funcs()
2851 pstate_funcs.get_scaling = funcs->get_scaling; in copy_cpu_funcs()
2852 pstate_funcs.get_val = funcs->get_val; in copy_cpu_funcs()
2853 pstate_funcs.get_vid = funcs->get_vid; in copy_cpu_funcs()
2854 pstate_funcs.get_aperf_mperf_shift = funcs->get_aperf_mperf_shift; in copy_cpu_funcs()
2872 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer); in intel_pstate_no_acpi_pss()
2877 if (pss && pss->type == ACPI_TYPE_PACKAGE) { in intel_pstate_no_acpi_pss()
2915 if (acpi_has_method(pr->handle, "_PPC")) in intel_pstate_has_acpi_ppc()
2927 /* Hardware vendor-specific info that has its own power management modes */
2930 {"ORACLE", "X4-2 ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
2931 {"ORACLE", "X4-2L ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
2932 {"ORACLE", "X4-2B ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
2933 {"ORACLE", "X3-2 ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
2934 {"ORACLE", "X3-2L ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
2935 {"ORACLE", "X3-2B ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
2942 {"ORACLE", "X6-2 ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
2985 * It may be unsafe to request P-states control from SMM if _PPC support in intel_pstate_request_control_from_smm()
3024 return -ENODEV; in intel_pstate_init()
3033 return -ENODEV; in intel_pstate_init()
3046 hwp_mode_bdw = id->driver_data; in intel_pstate_init()
3058 return -ENODEV; in intel_pstate_init()
3063 return -ENODEV; in intel_pstate_init()
3066 copy_cpu_funcs((struct pstate_funcs *)id->driver_data); in intel_pstate_init()
3071 return -ENODEV; in intel_pstate_init()
3083 pr_info("P-states controlled by the platform\n"); in intel_pstate_init()
3084 return -ENODEV; in intel_pstate_init()
3088 return -ENOTSUPP; in intel_pstate_init()
3090 pr_info("Intel P-state driver initializing\n"); in intel_pstate_init()
3094 return -ENOMEM; in intel_pstate_init()
3127 return -EINVAL; in intel_pstate_setup()
3156 MODULE_DESCRIPTION("'intel_pstate' - P state driver Intel Core processors");