Lines Matching +full:min +full:- +full:freq
1 // SPDX-License-Identifier: GPL-2.0-only
38 #include <asm/intel-family.h>
56 #define ONE_EIGHTH_FP ((int64_t)1 << (FRAC_BITS - 3))
78 mask = (1 << FRAC_BITS) - 1; in ceiling_fp()
95 * struct sample - Store performance sample
122 * struct pstate_data - Store P state data
124 * @min_pstate: Min P state possible for this platform
129 * @perf_ctl_scaling: PERF_CTL P-state to frequency scaling factor
152 * struct vid_data - Stores voltage information data
153 * @min: VID data for this platform corresponding to
157 * @ratio: Ratio of (vid max - vid min) /
158 * (max P state - Min P State)
165 int min; member
172 * struct global_params - Global parameters, mostly tunable via sysfs.
173 * @no_turbo: Whether or not to use turbo P-states.
174 * @turbo_disabled: Whether or not turbo P-states are available at all,
176 * not the maximum reported turbo P-state is different from
177 * the maximum reported non-turbo one.
179 * P-state capacity.
181 * P-state capacity.
191 * struct cpudata - Per CPU instance data storage
196 * @iowait_boost: iowait-related boost fraction
216 * @epp_cached: Cached HWP energy-performance preference value
222 * @hwp_boost_min: Last HWP boosted min performance
273 * struct pstate_funcs - Per CPU model specific callbacks
377 cppc_perf.highest_perf = HWP_HIGHEST_PERF(READ_ONCE(all_cpu_data[cpu]->hwp_cap_cached)); in intel_pstate_set_itmt_prio()
425 * Compute the perf-to-frequency scaling factor for the given CPU if in intel_pstate_cppc_get_scaling()
449 intel_pstate_set_itmt_prio(policy->cpu); in intel_pstate_init_acpi_perf_limits()
456 cpu = all_cpu_data[policy->cpu]; in intel_pstate_init_acpi_perf_limits()
458 ret = acpi_processor_register_performance(&cpu->acpi_perf_data, in intel_pstate_init_acpi_perf_limits()
459 policy->cpu); in intel_pstate_init_acpi_perf_limits()
468 if (cpu->acpi_perf_data.control_register.space_id != in intel_pstate_init_acpi_perf_limits()
476 if (cpu->acpi_perf_data.state_count < 2) in intel_pstate_init_acpi_perf_limits()
479 pr_debug("CPU%u - ACPI _PSS perf data\n", policy->cpu); in intel_pstate_init_acpi_perf_limits()
480 for (i = 0; i < cpu->acpi_perf_data.state_count; i++) { in intel_pstate_init_acpi_perf_limits()
482 (i == cpu->acpi_perf_data.state ? '*' : ' '), i, in intel_pstate_init_acpi_perf_limits()
483 (u32) cpu->acpi_perf_data.states[i].core_frequency, in intel_pstate_init_acpi_perf_limits()
484 (u32) cpu->acpi_perf_data.states[i].power, in intel_pstate_init_acpi_perf_limits()
485 (u32) cpu->acpi_perf_data.states[i].control); in intel_pstate_init_acpi_perf_limits()
488 cpu->valid_pss_table = true; in intel_pstate_init_acpi_perf_limits()
494 cpu->valid_pss_table = false; in intel_pstate_init_acpi_perf_limits()
495 acpi_processor_unregister_performance(policy->cpu); in intel_pstate_init_acpi_perf_limits()
502 cpu = all_cpu_data[policy->cpu]; in intel_pstate_exit_perf_limits()
503 if (!cpu->valid_pss_table) in intel_pstate_exit_perf_limits()
506 acpi_processor_unregister_performance(policy->cpu); in intel_pstate_exit_perf_limits()
526 return -ENOTSUPP; in intel_pstate_get_cppc_guaranteed()
535 static int intel_pstate_freq_to_hwp_rel(struct cpudata *cpu, int freq, in intel_pstate_freq_to_hwp_rel() argument
538 if (freq == cpu->pstate.turbo_freq) in intel_pstate_freq_to_hwp_rel()
539 return cpu->pstate.turbo_pstate; in intel_pstate_freq_to_hwp_rel()
541 if (freq == cpu->pstate.max_freq) in intel_pstate_freq_to_hwp_rel()
542 return cpu->pstate.max_pstate; in intel_pstate_freq_to_hwp_rel()
546 return freq / cpu->pstate.scaling; in intel_pstate_freq_to_hwp_rel()
548 return DIV_ROUND_CLOSEST(freq, cpu->pstate.scaling); in intel_pstate_freq_to_hwp_rel()
551 return DIV_ROUND_UP(freq, cpu->pstate.scaling); in intel_pstate_freq_to_hwp_rel()
554 static int intel_pstate_freq_to_hwp(struct cpudata *cpu, int freq) in intel_pstate_freq_to_hwp() argument
556 return intel_pstate_freq_to_hwp_rel(cpu, freq, CPUFREQ_RELATION_L); in intel_pstate_freq_to_hwp()
560 * intel_pstate_hybrid_hwp_adjust - Calibrate HWP performance levels.
564 * P-states accessible through the PERF_CTL interface. If that happens, the
566 * than the scaling factor between P-state values and CPU frequency.
572 int perf_ctl_max_phys = cpu->pstate.max_pstate_physical; in intel_pstate_hybrid_hwp_adjust()
573 int perf_ctl_scaling = cpu->pstate.perf_ctl_scaling; in intel_pstate_hybrid_hwp_adjust()
574 int perf_ctl_turbo = pstate_funcs.get_turbo(cpu->cpu); in intel_pstate_hybrid_hwp_adjust()
575 int scaling = cpu->pstate.scaling; in intel_pstate_hybrid_hwp_adjust()
576 int freq; in intel_pstate_hybrid_hwp_adjust() local
578 pr_debug("CPU%d: perf_ctl_max_phys = %d\n", cpu->cpu, perf_ctl_max_phys); in intel_pstate_hybrid_hwp_adjust()
579 pr_debug("CPU%d: perf_ctl_turbo = %d\n", cpu->cpu, perf_ctl_turbo); in intel_pstate_hybrid_hwp_adjust()
580 pr_debug("CPU%d: perf_ctl_scaling = %d\n", cpu->cpu, perf_ctl_scaling); in intel_pstate_hybrid_hwp_adjust()
581 pr_debug("CPU%d: HWP_CAP guaranteed = %d\n", cpu->cpu, cpu->pstate.max_pstate); in intel_pstate_hybrid_hwp_adjust()
582 pr_debug("CPU%d: HWP_CAP highest = %d\n", cpu->cpu, cpu->pstate.turbo_pstate); in intel_pstate_hybrid_hwp_adjust()
583 pr_debug("CPU%d: HWP-to-frequency scaling factor: %d\n", cpu->cpu, scaling); in intel_pstate_hybrid_hwp_adjust()
585 cpu->pstate.turbo_freq = rounddown(cpu->pstate.turbo_pstate * scaling, in intel_pstate_hybrid_hwp_adjust()
587 cpu->pstate.max_freq = rounddown(cpu->pstate.max_pstate * scaling, in intel_pstate_hybrid_hwp_adjust()
590 freq = perf_ctl_max_phys * perf_ctl_scaling; in intel_pstate_hybrid_hwp_adjust()
591 cpu->pstate.max_pstate_physical = intel_pstate_freq_to_hwp(cpu, freq); in intel_pstate_hybrid_hwp_adjust()
593 freq = cpu->pstate.min_pstate * perf_ctl_scaling; in intel_pstate_hybrid_hwp_adjust()
594 cpu->pstate.min_freq = freq; in intel_pstate_hybrid_hwp_adjust()
596 * Cast the min P-state value retrieved via pstate_funcs.get_min() to in intel_pstate_hybrid_hwp_adjust()
599 cpu->pstate.min_pstate = intel_pstate_freq_to_hwp(cpu, freq); in intel_pstate_hybrid_hwp_adjust()
614 int turbo_pstate = cpu->pstate.turbo_pstate; in min_perf_pct_min()
617 (cpu->pstate.min_pstate * 100 / turbo_pstate) : 0; in min_perf_pct_min()
622 s16 epp = -EOPNOTSUPP; in intel_pstate_get_epp()
630 epp = rdmsrq_on_cpu(cpu_data->cpu, MSR_HWP_REQUEST, in intel_pstate_get_epp()
645 *-------------------------------------
680 int index = -EINVAL; in intel_pstate_get_energy_pref_index()
701 * 0x00-0x03 : Performance in intel_pstate_get_energy_pref_index()
702 * 0x04-0x07 : Balance performance in intel_pstate_get_energy_pref_index()
703 * 0x08-0x0B : Balance power in intel_pstate_get_energy_pref_index()
704 * 0x0C-0x0F : Power in intel_pstate_get_energy_pref_index()
724 u64 value = READ_ONCE(cpu->hwp_req_cached); in intel_pstate_set_epp()
733 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_pstate_set_epp()
734 ret = wrmsrq_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value); in intel_pstate_set_epp()
736 cpu->epp_cached = epp; in intel_pstate_set_epp()
745 int epp = -EINVAL; in intel_pstate_set_energy_pref_index()
746 int ret = -EOPNOTSUPP; in intel_pstate_set_energy_pref_index()
749 epp = cpu_data->epp_default; in intel_pstate_set_energy_pref_index()
754 else if (epp == -EINVAL) in intel_pstate_set_energy_pref_index()
762 if (epp > 0 && cpu_data->policy == CPUFREQ_POLICY_PERFORMANCE) in intel_pstate_set_energy_pref_index()
763 return -EBUSY; in intel_pstate_set_energy_pref_index()
792 struct cpudata *cpu = all_cpu_data[policy->cpu]; in store_energy_performance_preference()
800 return -EINVAL; in store_energy_performance_preference()
802 ret = match_string(energy_perf_strings, -1, str_preference); in store_energy_performance_preference()
812 return -EINVAL; in store_energy_performance_preference()
823 return -EAGAIN; in store_energy_performance_preference()
833 * which is super-heavy-weight, so make sure it is worth doing in store_energy_performance_preference()
837 epp = ret ? epp_values[ret] : cpu->epp_default; in store_energy_performance_preference()
839 if (cpu->epp_cached != epp) { in store_energy_performance_preference()
860 struct cpudata *cpu_data = all_cpu_data[policy->cpu]; in show_energy_performance_preference()
877 struct cpudata *cpu = all_cpu_data[policy->cpu]; in show_base_frequency()
878 int ratio, freq; in show_base_frequency() local
880 ratio = intel_pstate_get_cppc_guaranteed(policy->cpu); in show_base_frequency()
884 rdmsrq_on_cpu(policy->cpu, MSR_HWP_CAPABILITIES, &cap); in show_base_frequency()
888 freq = ratio * cpu->pstate.scaling; in show_base_frequency()
889 if (cpu->pstate.scaling != cpu->pstate.perf_ctl_scaling) in show_base_frequency()
890 freq = rounddown(freq, cpu->pstate.perf_ctl_scaling); in show_base_frequency()
892 return sprintf(buf, "%d\n", freq); in show_base_frequency()
917 * and the x86 arch scale-invariance information from concurrent updates.
925 unsigned long *freq) in hybrid_active_power() argument
928 * Create "utilization bins" of 0-40%, 40%-60%, 60%-80%, and 80%-100% in hybrid_active_power()
937 if (!*freq) in hybrid_active_power()
938 *freq = 2; in hybrid_active_power()
946 static int hybrid_get_cost(struct device *dev, unsigned long freq, in hybrid_get_cost() argument
949 struct pstate_data *pstate = &all_cpu_data[dev->id]->pstate; in hybrid_get_cost()
950 struct cpu_cacheinfo *cacheinfo = get_cpu_cacheinfo(dev->id); in hybrid_get_cost()
953 * The smaller the perf-to-frequency scaling factor, the larger the IPC in hybrid_get_cost()
959 * Add the freq value to the cost, so that the cost of running on CPUs in hybrid_get_cost()
962 *cost = div_u64(100ULL * INTEL_PSTATE_CORE_SCALING, pstate->scaling) + freq; in hybrid_get_cost()
972 for (i = 0; i < cacheinfo->num_leaves; i++) { in hybrid_get_cost()
973 if (cacheinfo->info_list[i].level == 3) { in hybrid_get_cost()
995 if (!hybrid_max_perf_cpu || cpudata->pd_registered) in hybrid_register_perf_domain()
1006 cpudata->pd_registered = true; in hybrid_register_perf_domain()
1021 if (cpu->pd_registered) in hybrid_update_perf_domain()
1022 em_adjust_cpu_capacity(cpu->cpu); in hybrid_update_perf_domain()
1032 arch_set_cpu_capacity(cpu->cpu, cpu->capacity_perf, in hybrid_set_cpu_capacity()
1033 hybrid_max_perf_cpu->capacity_perf, in hybrid_set_cpu_capacity()
1034 cpu->capacity_perf, in hybrid_set_cpu_capacity()
1035 cpu->pstate.max_pstate_physical); in hybrid_set_cpu_capacity()
1038 topology_set_cpu_scale(cpu->cpu, arch_scale_cpu_capacity(cpu->cpu)); in hybrid_set_cpu_capacity()
1040 pr_debug("CPU%d: perf = %u, max. perf = %u, base perf = %d\n", cpu->cpu, in hybrid_set_cpu_capacity()
1041 cpu->capacity_perf, hybrid_max_perf_cpu->capacity_perf, in hybrid_set_cpu_capacity()
1042 cpu->pstate.max_pstate_physical); in hybrid_set_cpu_capacity()
1053 cpu->capacity_perf = cpu->pstate.max_pstate_physical; in hybrid_get_capacity_perf()
1057 cpu->capacity_perf = HWP_HIGHEST_PERF(READ_ONCE(cpu->hwp_cap_cached)); in hybrid_get_capacity_perf()
1099 if (cpu->capacity_perf > max_cap_perf) { in hybrid_update_cpu_capacity_scaling()
1100 max_cap_perf = cpu->capacity_perf; in hybrid_update_cpu_capacity_scaling()
1136 /* Bail out if enabling capacity-aware scheduling is prohibited. */ in hybrid_init_cpu_capacity_scaling()
1181 rdmsrq_on_cpu(cpu->cpu, MSR_HWP_CAPABILITIES, &cap); in __intel_pstate_get_hwp_cap()
1182 WRITE_ONCE(cpu->hwp_cap_cached, cap); in __intel_pstate_get_hwp_cap()
1183 cpu->pstate.max_pstate = HWP_GUARANTEED_PERF(cap); in __intel_pstate_get_hwp_cap()
1184 cpu->pstate.turbo_pstate = HWP_HIGHEST_PERF(cap); in __intel_pstate_get_hwp_cap()
1189 int scaling = cpu->pstate.scaling; in intel_pstate_get_hwp_cap()
1193 cpu->pstate.max_freq = cpu->pstate.max_pstate * scaling; in intel_pstate_get_hwp_cap()
1194 cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * scaling; in intel_pstate_get_hwp_cap()
1195 if (scaling != cpu->pstate.perf_ctl_scaling) { in intel_pstate_get_hwp_cap()
1196 int perf_ctl_scaling = cpu->pstate.perf_ctl_scaling; in intel_pstate_get_hwp_cap()
1198 cpu->pstate.max_freq = rounddown(cpu->pstate.max_freq, in intel_pstate_get_hwp_cap()
1200 cpu->pstate.turbo_freq = rounddown(cpu->pstate.turbo_freq, in intel_pstate_get_hwp_cap()
1218 max_cap_perf = hybrid_max_perf_cpu->capacity_perf; in hybrid_update_capacity()
1224 if (cpu->capacity_perf > max_cap_perf) { in hybrid_update_capacity()
1231 if (cpu == hybrid_max_perf_cpu && cpu->capacity_perf < max_cap_perf) { in hybrid_update_capacity()
1243 if (hybrid_register_perf_domain(cpu->cpu)) in hybrid_update_capacity()
1253 int max, min; in intel_pstate_hwp_set() local
1257 max = cpu_data->max_perf_ratio; in intel_pstate_hwp_set()
1258 min = cpu_data->min_perf_ratio; in intel_pstate_hwp_set()
1260 if (cpu_data->policy == CPUFREQ_POLICY_PERFORMANCE) in intel_pstate_hwp_set()
1261 min = max; in intel_pstate_hwp_set()
1266 value |= HWP_MIN_PERF(min); in intel_pstate_hwp_set()
1271 if (cpu_data->epp_policy == cpu_data->policy) in intel_pstate_hwp_set()
1274 cpu_data->epp_policy = cpu_data->policy; in intel_pstate_hwp_set()
1276 if (cpu_data->policy == CPUFREQ_POLICY_PERFORMANCE) { in intel_pstate_hwp_set()
1278 cpu_data->epp_powersave = epp; in intel_pstate_hwp_set()
1286 if (cpu_data->epp_powersave < 0) in intel_pstate_hwp_set()
1292 * - Policy is not changed in intel_pstate_hwp_set()
1293 * - user has manually changed in intel_pstate_hwp_set()
1294 * - Error reading EPB in intel_pstate_hwp_set()
1300 epp = cpu_data->epp_powersave; in intel_pstate_hwp_set()
1308 WRITE_ONCE(cpu_data->hwp_req_cached, value); in intel_pstate_hwp_set()
1316 u64 value = READ_ONCE(cpu->hwp_req_cached); in intel_pstate_hwp_offline()
1328 value |= HWP_ENERGY_PERF_PREFERENCE(cpu->epp_cached); in intel_pstate_hwp_offline()
1334 cpu->epp_policy = CPUFREQ_POLICY_UNKNOWN; in intel_pstate_hwp_offline()
1343 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_pstate_hwp_offline()
1346 min_perf = HWP_LOWEST_PERF(READ_ONCE(cpu->hwp_cap_cached)); in intel_pstate_hwp_offline()
1352 /* Set EPP to min */ in intel_pstate_hwp_offline()
1356 wrmsrq_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value); in intel_pstate_hwp_offline()
1372 hybrid_clear_cpu_capacity(cpu->cpu); in intel_pstate_hwp_offline()
1405 wrmsrq_on_cpu(cpu->cpu, MSR_HWP_REQUEST, READ_ONCE(cpu->hwp_req_cached)); in intel_pstate_hwp_reenable()
1410 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_suspend()
1412 pr_debug("CPU %d suspending\n", cpu->cpu); in intel_pstate_suspend()
1414 cpu->suspended = true; in intel_pstate_suspend()
1424 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_resume()
1426 pr_debug("CPU %d resuming\n", cpu->cpu); in intel_pstate_resume()
1434 if (cpu->suspended && hwp_active) { in intel_pstate_resume()
1437 /* Re-enable HWP, because "online" has not done that. */ in intel_pstate_resume()
1443 cpu->suspended = false; in intel_pstate_resume()
1464 policy->cpuinfo.max_freq = READ_ONCE(global.no_turbo) ? in __intel_pstate_update_max_freq()
1465 cpudata->pstate.max_freq : cpudata->pstate.turbo_freq; in __intel_pstate_update_max_freq()
1472 struct cpufreq_policy *policy __free(put_cpufreq_policy) = cpufreq_cpu_get(cpudata->cpu); in intel_pstate_update_max_freq()
1483 struct cpudata *cpudata = all_cpu_data[policy->cpu]; in intel_pstate_update_limits()
1535 ret = intel_pstate_update_status(buf, p ? p - buf : count); in store_status()
1552 return -EAGAIN; in show_turbo_pct()
1557 total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate + 1; in show_turbo_pct()
1558 no_turbo = cpu->pstate.max_pstate - cpu->pstate.min_pstate + 1; in show_turbo_pct()
1560 turbo_pct = 100 - fp_toint(mul_fp(turbo_fp, int_tofp(100))); in show_turbo_pct()
1577 return -EAGAIN; in show_num_pstates()
1581 total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate + 1; in show_num_pstates()
1597 return -EAGAIN; in show_no_turbo()
1614 return -EINVAL; in store_no_turbo()
1619 count = -EAGAIN; in store_no_turbo()
1628 count = -EPERM; in store_no_turbo()
1645 int pct = cpu->pstate.max_pstate * 100 / cpu->pstate.turbo_pstate; in store_no_turbo()
1666 unsigned int freq = cpudata->pstate.turbo_freq; in update_cpu_qos_request() local
1673 req = policy->driver_data; in update_cpu_qos_request()
1681 freq = DIV_ROUND_UP(freq * global.min_perf_pct, 100); in update_cpu_qos_request()
1684 freq = (freq * global.max_perf_pct) / 100; in update_cpu_qos_request()
1687 if (freq_qos_update_request(req, freq) < 0) in update_cpu_qos_request()
1688 pr_warn("Failed to update freq constraint: CPU%d\n", cpu); in update_cpu_qos_request()
1707 return -EINVAL; in store_max_perf_pct()
1713 return -EAGAIN; in store_max_perf_pct()
1740 return -EINVAL; in store_min_perf_pct()
1746 return -EAGAIN; in store_min_perf_pct()
1849 intel_pstate_kobject = kobject_create_and_add("intel_pstate", &dev_root->kobj); in intel_pstate_sysfs_expose_params()
1944 wrmsrq_on_cpu(cpudata->cpu, MSR_HWP_STATUS, 0); in intel_pstate_notify_work()
1975 schedule_delayed_work(&all_cpu_data[this_cpu]->hwp_notify_work, in notify_hwp_interrupt()
1995 wrmsrq_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x00); in intel_pstate_disable_hwp_interrupt()
1998 cancel_work = cpumask_test_and_clear_cpu(cpudata->cpu, &hwp_intr_enable_mask); in intel_pstate_disable_hwp_interrupt()
2002 cancel_delayed_work_sync(&cpudata->hwp_notify_work); in intel_pstate_disable_hwp_interrupt()
2015 INIT_DELAYED_WORK(&cpudata->hwp_notify_work, intel_pstate_notify_work); in intel_pstate_enable_hwp_interrupt()
2016 cpumask_set_cpu(cpudata->cpu, &hwp_intr_enable_mask); in intel_pstate_enable_hwp_interrupt()
2023 wrmsrq_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, interrupt_mask); in intel_pstate_enable_hwp_interrupt()
2024 wrmsrq_on_cpu(cpudata->cpu, MSR_HWP_STATUS, 0); in intel_pstate_enable_hwp_interrupt()
2030 cpudata->epp_default = intel_pstate_get_epp(cpudata, 0); in intel_pstate_update_epp_defaults()
2034 * - Is equal or less than 0x80 (default balance_perf EPP) in intel_pstate_update_epp_defaults()
2035 * - But less performance oriented than performance EPP in intel_pstate_update_epp_defaults()
2038 if (hwp_forced && cpudata->epp_default <= HWP_EPP_BALANCE_PERFORMANCE && in intel_pstate_update_epp_defaults()
2039 cpudata->epp_default > HWP_EPP_PERFORMANCE) { in intel_pstate_update_epp_defaults()
2040 epp_values[EPP_INDEX_BALANCE_PERFORMANCE] = cpudata->epp_default; in intel_pstate_update_epp_defaults()
2055 cpudata->epp_default = epp_values[EPP_INDEX_BALANCE_PERFORMANCE]; in intel_pstate_update_epp_defaults()
2056 intel_pstate_set_epp(cpudata, cpudata->epp_default); in intel_pstate_update_epp_defaults()
2063 wrmsrq_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x00); in intel_pstate_hwp_enable()
2065 wrmsrq_on_cpu(cpudata->cpu, MSR_PM_ENABLE, 0x1); in intel_pstate_hwp_enable()
2069 if (cpudata->epp_default >= 0) in intel_pstate_hwp_enable()
2110 vid_fp = cpudata->vid.min + mul_fp( in atom_get_val()
2111 int_tofp(pstate - cpudata->pstate.min_pstate), in atom_get_val()
2112 cpudata->vid.ratio); in atom_get_val()
2114 vid_fp = clamp_t(int32_t, vid_fp, cpudata->vid.min, cpudata->vid.max); in atom_get_val()
2117 if (pstate > cpudata->pstate.max_pstate) in atom_get_val()
2118 vid = cpudata->vid.turbo; in atom_get_val()
2127 /* Defined in Table 35-6 from SDM (Sept 2015) */ in silvermont_get_scaling()
2142 /* Defined in Table 35-10 from SDM (Sept 2015) */ in airmont_get_scaling()
2159 cpudata->vid.min = int_tofp((value >> 8) & 0x7f); in atom_get_vid()
2160 cpudata->vid.max = int_tofp((value >> 16) & 0x7f); in atom_get_vid()
2161 cpudata->vid.ratio = div_fp( in atom_get_vid()
2162 cpudata->vid.max - cpudata->vid.min, in atom_get_vid()
2163 int_tofp(cpudata->pstate.max_pstate - in atom_get_vid()
2164 cpudata->pstate.min_pstate)); in atom_get_vid()
2167 cpudata->vid.turbo = value & 0x7f; in atom_get_vid()
2216 return -ENXIO; in core_get_tdp_ratio()
2245 if (tdp_ratio - 1 == tar_levels) { in core_get_max_pstate()
2301 u8 cpu_type = c->topo.intel_type; in hwp_get_cpu_scaling()
2304 * Return the hybrid scaling factor for P-cores and use the in hwp_get_cpu_scaling()
2305 * default core scaling for E-cores. in hwp_get_cpu_scaling()
2314 /* Use core scaling on non-hybrid systems. */ in hwp_get_cpu_scaling()
2328 trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu); in intel_pstate_set_pstate()
2329 cpu->pstate.current_pstate = pstate; in intel_pstate_set_pstate()
2335 wrmsrq_on_cpu(cpu->cpu, MSR_IA32_PERF_CTL, in intel_pstate_set_pstate()
2341 intel_pstate_set_pstate(cpu, cpu->pstate.min_pstate); in intel_pstate_set_min_pstate()
2346 int perf_ctl_max_phys = pstate_funcs.get_max_physical(cpu->cpu); in intel_pstate_get_cpu_pstates()
2349 cpu->pstate.min_pstate = pstate_funcs.get_min(cpu->cpu); in intel_pstate_get_cpu_pstates()
2350 cpu->pstate.max_pstate_physical = perf_ctl_max_phys; in intel_pstate_get_cpu_pstates()
2351 cpu->pstate.perf_ctl_scaling = perf_ctl_scaling; in intel_pstate_get_cpu_pstates()
2357 cpu->pstate.scaling = pstate_funcs.get_cpu_scaling(cpu->cpu); in intel_pstate_get_cpu_pstates()
2358 if (cpu->pstate.scaling != perf_ctl_scaling) { in intel_pstate_get_cpu_pstates()
2363 cpu->pstate.scaling = perf_ctl_scaling; in intel_pstate_get_cpu_pstates()
2371 cpu->pstate.scaling = perf_ctl_scaling; in intel_pstate_get_cpu_pstates()
2372 cpu->pstate.max_pstate = pstate_funcs.get_max(cpu->cpu); in intel_pstate_get_cpu_pstates()
2373 cpu->pstate.turbo_pstate = pstate_funcs.get_turbo(cpu->cpu); in intel_pstate_get_cpu_pstates()
2376 if (cpu->pstate.scaling == perf_ctl_scaling) { in intel_pstate_get_cpu_pstates()
2377 cpu->pstate.min_freq = cpu->pstate.min_pstate * perf_ctl_scaling; in intel_pstate_get_cpu_pstates()
2378 cpu->pstate.max_freq = cpu->pstate.max_pstate * perf_ctl_scaling; in intel_pstate_get_cpu_pstates()
2379 cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * perf_ctl_scaling; in intel_pstate_get_cpu_pstates()
2383 cpu->aperf_mperf_shift = pstate_funcs.get_aperf_mperf_shift(); in intel_pstate_get_cpu_pstates()
2401 u64 hwp_req = READ_ONCE(cpu->hwp_req_cached); in intel_pstate_hwp_boost_up()
2402 u64 hwp_cap = READ_ONCE(cpu->hwp_cap_cached); in intel_pstate_hwp_boost_up()
2409 * If, P0 (Turbo max) = P1 (Guaranteed max) = min: in intel_pstate_hwp_boost_up()
2411 * If, P0 (Turbo max) > P1 (Guaranteed max) = min: in intel_pstate_hwp_boost_up()
2413 * If, P0 (Turbo max) = P1 (Guaranteed max) > min: in intel_pstate_hwp_boost_up()
2415 * (min + p1)/2 and P1. in intel_pstate_hwp_boost_up()
2416 * If, P0 (Turbo max) > P1 (Guaranteed max) > min: in intel_pstate_hwp_boost_up()
2418 * (min + p1)/2, P1 and P0. in intel_pstate_hwp_boost_up()
2421 /* If max and min are equal or already at max, nothing to boost */ in intel_pstate_hwp_boost_up()
2422 if (max_limit == min_limit || cpu->hwp_boost_min >= max_limit) in intel_pstate_hwp_boost_up()
2425 if (!cpu->hwp_boost_min) in intel_pstate_hwp_boost_up()
2426 cpu->hwp_boost_min = min_limit; in intel_pstate_hwp_boost_up()
2428 /* level at half way mark between min and guranteed */ in intel_pstate_hwp_boost_up()
2431 if (cpu->hwp_boost_min < boost_level1) in intel_pstate_hwp_boost_up()
2432 cpu->hwp_boost_min = boost_level1; in intel_pstate_hwp_boost_up()
2433 else if (cpu->hwp_boost_min < HWP_GUARANTEED_PERF(hwp_cap)) in intel_pstate_hwp_boost_up()
2434 cpu->hwp_boost_min = HWP_GUARANTEED_PERF(hwp_cap); in intel_pstate_hwp_boost_up()
2435 else if (cpu->hwp_boost_min == HWP_GUARANTEED_PERF(hwp_cap) && in intel_pstate_hwp_boost_up()
2437 cpu->hwp_boost_min = max_limit; in intel_pstate_hwp_boost_up()
2441 hwp_req = (hwp_req & ~GENMASK_ULL(7, 0)) | cpu->hwp_boost_min; in intel_pstate_hwp_boost_up()
2443 cpu->last_update = cpu->sample.time; in intel_pstate_hwp_boost_up()
2448 if (cpu->hwp_boost_min) { in intel_pstate_hwp_boost_down()
2452 expired = time_after64(cpu->sample.time, cpu->last_update + in intel_pstate_hwp_boost_down()
2455 wrmsrq(MSR_HWP_REQUEST, cpu->hwp_req_cached); in intel_pstate_hwp_boost_down()
2456 cpu->hwp_boost_min = 0; in intel_pstate_hwp_boost_down()
2459 cpu->last_update = cpu->sample.time; in intel_pstate_hwp_boost_down()
2465 cpu->sample.time = time; in intel_pstate_update_util_hwp_local()
2467 if (cpu->sched_flags & SCHED_CPUFREQ_IOWAIT) { in intel_pstate_update_util_hwp_local()
2470 cpu->sched_flags = 0; in intel_pstate_update_util_hwp_local()
2478 if (time_before64(time, cpu->last_io_update + 2 * TICK_NSEC)) in intel_pstate_update_util_hwp_local()
2481 cpu->last_io_update = time; in intel_pstate_update_util_hwp_local()
2496 cpu->sched_flags |= flags; in intel_pstate_update_util_hwp()
2498 if (smp_processor_id() == cpu->cpu) in intel_pstate_update_util_hwp()
2504 struct sample *sample = &cpu->sample; in intel_pstate_calc_avg_perf()
2506 sample->core_avg_perf = div_ext_fp(sample->aperf, sample->mperf); in intel_pstate_calc_avg_perf()
2519 if (cpu->prev_mperf == mperf || cpu->prev_tsc == tsc) { in intel_pstate_sample()
2525 cpu->last_sample_time = cpu->sample.time; in intel_pstate_sample()
2526 cpu->sample.time = time; in intel_pstate_sample()
2527 cpu->sample.aperf = aperf; in intel_pstate_sample()
2528 cpu->sample.mperf = mperf; in intel_pstate_sample()
2529 cpu->sample.tsc = tsc; in intel_pstate_sample()
2530 cpu->sample.aperf -= cpu->prev_aperf; in intel_pstate_sample()
2531 cpu->sample.mperf -= cpu->prev_mperf; in intel_pstate_sample()
2532 cpu->sample.tsc -= cpu->prev_tsc; in intel_pstate_sample()
2534 cpu->prev_aperf = aperf; in intel_pstate_sample()
2535 cpu->prev_mperf = mperf; in intel_pstate_sample()
2536 cpu->prev_tsc = tsc; in intel_pstate_sample()
2544 if (likely(cpu->last_sample_time)) { in intel_pstate_sample()
2553 return mul_ext_fp(cpu->sample.core_avg_perf, cpu_khz); in get_avg_frequency()
2558 return mul_ext_fp(cpu->pstate.max_pstate_physical, in get_avg_pstate()
2559 cpu->sample.core_avg_perf); in get_avg_pstate()
2564 struct sample *sample = &cpu->sample; in get_target_pstate()
2568 busy_frac = div_fp(sample->mperf << cpu->aperf_mperf_shift, in get_target_pstate()
2569 sample->tsc); in get_target_pstate()
2571 if (busy_frac < cpu->iowait_boost) in get_target_pstate()
2572 busy_frac = cpu->iowait_boost; in get_target_pstate()
2574 sample->busy_scaled = busy_frac * 100; in get_target_pstate()
2577 cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; in get_target_pstate()
2580 if (target < cpu->pstate.min_pstate) in get_target_pstate()
2581 target = cpu->pstate.min_pstate; in get_target_pstate()
2584 * If the average P-state during the previous cycle was higher than the in get_target_pstate()
2592 target += (avg_pstate - target) >> 1; in get_target_pstate()
2599 int min_pstate = max(cpu->pstate.min_pstate, cpu->min_perf_ratio); in intel_pstate_prepare_request()
2600 int max_pstate = max(min_pstate, cpu->max_perf_ratio); in intel_pstate_prepare_request()
2607 if (pstate == cpu->pstate.current_pstate) in intel_pstate_update_pstate()
2610 cpu->pstate.current_pstate = pstate; in intel_pstate_update_pstate()
2616 int from = cpu->pstate.current_pstate; in intel_pstate_adjust_pstate()
2622 trace_cpu_frequency(target_pstate * cpu->pstate.scaling, cpu->cpu); in intel_pstate_adjust_pstate()
2625 sample = &cpu->sample; in intel_pstate_adjust_pstate()
2626 trace_pstate_sample(mul_ext_fp(100, sample->core_avg_perf), in intel_pstate_adjust_pstate()
2627 fp_toint(sample->busy_scaled), in intel_pstate_adjust_pstate()
2629 cpu->pstate.current_pstate, in intel_pstate_adjust_pstate()
2630 sample->mperf, in intel_pstate_adjust_pstate()
2631 sample->aperf, in intel_pstate_adjust_pstate()
2632 sample->tsc, in intel_pstate_adjust_pstate()
2634 fp_toint(cpu->iowait_boost * 100)); in intel_pstate_adjust_pstate()
2644 if (smp_processor_id() != cpu->cpu) in intel_pstate_update_util()
2647 delta_ns = time - cpu->last_update; in intel_pstate_update_util()
2651 cpu->iowait_boost = ONE_EIGHTH_FP; in intel_pstate_update_util()
2652 } else if (cpu->iowait_boost >= ONE_EIGHTH_FP) { in intel_pstate_update_util()
2653 cpu->iowait_boost <<= 1; in intel_pstate_update_util()
2654 if (cpu->iowait_boost > int_tofp(1)) in intel_pstate_update_util()
2655 cpu->iowait_boost = int_tofp(1); in intel_pstate_update_util()
2657 cpu->iowait_boost = ONE_EIGHTH_FP; in intel_pstate_update_util()
2659 } else if (cpu->iowait_boost) { in intel_pstate_update_util()
2662 cpu->iowait_boost = 0; in intel_pstate_update_util()
2664 cpu->iowait_boost >>= 1; in intel_pstate_update_util()
2666 cpu->last_update = time; in intel_pstate_update_util()
2667 delta_ns = time - cpu->sample.time; in intel_pstate_update_util()
2781 return -ENOMEM; in intel_pstate_init_cpu()
2785 cpu->cpu = cpunum; in intel_pstate_init_cpu()
2787 cpu->epp_default = -EINVAL; in intel_pstate_init_cpu()
2797 * Re-enable HWP in case this happens after a resume from ACPI in intel_pstate_init_cpu()
2804 cpu->epp_powersave = -EINVAL; in intel_pstate_init_cpu()
2805 cpu->epp_policy = CPUFREQ_POLICY_UNKNOWN; in intel_pstate_init_cpu()
2821 if (cpu->update_util_set) in intel_pstate_set_update_util_hook()
2825 cpu->sample.time = 0; in intel_pstate_set_update_util_hook()
2826 cpufreq_add_update_util_hook(cpu_num, &cpu->update_util, in intel_pstate_set_update_util_hook()
2830 cpu->update_util_set = true; in intel_pstate_set_update_util_hook()
2837 if (!cpu_data->update_util_set) in intel_pstate_clear_update_util_hook()
2841 cpu_data->update_util_set = false; in intel_pstate_clear_update_util_hook()
2848 cpu->pstate.max_freq : cpu->pstate.turbo_freq; in intel_pstate_get_max_freq()
2855 int perf_ctl_scaling = cpu->pstate.perf_ctl_scaling; in intel_pstate_update_perf_limits()
2871 if (hwp_active && cpu->pstate.scaling != perf_ctl_scaling) { in intel_pstate_update_perf_limits()
2872 int freq; in intel_pstate_update_perf_limits() local
2874 freq = max_policy_perf * perf_ctl_scaling; in intel_pstate_update_perf_limits()
2875 max_policy_perf = intel_pstate_freq_to_hwp(cpu, freq); in intel_pstate_update_perf_limits()
2876 freq = min_policy_perf * perf_ctl_scaling; in intel_pstate_update_perf_limits()
2877 min_policy_perf = intel_pstate_freq_to_hwp(cpu, freq); in intel_pstate_update_perf_limits()
2881 cpu->cpu, min_policy_perf, max_policy_perf); in intel_pstate_update_perf_limits()
2885 cpu->min_perf_ratio = min_policy_perf; in intel_pstate_update_perf_limits()
2886 cpu->max_perf_ratio = max_policy_perf; in intel_pstate_update_perf_limits()
2888 int turbo_max = cpu->pstate.turbo_pstate; in intel_pstate_update_perf_limits()
2891 /* Global limits are in percent of the maximum turbo P-state. */ in intel_pstate_update_perf_limits()
2896 pr_debug("cpu:%d global_min:%d global_max:%d\n", cpu->cpu, in intel_pstate_update_perf_limits()
2899 cpu->min_perf_ratio = max(min_policy_perf, global_min); in intel_pstate_update_perf_limits()
2900 cpu->min_perf_ratio = min(cpu->min_perf_ratio, max_policy_perf); in intel_pstate_update_perf_limits()
2901 cpu->max_perf_ratio = min(max_policy_perf, global_max); in intel_pstate_update_perf_limits()
2902 cpu->max_perf_ratio = max(min_policy_perf, cpu->max_perf_ratio); in intel_pstate_update_perf_limits()
2905 cpu->min_perf_ratio = min(cpu->min_perf_ratio, in intel_pstate_update_perf_limits()
2906 cpu->max_perf_ratio); in intel_pstate_update_perf_limits()
2909 pr_debug("cpu:%d max_perf_ratio:%d min_perf_ratio:%d\n", cpu->cpu, in intel_pstate_update_perf_limits()
2910 cpu->max_perf_ratio, in intel_pstate_update_perf_limits()
2911 cpu->min_perf_ratio); in intel_pstate_update_perf_limits()
2918 if (!policy->cpuinfo.max_freq) in intel_pstate_set_policy()
2919 return -ENODEV; in intel_pstate_set_policy()
2921 pr_debug("set_policy cpuinfo.max %u policy->max %u\n", in intel_pstate_set_policy()
2922 policy->cpuinfo.max_freq, policy->max); in intel_pstate_set_policy()
2924 cpu = all_cpu_data[policy->cpu]; in intel_pstate_set_policy()
2925 cpu->policy = policy->policy; in intel_pstate_set_policy()
2929 intel_pstate_update_perf_limits(cpu, policy->min, policy->max); in intel_pstate_set_policy()
2931 if (cpu->policy == CPUFREQ_POLICY_PERFORMANCE) { in intel_pstate_set_policy()
2932 int pstate = max(cpu->pstate.min_pstate, cpu->max_perf_ratio); in intel_pstate_set_policy()
2938 intel_pstate_clear_update_util_hook(policy->cpu); in intel_pstate_set_policy()
2941 intel_pstate_set_update_util_hook(policy->cpu); in intel_pstate_set_policy()
2951 intel_pstate_clear_update_util_hook(policy->cpu); in intel_pstate_set_policy()
2952 intel_pstate_hwp_set(policy->cpu); in intel_pstate_set_policy()
2955 * policy->cur is never updated with the intel_pstate driver, but it in intel_pstate_set_policy()
2958 policy->cur = policy->min; in intel_pstate_set_policy()
2969 cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate && in intel_pstate_adjust_policy_max()
2970 policy->max < policy->cpuinfo.max_freq && in intel_pstate_adjust_policy_max()
2971 policy->max > cpu->pstate.max_freq) { in intel_pstate_adjust_policy_max()
2972 pr_debug("policy->max > max non turbo frequency\n"); in intel_pstate_adjust_policy_max()
2973 policy->max = policy->cpuinfo.max_freq; in intel_pstate_adjust_policy_max()
2985 cpu->pstate.max_freq : cpu->pstate.turbo_freq; in intel_pstate_verify_cpu_policy()
2989 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, max_freq); in intel_pstate_verify_cpu_policy()
2996 intel_pstate_verify_cpu_policy(all_cpu_data[policy->cpu], policy); in intel_pstate_verify_policy()
3003 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_cpu_offline()
3005 pr_debug("CPU %d going offline\n", cpu->cpu); in intel_cpufreq_cpu_offline()
3007 if (cpu->suspended) in intel_cpufreq_cpu_offline()
3028 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_cpu_online()
3030 pr_debug("CPU %d going online\n", cpu->cpu); in intel_pstate_cpu_online()
3036 * Re-enable HWP and clear the "suspended" flag to let "resume" in intel_pstate_cpu_online()
3040 cpu->suspended = false; in intel_pstate_cpu_online()
3050 intel_pstate_clear_update_util_hook(policy->cpu); in intel_pstate_cpu_offline()
3057 pr_debug("CPU %d exiting\n", policy->cpu); in intel_pstate_cpu_exit()
3059 policy->fast_switch_possible = false; in intel_pstate_cpu_exit()
3067 rc = intel_pstate_init_cpu(policy->cpu); in __intel_pstate_cpu_init()
3071 cpu = all_cpu_data[policy->cpu]; in __intel_pstate_cpu_init()
3073 cpu->max_perf_ratio = 0xFF; in __intel_pstate_cpu_init()
3074 cpu->min_perf_ratio = 0; in __intel_pstate_cpu_init()
3077 policy->cpuinfo.min_freq = cpu->pstate.min_freq; in __intel_pstate_cpu_init()
3078 policy->cpuinfo.max_freq = READ_ONCE(global.no_turbo) ? in __intel_pstate_cpu_init()
3079 cpu->pstate.max_freq : cpu->pstate.turbo_freq; in __intel_pstate_cpu_init()
3081 policy->min = policy->cpuinfo.min_freq; in __intel_pstate_cpu_init()
3082 policy->max = policy->cpuinfo.max_freq; in __intel_pstate_cpu_init()
3086 policy->fast_switch_possible = true; in __intel_pstate_cpu_init()
3102 policy->policy = CPUFREQ_POLICY_POWERSAVE; in intel_pstate_cpu_init()
3105 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_pstate_cpu_init()
3107 cpu->epp_cached = intel_pstate_get_epp(cpu, 0); in intel_pstate_cpu_init()
3129 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_verify_policy()
3132 intel_pstate_update_perf_limits(cpu, policy->min, policy->max); in intel_cpufreq_verify_policy()
3141 * core_avg_perf) is not needed and so is re-assigned to indicate if the
3144 * (or performance or core_avg_perf) have a fixed y-axis from 0 to 100%,
3163 sample = &cpu->sample; in intel_cpufreq_trace()
3167 cpu->pstate.current_pstate, in intel_cpufreq_trace()
3168 sample->mperf, in intel_cpufreq_trace()
3169 sample->aperf, in intel_cpufreq_trace()
3170 sample->tsc, in intel_cpufreq_trace()
3172 fp_toint(cpu->iowait_boost * 100)); in intel_cpufreq_trace()
3175 static void intel_cpufreq_hwp_update(struct cpudata *cpu, u32 min, u32 max, in intel_cpufreq_hwp_update() argument
3178 u64 prev = READ_ONCE(cpu->hwp_req_cached), value = prev; in intel_cpufreq_hwp_update()
3181 value |= HWP_MIN_PERF(min); in intel_cpufreq_hwp_update()
3192 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_cpufreq_hwp_update()
3196 wrmsrq_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value); in intel_cpufreq_hwp_update()
3206 wrmsrq_on_cpu(cpu->cpu, MSR_IA32_PERF_CTL, in intel_cpufreq_perf_ctl_update()
3213 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_update_pstate()
3214 int old_pstate = cpu->pstate.current_pstate; in intel_cpufreq_update_pstate()
3218 int max_pstate = policy->strict_target ? in intel_cpufreq_update_pstate()
3219 target_pstate : cpu->max_perf_ratio; in intel_cpufreq_update_pstate()
3227 cpu->pstate.current_pstate = target_pstate; in intel_cpufreq_update_pstate()
3239 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_target()
3243 freqs.old = policy->cur; in intel_cpufreq_target()
3251 freqs.new = target_pstate * cpu->pstate.scaling; in intel_cpufreq_target()
3261 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_fast_switch()
3268 return target_pstate * cpu->pstate.scaling; in intel_cpufreq_fast_switch()
3277 u64 hwp_cap = READ_ONCE(cpu->hwp_cap_cached); in intel_cpufreq_adjust_perf()
3278 int old_pstate = cpu->pstate.current_pstate; in intel_cpufreq_adjust_perf()
3295 if (min_pstate < cpu->pstate.min_pstate) in intel_cpufreq_adjust_perf()
3296 min_pstate = cpu->pstate.min_pstate; in intel_cpufreq_adjust_perf()
3298 if (min_pstate < cpu->min_perf_ratio) in intel_cpufreq_adjust_perf()
3299 min_pstate = cpu->min_perf_ratio; in intel_cpufreq_adjust_perf()
3301 if (min_pstate > cpu->max_perf_ratio) in intel_cpufreq_adjust_perf()
3302 min_pstate = cpu->max_perf_ratio; in intel_cpufreq_adjust_perf()
3304 max_pstate = min(cap_pstate, cpu->max_perf_ratio); in intel_cpufreq_adjust_perf()
3312 cpu->pstate.current_pstate = target_pstate; in intel_cpufreq_adjust_perf()
3321 int ret, freq; in intel_cpufreq_cpu_init() local
3323 dev = get_cpu_device(policy->cpu); in intel_cpufreq_cpu_init()
3325 return -ENODEV; in intel_cpufreq_cpu_init()
3331 policy->cpuinfo.transition_latency = INTEL_CPUFREQ_TRANSITION_LATENCY; in intel_cpufreq_cpu_init()
3333 policy->cur = policy->cpuinfo.min_freq; in intel_cpufreq_cpu_init()
3337 ret = -ENOMEM; in intel_cpufreq_cpu_init()
3341 cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_cpu_init()
3346 policy->transition_delay_us = INTEL_CPUFREQ_TRANSITION_DELAY_HWP; in intel_cpufreq_cpu_init()
3350 rdmsrq_on_cpu(cpu->cpu, MSR_HWP_REQUEST, &value); in intel_cpufreq_cpu_init()
3351 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_cpufreq_cpu_init()
3353 cpu->epp_cached = intel_pstate_get_epp(cpu, value); in intel_cpufreq_cpu_init()
3355 policy->transition_delay_us = INTEL_CPUFREQ_TRANSITION_DELAY; in intel_cpufreq_cpu_init()
3358 freq = DIV_ROUND_UP(cpu->pstate.turbo_freq * global.min_perf_pct, 100); in intel_cpufreq_cpu_init()
3360 ret = freq_qos_add_request(&policy->constraints, req, FREQ_QOS_MIN, in intel_cpufreq_cpu_init()
3361 freq); in intel_cpufreq_cpu_init()
3363 dev_err(dev, "Failed to add min-freq constraint (%d)\n", ret); in intel_cpufreq_cpu_init()
3367 freq = DIV_ROUND_UP(cpu->pstate.turbo_freq * global.max_perf_pct, 100); in intel_cpufreq_cpu_init()
3369 ret = freq_qos_add_request(&policy->constraints, req + 1, FREQ_QOS_MAX, in intel_cpufreq_cpu_init()
3370 freq); in intel_cpufreq_cpu_init()
3372 dev_err(dev, "Failed to add max-freq constraint (%d)\n", ret); in intel_cpufreq_cpu_init()
3376 policy->driver_data = req; in intel_cpufreq_cpu_init()
3394 req = policy->driver_data; in intel_cpufreq_cpu_exit()
3408 struct cpudata *cpu = all_cpu_data[policy->cpu]; in intel_cpufreq_suspend()
3409 u64 value = READ_ONCE(cpu->hwp_req_cached); in intel_cpufreq_suspend()
3417 wrmsrq_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value); in intel_cpufreq_suspend()
3418 WRITE_ONCE(cpu->hwp_req_cached, value); in intel_cpufreq_suspend()
3504 return -EINVAL; in intel_pstate_update_status()
3507 return -EBUSY; in intel_pstate_update_status()
3537 return -EINVAL; in intel_pstate_update_status()
3550 return -ENODEV; in intel_pstate_msrs_not_valid()
3557 pstate_funcs.get_max = funcs->get_max; in copy_cpu_funcs()
3558 pstate_funcs.get_max_physical = funcs->get_max_physical; in copy_cpu_funcs()
3559 pstate_funcs.get_min = funcs->get_min; in copy_cpu_funcs()
3560 pstate_funcs.get_turbo = funcs->get_turbo; in copy_cpu_funcs()
3561 pstate_funcs.get_scaling = funcs->get_scaling; in copy_cpu_funcs()
3562 pstate_funcs.get_val = funcs->get_val; in copy_cpu_funcs()
3563 pstate_funcs.get_vid = funcs->get_vid; in copy_cpu_funcs()
3564 pstate_funcs.get_aperf_mperf_shift = funcs->get_aperf_mperf_shift; in copy_cpu_funcs()
3582 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer); in intel_pstate_no_acpi_pss()
3587 if (pss && pss->type == ACPI_TYPE_PACKAGE) { in intel_pstate_no_acpi_pss()
3625 if (acpi_has_method(pr->handle, "_PPC")) in intel_pstate_has_acpi_ppc()
3637 /* Hardware vendor-specific info that has its own power management modes */
3640 {"ORACLE", "X4-2 ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
3641 {"ORACLE", "X4-2L ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
3642 {"ORACLE", "X4-2B ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
3643 {"ORACLE", "X3-2 ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
3644 {"ORACLE", "X3-2L ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
3645 {"ORACLE", "X3-2B ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
3652 {"ORACLE", "X6-2 ", 0, ACPI_SIG_FADT, all_versions, NULL, PPC},
3695 * It may be unsafe to request P-states control from SMM if _PPC support in intel_pstate_request_control_from_smm()
3776 /* Without EPP support, don't expose EPP-related sysfs attributes. */ in hwp_check_epp()
3798 return -ENODEV; in intel_pstate_init()
3805 pr_info("P-states controlled by the platform\n"); in intel_pstate_init()
3806 return -ENODEV; in intel_pstate_init()
3822 return -ENODEV; in intel_pstate_init()
3838 hwp_mode_bdw = id->driver_data; in intel_pstate_init()
3853 return -ENODEV; in intel_pstate_init()
3858 return -ENODEV; in intel_pstate_init()
3861 copy_cpu_funcs((struct pstate_funcs *)id->driver_data); in intel_pstate_init()
3866 return -ENODEV; in intel_pstate_init()
3874 return -ENOTSUPP; in intel_pstate_init()
3876 pr_info("Intel P-state driver initializing\n"); in intel_pstate_init()
3880 return -ENOMEM; in intel_pstate_init()
3894 FIELD_GET(POWERSAVE_MASK, id->driver_data); in intel_pstate_init()
3896 FIELD_GET(BALANCE_POWER_MASK, id->driver_data); in intel_pstate_init()
3898 FIELD_GET(BALANCE_PERFORMANCE_MASK, id->driver_data); in intel_pstate_init()
3900 FIELD_GET(PERFORMANCE_MASK, id->driver_data); in intel_pstate_init()
3909 hybrid_scaling_factor = hybrid_id->driver_data; in intel_pstate_init()
3944 return -EINVAL; in intel_pstate_setup()
3976 MODULE_DESCRIPTION("'intel_pstate' - P state driver Intel Core processors");