Skip to content

Commit ec4e332

Browse files
huangruirafaeljw
authored andcommitted
cpufreq: amd-pstate: Add AMD P-State frequencies attributes
Introduce sysfs attributes to get the different level processor frequencies. Signed-off-by: Huang Rui <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 4127101 commit ec4e332

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,52 @@ static int amd_pstate_cpu_exit(struct cpufreq_policy *policy)
509509
return 0;
510510
}
511511

512+
/* Sysfs attributes */
513+
514+
/*
515+
* This frequency is to indicate the maximum hardware frequency.
516+
* If boost is not active but supported, the frequency will be larger than the
517+
* one in cpuinfo.
518+
*/
519+
static ssize_t show_amd_pstate_max_freq(struct cpufreq_policy *policy,
520+
char *buf)
521+
{
522+
int max_freq;
523+
struct amd_cpudata *cpudata;
524+
525+
cpudata = policy->driver_data;
526+
527+
max_freq = amd_get_max_freq(cpudata);
528+
if (max_freq < 0)
529+
return max_freq;
530+
531+
return sprintf(&buf[0], "%u\n", max_freq);
532+
}
533+
534+
static ssize_t show_amd_pstate_lowest_nonlinear_freq(struct cpufreq_policy *policy,
535+
char *buf)
536+
{
537+
int freq;
538+
struct amd_cpudata *cpudata;
539+
540+
cpudata = policy->driver_data;
541+
542+
freq = amd_get_lowest_nonlinear_freq(cpudata);
543+
if (freq < 0)
544+
return freq;
545+
546+
return sprintf(&buf[0], "%u\n", freq);
547+
}
548+
549+
cpufreq_freq_attr_ro(amd_pstate_max_freq);
550+
cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_freq);
551+
552+
static struct freq_attr *amd_pstate_attr[] = {
553+
&amd_pstate_max_freq,
554+
&amd_pstate_lowest_nonlinear_freq,
555+
NULL,
556+
};
557+
512558
static struct cpufreq_driver amd_pstate_driver = {
513559
.flags = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS,
514560
.verify = amd_pstate_verify,
@@ -517,6 +563,7 @@ static struct cpufreq_driver amd_pstate_driver = {
517563
.exit = amd_pstate_cpu_exit,
518564
.set_boost = amd_pstate_set_boost,
519565
.name = "amd-pstate",
566+
.attr = amd_pstate_attr,
520567
};
521568

522569
static int __init amd_pstate_init(void)

0 commit comments

Comments
 (0)