Skip to content

Commit 86d333a

Browse files
spandruvadarafaeljw
authored andcommitted
cpufreq: intel_pstate: Add base_frequency attribute
Expose base_frequency to user space via cpufreq sysfs when HWP is in use. This HWP base frequency is read from the ACPI _CPC object if present, or from the HWP Capabilities MSR otherwise. On the majority of the HWP platforms the _CPC object will point to the HWP Capabilities MSR using the "Functional Fixed Hardware" address space type. The address space type also can simply be ACPI_TYPE_INTEGER, however, in which case the platform firmware can set its value at the initialization time based on the system constraints. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> [ rjw: Changelog ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 29523f0 commit 86d333a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,28 @@ static void intel_pstate_set_itmt_prio(int cpu)
373373
}
374374
}
375375
}
376+
377+
static int intel_pstate_get_cppc_guranteed(int cpu)
378+
{
379+
struct cppc_perf_caps cppc_perf;
380+
int ret;
381+
382+
ret = cppc_get_perf_caps(cpu, &cppc_perf);
383+
if (ret)
384+
return ret;
385+
386+
return cppc_perf.guaranteed_perf;
387+
}
388+
376389
#else
377390
static void intel_pstate_set_itmt_prio(int cpu)
378391
{
379392
}
393+
394+
static int intel_pstate_get_cppc_guranteed(int cpu)
395+
{
396+
return -ENOTSUPP;
397+
}
380398
#endif
381399

382400
static void intel_pstate_init_acpi_perf_limits(struct cpufreq_policy *policy)
@@ -699,9 +717,29 @@ static ssize_t show_energy_performance_preference(
699717

700718
cpufreq_freq_attr_rw(energy_performance_preference);
701719

720+
static ssize_t show_base_frequency(struct cpufreq_policy *policy, char *buf)
721+
{
722+
struct cpudata *cpu;
723+
u64 cap;
724+
int ratio;
725+
726+
ratio = intel_pstate_get_cppc_guranteed(policy->cpu);
727+
if (ratio <= 0) {
728+
rdmsrl_on_cpu(policy->cpu, MSR_HWP_CAPABILITIES, &cap);
729+
ratio = HWP_GUARANTEED_PERF(cap);
730+
}
731+
732+
cpu = all_cpu_data[policy->cpu];
733+
734+
return sprintf(buf, "%d\n", ratio * cpu->pstate.scaling);
735+
}
736+
737+
cpufreq_freq_attr_ro(base_frequency);
738+
702739
static struct freq_attr *hwp_cpufreq_attrs[] = {
703740
&energy_performance_preference,
704741
&energy_performance_available_preferences,
742+
&base_frequency,
705743
NULL,
706744
};
707745

0 commit comments

Comments
 (0)