Skip to content

Commit

Permalink
cpufreq: amd: add amd-pstate performance attributes
Browse files Browse the repository at this point in the history
Introduce sysfs attributes to get the different level amd-pstate
performances.

Signed-off-by: Huang Rui <ray.huang@amd.com>
  • Loading branch information
huangrui authored and xanmod committed Nov 4, 2021
1 parent dd80c52 commit b89d41f
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions drivers/cpufreq/amd-pstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,14 +536,67 @@ static ssize_t show_amd_pstate_lowest_nonlinear_freq(struct cpufreq_policy *poli
return sprintf(&buf[0], "%u\n", freq);
}

static ssize_t show_amd_pstate_highest_perf(struct cpufreq_policy *policy,
char *buf)
{
u32 perf;
struct amd_cpudata *cpudata = policy->driver_data;

perf = READ_ONCE(cpudata->highest_perf);

return sprintf(&buf[0], "%u\n", perf);
}

static ssize_t show_amd_pstate_nominal_perf(struct cpufreq_policy *policy,
char *buf)
{
u32 perf;
struct amd_cpudata *cpudata = policy->driver_data;

perf = READ_ONCE(cpudata->nominal_perf);

return sprintf(&buf[0], "%u\n", perf);
}

static ssize_t show_amd_pstate_lowest_nonlinear_perf(struct cpufreq_policy *policy,
char *buf)
{
u32 perf;
struct amd_cpudata *cpudata = policy->driver_data;

perf = READ_ONCE(cpudata->lowest_nonlinear_perf);

return sprintf(&buf[0], "%u\n", perf);
}

static ssize_t show_amd_pstate_lowest_perf(struct cpufreq_policy *policy,
char *buf)
{
u32 perf;
struct amd_cpudata *cpudata = policy->driver_data;

perf = READ_ONCE(cpudata->lowest_perf);

return sprintf(&buf[0], "%u\n", perf);
}

cpufreq_freq_attr_ro(amd_pstate_max_freq);
cpufreq_freq_attr_ro(amd_pstate_nominal_freq);
cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_freq);

cpufreq_freq_attr_ro(amd_pstate_highest_perf);
cpufreq_freq_attr_ro(amd_pstate_nominal_perf);
cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_perf);
cpufreq_freq_attr_ro(amd_pstate_lowest_perf);

static struct freq_attr *amd_pstate_attr[] = {
&amd_pstate_max_freq,
&amd_pstate_nominal_freq,
&amd_pstate_lowest_nonlinear_freq,
&amd_pstate_highest_perf,
&amd_pstate_nominal_perf,
&amd_pstate_lowest_nonlinear_perf,
&amd_pstate_lowest_perf,
NULL,
};

Expand Down

0 comments on commit b89d41f

Please sign in to comment.