Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq: amd-pstate: Add AMD P-State frequencies attributes

Introduce sysfs attributes to get the different level processor
frequencies.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Huang Rui and committed by
Rafael J. Wysocki
ec4e3326 41271016

+47
+47
drivers/cpufreq/amd-pstate.c
··· 509 509 return 0; 510 510 } 511 511 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 + 512 558 static struct cpufreq_driver amd_pstate_driver = { 513 559 .flags = CPUFREQ_CONST_LOOPS | CPUFREQ_NEED_UPDATE_LIMITS, 514 560 .verify = amd_pstate_verify, ··· 563 517 .exit = amd_pstate_cpu_exit, 564 518 .set_boost = amd_pstate_set_boost, 565 519 .name = "amd-pstate", 520 + .attr = amd_pstate_attr, 566 521 }; 567 522 568 523 static int __init amd_pstate_init(void)