Lines Matching full:cpu
20 #include <linux/cpu.h>
104 * to account for cpu idle period
139 * Stores the per cpu model P state limits and current P state.
194 * struct cpudata - Per CPU instance data storage
195 * @cpu: CPU number for this instance data
201 * @pstate: Stores P state limits for this CPU
202 * @vid: Stores VID limits for this CPU
206 * calculate CPU busy.
223 * @epp_saved: Saved EPP/EPB during system suspend or CPU offline
228 * @sched_flags: Store scheduler flags for possible cross CPU update
231 * This structure stores per CPU instance data for all CPUs.
234 int cpu; member
272 * struct pstate_funcs - Per CPU model specific callbacks
281 * Core and Atom CPU models have different way to get P State limits. This
334 /* The work item is needed to avoid CPU hotplug locking issues */
342 static void intel_pstate_set_itmt_prio(int cpu) in intel_pstate_set_itmt_prio() argument
348 ret = cppc_get_perf_caps(cpu, &cppc_perf); in intel_pstate_set_itmt_prio()
357 sched_set_itmt_core_prio(cppc_perf.highest_perf, cpu); in intel_pstate_set_itmt_prio()
368 * This code can be run during CPU online under the in intel_pstate_set_itmt_prio()
369 * CPU hotplug locks, so sched_set_itmt_support() in intel_pstate_set_itmt_prio()
378 static int intel_pstate_get_cppc_guranteed(int cpu) in intel_pstate_get_cppc_guranteed() argument
383 ret = cppc_get_perf_caps(cpu, &cppc_perf); in intel_pstate_get_cppc_guranteed()
394 static void intel_pstate_set_itmt_prio(int cpu) in intel_pstate_set_itmt_prio() argument
401 struct cpudata *cpu; in intel_pstate_init_acpi_perf_limits() local
406 intel_pstate_set_itmt_prio(policy->cpu); in intel_pstate_init_acpi_perf_limits()
413 cpu = all_cpu_data[policy->cpu]; in intel_pstate_init_acpi_perf_limits()
415 ret = acpi_processor_register_performance(&cpu->acpi_perf_data, in intel_pstate_init_acpi_perf_limits()
416 policy->cpu); in intel_pstate_init_acpi_perf_limits()
425 if (cpu->acpi_perf_data.control_register.space_id != in intel_pstate_init_acpi_perf_limits()
433 if (cpu->acpi_perf_data.state_count < 2) in intel_pstate_init_acpi_perf_limits()
436 pr_debug("CPU%u - ACPI _PSS perf data\n", policy->cpu); in intel_pstate_init_acpi_perf_limits()
437 for (i = 0; i < cpu->acpi_perf_data.state_count; i++) { in intel_pstate_init_acpi_perf_limits()
439 (i == cpu->acpi_perf_data.state ? '*' : ' '), i, in intel_pstate_init_acpi_perf_limits()
440 (u32) cpu->acpi_perf_data.states[i].core_frequency, in intel_pstate_init_acpi_perf_limits()
441 (u32) cpu->acpi_perf_data.states[i].power, in intel_pstate_init_acpi_perf_limits()
442 (u32) cpu->acpi_perf_data.states[i].control); in intel_pstate_init_acpi_perf_limits()
457 cpu->acpi_perf_data.states[0].core_frequency = in intel_pstate_init_acpi_perf_limits()
459 cpu->valid_pss_table = true; in intel_pstate_init_acpi_perf_limits()
465 cpu->valid_pss_table = false; in intel_pstate_init_acpi_perf_limits()
466 acpi_processor_unregister_performance(policy->cpu); in intel_pstate_init_acpi_perf_limits()
471 struct cpudata *cpu; in intel_pstate_exit_perf_limits() local
473 cpu = all_cpu_data[policy->cpu]; in intel_pstate_exit_perf_limits()
474 if (!cpu->valid_pss_table) in intel_pstate_exit_perf_limits()
477 acpi_processor_unregister_performance(policy->cpu); in intel_pstate_exit_perf_limits()
495 static int intel_pstate_get_cppc_guranteed(int cpu) in intel_pstate_get_cppc_guranteed() argument
504 struct cpudata *cpu; in update_turbo_state() local
506 cpu = all_cpu_data[0]; in update_turbo_state()
510 cpu->pstate.max_pstate == cpu->pstate.turbo_pstate); in update_turbo_state()
515 struct cpudata *cpu = all_cpu_data[0]; in min_perf_pct_min() local
516 int turbo_pstate = cpu->pstate.turbo_pstate; in min_perf_pct_min()
519 (cpu->pstate.min_pstate * 100 / turbo_pstate) : 0; in min_perf_pct_min()
530 ret = rdmsrl_on_cpu(cpu_data->cpu, MSR_IA32_ENERGY_PERF_BIAS, &epb); in intel_pstate_get_epb()
547 epp = rdmsrl_on_cpu(cpu_data->cpu, MSR_HWP_REQUEST, in intel_pstate_get_epp()
561 static int intel_pstate_set_epb(int cpu, s16 pref) in intel_pstate_set_epb() argument
569 ret = rdmsrl_on_cpu(cpu, MSR_IA32_ENERGY_PERF_BIAS, &epb); in intel_pstate_set_epb()
574 wrmsrl_on_cpu(cpu, MSR_IA32_ENERGY_PERF_BIAS, epb); in intel_pstate_set_epb()
654 ret = rdmsrl_on_cpu(cpu_data->cpu, MSR_HWP_REQUEST, &value); in intel_pstate_set_energy_pref_index()
664 ret = wrmsrl_on_cpu(cpu_data->cpu, MSR_HWP_REQUEST, value); in intel_pstate_set_energy_pref_index()
668 ret = intel_pstate_set_epb(cpu_data->cpu, epp); in intel_pstate_set_energy_pref_index()
695 struct cpudata *cpu_data = all_cpu_data[policy->cpu]; in store_energy_performance_preference()
714 struct cpudata *cpu_data = all_cpu_data[policy->cpu]; in show_energy_performance_preference()
728 struct cpudata *cpu; in show_base_frequency() local
732 ratio = intel_pstate_get_cppc_guranteed(policy->cpu); in show_base_frequency()
734 rdmsrl_on_cpu(policy->cpu, MSR_HWP_CAPABILITIES, &cap); in show_base_frequency()
738 cpu = all_cpu_data[policy->cpu]; in show_base_frequency()
740 return sprintf(buf, "%d\n", ratio * cpu->pstate.scaling); in show_base_frequency()
752 static void intel_pstate_get_hwp_max(unsigned int cpu, int *phy_max, in intel_pstate_get_hwp_max() argument
757 rdmsrl_on_cpu(cpu, MSR_HWP_CAPABILITIES, &cap); in intel_pstate_get_hwp_max()
758 WRITE_ONCE(all_cpu_data[cpu]->hwp_cap_cached, cap); in intel_pstate_get_hwp_max()
767 static void intel_pstate_hwp_set(unsigned int cpu) in intel_pstate_hwp_set() argument
769 struct cpudata *cpu_data = all_cpu_data[cpu]; in intel_pstate_hwp_set()
780 rdmsrl_on_cpu(cpu, MSR_HWP_REQUEST, &value); in intel_pstate_hwp_set()
830 intel_pstate_set_epb(cpu, epp); in intel_pstate_hwp_set()
834 wrmsrl_on_cpu(cpu, MSR_HWP_REQUEST, value); in intel_pstate_hwp_set()
837 static void intel_pstate_hwp_force_min_perf(int cpu) in intel_pstate_hwp_force_min_perf() argument
842 value = all_cpu_data[cpu]->hwp_req_cached; in intel_pstate_hwp_force_min_perf()
844 min_perf = HWP_LOWEST_PERF(all_cpu_data[cpu]->hwp_cap_cached); in intel_pstate_hwp_force_min_perf()
854 wrmsrl_on_cpu(cpu, MSR_HWP_REQUEST, value); in intel_pstate_hwp_force_min_perf()
859 struct cpudata *cpu_data = all_cpu_data[policy->cpu]; in intel_pstate_hwp_save_state()
878 if (policy->cpu == 0) in intel_pstate_resume()
879 intel_pstate_hwp_enable(all_cpu_data[policy->cpu]); in intel_pstate_resume()
881 all_cpu_data[policy->cpu]->epp_policy = 0; in intel_pstate_resume()
882 intel_pstate_hwp_set(policy->cpu); in intel_pstate_resume()
891 int cpu; in intel_pstate_update_policies() local
893 for_each_possible_cpu(cpu) in intel_pstate_update_policies()
894 cpufreq_update_policy(cpu); in intel_pstate_update_policies()
897 static void intel_pstate_update_max_freq(unsigned int cpu) in intel_pstate_update_max_freq() argument
899 struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpu); in intel_pstate_update_max_freq()
905 cpudata = all_cpu_data[cpu]; in intel_pstate_update_max_freq()
914 static void intel_pstate_update_limits(unsigned int cpu) in intel_pstate_update_limits() argument
925 for_each_possible_cpu(cpu) in intel_pstate_update_limits()
926 intel_pstate_update_max_freq(cpu); in intel_pstate_update_limits()
928 cpufreq_update_policy(cpu); in intel_pstate_update_limits()
973 struct cpudata *cpu; in show_turbo_pct() local
984 cpu = all_cpu_data[0]; in show_turbo_pct()
986 total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate + 1; in show_turbo_pct()
987 no_turbo = cpu->pstate.max_pstate - cpu->pstate.min_pstate + 1; in show_turbo_pct()
999 struct cpudata *cpu; in show_num_pstates() local
1009 cpu = all_cpu_data[0]; in show_num_pstates()
1010 total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate + 1; in show_num_pstates()
1070 struct cpudata *cpu = all_cpu_data[0]; in store_no_turbo() local
1071 int pct = cpu->pstate.max_pstate * 100 / cpu->pstate.turbo_pstate; in store_no_turbo()
1096 struct cpudata *cpu = all_cpu_data[i]; in update_qos_request() local
1111 turbo_max = cpu->pstate.turbo_pstate; in update_qos_request()
1121 freq *= cpu->pstate.scaling; in update_qos_request()
1124 pr_warn("Failed to update freq constraint: CPU%d\n", i); in update_qos_request()
1258 * If per cpu limits are enforced there are no global limits, so in intel_pstate_sysfs_expose_params()
1282 wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x00); in intel_pstate_hwp_enable()
1284 wrmsrl_on_cpu(cpudata->cpu, MSR_PM_ENABLE, 0x1); in intel_pstate_hwp_enable()
1293 static void intel_pstate_disable_ee(int cpu) in intel_pstate_disable_ee() argument
1298 ret = rdmsrl_on_cpu(cpu, MSR_IA32_POWER_CTL, &power_ctl); in intel_pstate_disable_ee()
1305 wrmsrl_on_cpu(cpu, MSR_IA32_POWER_CTL, power_ctl); in intel_pstate_disable_ee()
1534 static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) in intel_pstate_set_pstate() argument
1536 trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu); in intel_pstate_set_pstate()
1537 cpu->pstate.current_pstate = pstate; in intel_pstate_set_pstate()
1540 * the CPU being updated, so force the register update to run on the in intel_pstate_set_pstate()
1541 * right CPU. in intel_pstate_set_pstate()
1543 wrmsrl_on_cpu(cpu->cpu, MSR_IA32_PERF_CTL, in intel_pstate_set_pstate()
1544 pstate_funcs.get_val(cpu, pstate)); in intel_pstate_set_pstate()
1547 static void intel_pstate_set_min_pstate(struct cpudata *cpu) in intel_pstate_set_min_pstate() argument
1549 intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate); in intel_pstate_set_min_pstate()
1552 static void intel_pstate_max_within_limits(struct cpudata *cpu) in intel_pstate_max_within_limits() argument
1554 int pstate = max(cpu->pstate.min_pstate, cpu->max_perf_ratio); in intel_pstate_max_within_limits()
1557 intel_pstate_set_pstate(cpu, pstate); in intel_pstate_max_within_limits()
1560 static void intel_pstate_get_cpu_pstates(struct cpudata *cpu) in intel_pstate_get_cpu_pstates() argument
1562 cpu->pstate.min_pstate = pstate_funcs.get_min(); in intel_pstate_get_cpu_pstates()
1563 cpu->pstate.max_pstate = pstate_funcs.get_max(); in intel_pstate_get_cpu_pstates()
1564 cpu->pstate.max_pstate_physical = pstate_funcs.get_max_physical(); in intel_pstate_get_cpu_pstates()
1565 cpu->pstate.turbo_pstate = pstate_funcs.get_turbo(); in intel_pstate_get_cpu_pstates()
1566 cpu->pstate.scaling = pstate_funcs.get_scaling(); in intel_pstate_get_cpu_pstates()
1567 cpu->pstate.max_freq = cpu->pstate.max_pstate * cpu->pstate.scaling; in intel_pstate_get_cpu_pstates()
1572 intel_pstate_get_hwp_max(cpu->cpu, &phy_max, ¤t_max); in intel_pstate_get_cpu_pstates()
1573 cpu->pstate.turbo_freq = phy_max * cpu->pstate.scaling; in intel_pstate_get_cpu_pstates()
1575 cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * cpu->pstate.scaling; in intel_pstate_get_cpu_pstates()
1579 cpu->aperf_mperf_shift = pstate_funcs.get_aperf_mperf_shift(); in intel_pstate_get_cpu_pstates()
1582 pstate_funcs.get_vid(cpu); in intel_pstate_get_cpu_pstates()
1584 intel_pstate_set_min_pstate(cpu); in intel_pstate_get_cpu_pstates()
1595 static inline void intel_pstate_hwp_boost_up(struct cpudata *cpu) in intel_pstate_hwp_boost_up() argument
1597 u64 hwp_req = READ_ONCE(cpu->hwp_req_cached); in intel_pstate_hwp_boost_up()
1617 if (max_limit == min_limit || cpu->hwp_boost_min >= max_limit) in intel_pstate_hwp_boost_up()
1620 if (!cpu->hwp_boost_min) in intel_pstate_hwp_boost_up()
1621 cpu->hwp_boost_min = min_limit; in intel_pstate_hwp_boost_up()
1624 boost_level1 = (HWP_GUARANTEED_PERF(cpu->hwp_cap_cached) + min_limit) >> 1; in intel_pstate_hwp_boost_up()
1626 if (cpu->hwp_boost_min < boost_level1) in intel_pstate_hwp_boost_up()
1627 cpu->hwp_boost_min = boost_level1; in intel_pstate_hwp_boost_up()
1628 else if (cpu->hwp_boost_min < HWP_GUARANTEED_PERF(cpu->hwp_cap_cached)) in intel_pstate_hwp_boost_up()
1629 cpu->hwp_boost_min = HWP_GUARANTEED_PERF(cpu->hwp_cap_cached); in intel_pstate_hwp_boost_up()
1630 else if (cpu->hwp_boost_min == HWP_GUARANTEED_PERF(cpu->hwp_cap_cached) && in intel_pstate_hwp_boost_up()
1631 max_limit != HWP_GUARANTEED_PERF(cpu->hwp_cap_cached)) in intel_pstate_hwp_boost_up()
1632 cpu->hwp_boost_min = max_limit; in intel_pstate_hwp_boost_up()
1636 hwp_req = (hwp_req & ~GENMASK_ULL(7, 0)) | cpu->hwp_boost_min; in intel_pstate_hwp_boost_up()
1638 cpu->last_update = cpu->sample.time; in intel_pstate_hwp_boost_up()
1641 static inline void intel_pstate_hwp_boost_down(struct cpudata *cpu) in intel_pstate_hwp_boost_down() argument
1643 if (cpu->hwp_boost_min) { in intel_pstate_hwp_boost_down()
1647 expired = time_after64(cpu->sample.time, cpu->last_update + in intel_pstate_hwp_boost_down()
1650 wrmsrl(MSR_HWP_REQUEST, cpu->hwp_req_cached); in intel_pstate_hwp_boost_down()
1651 cpu->hwp_boost_min = 0; in intel_pstate_hwp_boost_down()
1654 cpu->last_update = cpu->sample.time; in intel_pstate_hwp_boost_down()
1657 static inline void intel_pstate_update_util_hwp_local(struct cpudata *cpu, in intel_pstate_update_util_hwp_local() argument
1660 cpu->sample.time = time; in intel_pstate_update_util_hwp_local()
1662 if (cpu->sched_flags & SCHED_CPUFREQ_IOWAIT) { in intel_pstate_update_util_hwp_local()
1665 cpu->sched_flags = 0; in intel_pstate_update_util_hwp_local()
1669 * some IO bound activity is scheduled on this CPU with just in intel_pstate_update_util_hwp_local()
1673 if (time_before64(time, cpu->last_io_update + 2 * TICK_NSEC)) in intel_pstate_update_util_hwp_local()
1676 cpu->last_io_update = time; in intel_pstate_update_util_hwp_local()
1679 intel_pstate_hwp_boost_up(cpu); in intel_pstate_update_util_hwp_local()
1682 intel_pstate_hwp_boost_down(cpu); in intel_pstate_update_util_hwp_local()
1689 struct cpudata *cpu = container_of(data, struct cpudata, update_util); in intel_pstate_update_util_hwp() local
1691 cpu->sched_flags |= flags; in intel_pstate_update_util_hwp()
1693 if (smp_processor_id() == cpu->cpu) in intel_pstate_update_util_hwp()
1694 intel_pstate_update_util_hwp_local(cpu, time); in intel_pstate_update_util_hwp()
1697 static inline void intel_pstate_calc_avg_perf(struct cpudata *cpu) in intel_pstate_calc_avg_perf() argument
1699 struct sample *sample = &cpu->sample; in intel_pstate_calc_avg_perf()
1704 static inline bool intel_pstate_sample(struct cpudata *cpu, u64 time) in intel_pstate_sample() argument
1714 if (cpu->prev_mperf == mperf || cpu->prev_tsc == tsc) { in intel_pstate_sample()
1720 cpu->last_sample_time = cpu->sample.time; in intel_pstate_sample()
1721 cpu->sample.time = time; in intel_pstate_sample()
1722 cpu->sample.aperf = aperf; in intel_pstate_sample()
1723 cpu->sample.mperf = mperf; in intel_pstate_sample()
1724 cpu->sample.tsc = tsc; in intel_pstate_sample()
1725 cpu->sample.aperf -= cpu->prev_aperf; in intel_pstate_sample()
1726 cpu->sample.mperf -= cpu->prev_mperf; in intel_pstate_sample()
1727 cpu->sample.tsc -= cpu->prev_tsc; in intel_pstate_sample()
1729 cpu->prev_aperf = aperf; in intel_pstate_sample()
1730 cpu->prev_mperf = mperf; in intel_pstate_sample()
1731 cpu->prev_tsc = tsc; in intel_pstate_sample()
1739 if (cpu->last_sample_time) { in intel_pstate_sample()
1740 intel_pstate_calc_avg_perf(cpu); in intel_pstate_sample()
1746 static inline int32_t get_avg_frequency(struct cpudata *cpu) in get_avg_frequency() argument
1748 return mul_ext_fp(cpu->sample.core_avg_perf, cpu_khz); in get_avg_frequency()
1751 static inline int32_t get_avg_pstate(struct cpudata *cpu) in get_avg_pstate() argument
1753 return mul_ext_fp(cpu->pstate.max_pstate_physical, in get_avg_pstate()
1754 cpu->sample.core_avg_perf); in get_avg_pstate()
1757 static inline int32_t get_target_pstate(struct cpudata *cpu) in get_target_pstate() argument
1759 struct sample *sample = &cpu->sample; in get_target_pstate()
1763 busy_frac = div_fp(sample->mperf << cpu->aperf_mperf_shift, in get_target_pstate()
1766 if (busy_frac < cpu->iowait_boost) in get_target_pstate()
1767 busy_frac = cpu->iowait_boost; in get_target_pstate()
1772 cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; in get_target_pstate()
1775 if (target < cpu->pstate.min_pstate) in get_target_pstate()
1776 target = cpu->pstate.min_pstate; in get_target_pstate()
1782 * loss related to moving the workload from one CPU to another within in get_target_pstate()
1785 avg_pstate = get_avg_pstate(cpu); in get_target_pstate()
1792 static int intel_pstate_prepare_request(struct cpudata *cpu, int pstate) in intel_pstate_prepare_request() argument
1794 int min_pstate = max(cpu->pstate.min_pstate, cpu->min_perf_ratio); in intel_pstate_prepare_request()
1795 int max_pstate = max(min_pstate, cpu->max_perf_ratio); in intel_pstate_prepare_request()
1800 static void intel_pstate_update_pstate(struct cpudata *cpu, int pstate) in intel_pstate_update_pstate() argument
1802 if (pstate == cpu->pstate.current_pstate) in intel_pstate_update_pstate()
1805 cpu->pstate.current_pstate = pstate; in intel_pstate_update_pstate()
1806 wrmsrl(MSR_IA32_PERF_CTL, pstate_funcs.get_val(cpu, pstate)); in intel_pstate_update_pstate()
1809 static void intel_pstate_adjust_pstate(struct cpudata *cpu) in intel_pstate_adjust_pstate() argument
1811 int from = cpu->pstate.current_pstate; in intel_pstate_adjust_pstate()
1817 target_pstate = get_target_pstate(cpu); in intel_pstate_adjust_pstate()
1818 target_pstate = intel_pstate_prepare_request(cpu, target_pstate); in intel_pstate_adjust_pstate()
1819 trace_cpu_frequency(target_pstate * cpu->pstate.scaling, cpu->cpu); in intel_pstate_adjust_pstate()
1820 intel_pstate_update_pstate(cpu, target_pstate); in intel_pstate_adjust_pstate()
1822 sample = &cpu->sample; in intel_pstate_adjust_pstate()
1826 cpu->pstate.current_pstate, in intel_pstate_adjust_pstate()
1830 get_avg_frequency(cpu), in intel_pstate_adjust_pstate()
1831 fp_toint(cpu->iowait_boost * 100)); in intel_pstate_adjust_pstate()
1837 struct cpudata *cpu = container_of(data, struct cpudata, update_util); in intel_pstate_update_util() local
1841 if (smp_processor_id() != cpu->cpu) in intel_pstate_update_util()
1844 delta_ns = time - cpu->last_update; in intel_pstate_update_util()
1846 /* Start over if the CPU may have been idle. */ in intel_pstate_update_util()
1848 cpu->iowait_boost = ONE_EIGHTH_FP; in intel_pstate_update_util()
1849 } else if (cpu->iowait_boost >= ONE_EIGHTH_FP) { in intel_pstate_update_util()
1850 cpu->iowait_boost <<= 1; in intel_pstate_update_util()
1851 if (cpu->iowait_boost > int_tofp(1)) in intel_pstate_update_util()
1852 cpu->iowait_boost = int_tofp(1); in intel_pstate_update_util()
1854 cpu->iowait_boost = ONE_EIGHTH_FP; in intel_pstate_update_util()
1856 } else if (cpu->iowait_boost) { in intel_pstate_update_util()
1857 /* Clear iowait_boost if the CPU may have been idle. */ in intel_pstate_update_util()
1859 cpu->iowait_boost = 0; in intel_pstate_update_util()
1861 cpu->iowait_boost >>= 1; in intel_pstate_update_util()
1863 cpu->last_update = time; in intel_pstate_update_util()
1864 delta_ns = time - cpu->sample.time; in intel_pstate_update_util()
1868 if (intel_pstate_sample(cpu, time)) in intel_pstate_update_util()
1869 intel_pstate_adjust_pstate(cpu); in intel_pstate_update_util()
1961 struct cpudata *cpu; in intel_pstate_init_cpu() local
1963 cpu = all_cpu_data[cpunum]; in intel_pstate_init_cpu()
1965 if (!cpu) { in intel_pstate_init_cpu()
1966 cpu = kzalloc(sizeof(*cpu), GFP_KERNEL); in intel_pstate_init_cpu()
1967 if (!cpu) in intel_pstate_init_cpu()
1970 all_cpu_data[cpunum] = cpu; in intel_pstate_init_cpu()
1972 cpu->epp_default = -EINVAL; in intel_pstate_init_cpu()
1973 cpu->epp_powersave = -EINVAL; in intel_pstate_init_cpu()
1974 cpu->epp_saved = -EINVAL; in intel_pstate_init_cpu()
1977 cpu = all_cpu_data[cpunum]; in intel_pstate_init_cpu()
1979 cpu->cpu = cpunum; in intel_pstate_init_cpu()
1988 intel_pstate_hwp_enable(cpu); in intel_pstate_init_cpu()
1995 intel_pstate_get_cpu_pstates(cpu); in intel_pstate_init_cpu()
1997 pr_debug("controlling: cpu %d\n", cpunum); in intel_pstate_init_cpu()
2004 struct cpudata *cpu = all_cpu_data[cpu_num]; in intel_pstate_set_update_util_hook() local
2009 if (cpu->update_util_set) in intel_pstate_set_update_util_hook()
2013 cpu->sample.time = 0; in intel_pstate_set_update_util_hook()
2014 cpufreq_add_update_util_hook(cpu_num, &cpu->update_util, in intel_pstate_set_update_util_hook()
2018 cpu->update_util_set = true; in intel_pstate_set_update_util_hook()
2021 static void intel_pstate_clear_update_util_hook(unsigned int cpu) in intel_pstate_clear_update_util_hook() argument
2023 struct cpudata *cpu_data = all_cpu_data[cpu]; in intel_pstate_clear_update_util_hook()
2028 cpufreq_remove_update_util_hook(cpu); in intel_pstate_clear_update_util_hook()
2033 static int intel_pstate_get_max_freq(struct cpudata *cpu) in intel_pstate_get_max_freq() argument
2036 cpu->pstate.max_freq : cpu->pstate.turbo_freq; in intel_pstate_get_max_freq()
2040 struct cpudata *cpu) in intel_pstate_update_perf_limits() argument
2042 int max_freq = intel_pstate_get_max_freq(cpu); in intel_pstate_update_perf_limits()
2052 intel_pstate_get_hwp_max(cpu->cpu, &turbo_max, &max_state); in intel_pstate_update_perf_limits()
2055 cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; in intel_pstate_update_perf_limits()
2056 turbo_max = cpu->pstate.turbo_pstate; in intel_pstate_update_perf_limits()
2068 pr_debug("cpu:%d max_state %d min_policy_perf:%d max_policy_perf:%d\n", in intel_pstate_update_perf_limits()
2069 policy->cpu, max_state, in intel_pstate_update_perf_limits()
2074 cpu->min_perf_ratio = min_policy_perf; in intel_pstate_update_perf_limits()
2075 cpu->max_perf_ratio = max_policy_perf; in intel_pstate_update_perf_limits()
2084 pr_debug("cpu:%d global_min:%d global_max:%d\n", policy->cpu, in intel_pstate_update_perf_limits()
2087 cpu->min_perf_ratio = max(min_policy_perf, global_min); in intel_pstate_update_perf_limits()
2088 cpu->min_perf_ratio = min(cpu->min_perf_ratio, max_policy_perf); in intel_pstate_update_perf_limits()
2089 cpu->max_perf_ratio = min(max_policy_perf, global_max); in intel_pstate_update_perf_limits()
2090 cpu->max_perf_ratio = max(min_policy_perf, cpu->max_perf_ratio); in intel_pstate_update_perf_limits()
2093 cpu->min_perf_ratio = min(cpu->min_perf_ratio, in intel_pstate_update_perf_limits()
2094 cpu->max_perf_ratio); in intel_pstate_update_perf_limits()
2097 pr_debug("cpu:%d max_perf_ratio:%d min_perf_ratio:%d\n", policy->cpu, in intel_pstate_update_perf_limits()
2098 cpu->max_perf_ratio, in intel_pstate_update_perf_limits()
2099 cpu->min_perf_ratio); in intel_pstate_update_perf_limits()
2104 struct cpudata *cpu; in intel_pstate_set_policy() local
2112 cpu = all_cpu_data[policy->cpu]; in intel_pstate_set_policy()
2113 cpu->policy = policy->policy; in intel_pstate_set_policy()
2117 intel_pstate_update_perf_limits(policy, cpu); in intel_pstate_set_policy()
2119 if (cpu->policy == CPUFREQ_POLICY_PERFORMANCE) { in intel_pstate_set_policy()
2124 intel_pstate_clear_update_util_hook(policy->cpu); in intel_pstate_set_policy()
2125 intel_pstate_max_within_limits(cpu); in intel_pstate_set_policy()
2127 intel_pstate_set_update_util_hook(policy->cpu); in intel_pstate_set_policy()
2137 intel_pstate_clear_update_util_hook(policy->cpu); in intel_pstate_set_policy()
2138 intel_pstate_hwp_set(policy->cpu); in intel_pstate_set_policy()
2147 struct cpudata *cpu) in intel_pstate_adjust_policy_max() argument
2150 cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate && in intel_pstate_adjust_policy_max()
2152 policy->max > cpu->pstate.max_freq) { in intel_pstate_adjust_policy_max()
2160 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_verify_policy() local
2164 intel_pstate_get_max_freq(cpu)); in intel_pstate_verify_policy()
2170 intel_pstate_adjust_policy_max(policy, cpu); in intel_pstate_verify_policy()
2177 intel_pstate_set_min_pstate(all_cpu_data[policy->cpu]); in intel_cpufreq_stop_cpu()
2182 pr_debug("CPU %d exiting\n", policy->cpu); in intel_pstate_stop_cpu()
2184 intel_pstate_clear_update_util_hook(policy->cpu); in intel_pstate_stop_cpu()
2187 intel_pstate_hwp_force_min_perf(policy->cpu); in intel_pstate_stop_cpu()
2204 struct cpudata *cpu; in __intel_pstate_cpu_init() local
2207 rc = intel_pstate_init_cpu(policy->cpu); in __intel_pstate_cpu_init()
2211 cpu = all_cpu_data[policy->cpu]; in __intel_pstate_cpu_init()
2213 cpu->max_perf_ratio = 0xFF; in __intel_pstate_cpu_init()
2214 cpu->min_perf_ratio = 0; in __intel_pstate_cpu_init()
2216 policy->min = cpu->pstate.min_pstate * cpu->pstate.scaling; in __intel_pstate_cpu_init()
2217 policy->max = cpu->pstate.turbo_pstate * cpu->pstate.scaling; in __intel_pstate_cpu_init()
2220 policy->cpuinfo.min_freq = cpu->pstate.min_pstate * cpu->pstate.scaling; in __intel_pstate_cpu_init()
2224 cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; in __intel_pstate_cpu_init()
2225 policy->cpuinfo.max_freq *= cpu->pstate.scaling; in __intel_pstate_cpu_init()
2231 cpu->pstate.max_freq : cpu->pstate.turbo_freq; in __intel_pstate_cpu_init()
2273 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_verify_policy() local
2277 intel_pstate_get_max_freq(cpu)); in intel_cpufreq_verify_policy()
2279 intel_pstate_adjust_policy_max(policy, cpu); in intel_cpufreq_verify_policy()
2281 intel_pstate_update_perf_limits(policy, cpu); in intel_cpufreq_verify_policy()
2302 static void intel_cpufreq_trace(struct cpudata *cpu, unsigned int trace_type, int old_pstate) in intel_cpufreq_trace() argument
2309 if (!intel_pstate_sample(cpu, ktime_get())) in intel_cpufreq_trace()
2312 sample = &cpu->sample; in intel_cpufreq_trace()
2316 cpu->pstate.current_pstate, in intel_cpufreq_trace()
2320 get_avg_frequency(cpu), in intel_cpufreq_trace()
2321 fp_toint(cpu->iowait_boost * 100)); in intel_cpufreq_trace()
2328 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_target() local
2340 target_pstate = DIV_ROUND_UP(freqs.new, cpu->pstate.scaling); in intel_cpufreq_target()
2343 target_pstate = freqs.new / cpu->pstate.scaling; in intel_cpufreq_target()
2346 target_pstate = DIV_ROUND_CLOSEST(freqs.new, cpu->pstate.scaling); in intel_cpufreq_target()
2349 target_pstate = intel_pstate_prepare_request(cpu, target_pstate); in intel_cpufreq_target()
2350 old_pstate = cpu->pstate.current_pstate; in intel_cpufreq_target()
2351 if (target_pstate != cpu->pstate.current_pstate) { in intel_cpufreq_target()
2352 cpu->pstate.current_pstate = target_pstate; in intel_cpufreq_target()
2353 wrmsrl_on_cpu(policy->cpu, MSR_IA32_PERF_CTL, in intel_cpufreq_target()
2354 pstate_funcs.get_val(cpu, target_pstate)); in intel_cpufreq_target()
2356 freqs.new = target_pstate * cpu->pstate.scaling; in intel_cpufreq_target()
2357 intel_cpufreq_trace(cpu, INTEL_PSTATE_TRACE_TARGET, old_pstate); in intel_cpufreq_target()
2366 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_fast_switch() local
2371 target_pstate = DIV_ROUND_UP(target_freq, cpu->pstate.scaling); in intel_cpufreq_fast_switch()
2372 target_pstate = intel_pstate_prepare_request(cpu, target_pstate); in intel_cpufreq_fast_switch()
2373 old_pstate = cpu->pstate.current_pstate; in intel_cpufreq_fast_switch()
2374 intel_pstate_update_pstate(cpu, target_pstate); in intel_cpufreq_fast_switch()
2375 intel_cpufreq_trace(cpu, INTEL_PSTATE_TRACE_FAST_SWITCH, old_pstate); in intel_cpufreq_fast_switch()
2376 return target_pstate * cpu->pstate.scaling; in intel_cpufreq_fast_switch()
2383 struct cpudata *cpu; in intel_cpufreq_cpu_init() local
2386 dev = get_cpu_device(policy->cpu); in intel_cpufreq_cpu_init()
2405 cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_cpu_init()
2408 intel_pstate_get_hwp_max(policy->cpu, &turbo_max, &max_state); in intel_cpufreq_cpu_init()
2410 turbo_max = cpu->pstate.turbo_pstate; in intel_cpufreq_cpu_init()
2413 min_freq *= cpu->pstate.scaling; in intel_cpufreq_cpu_init()
2415 max_freq *= cpu->pstate.scaling; in intel_cpufreq_cpu_init()
2474 unsigned int cpu; in intel_pstate_driver_cleanup() local
2477 for_each_online_cpu(cpu) { in intel_pstate_driver_cleanup()
2478 if (all_cpu_data[cpu]) { in intel_pstate_driver_cleanup()
2480 intel_pstate_clear_update_util_hook(cpu); in intel_pstate_driver_cleanup()
2482 kfree(all_cpu_data[cpu]); in intel_pstate_driver_cleanup()
2483 all_cpu_data[cpu] = NULL; in intel_pstate_driver_cleanup()
2765 pr_info("CPU model not supported\n"); in intel_pstate_init()