[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1ca42aaa-3864-2143-b29f-31016eb7304f@amd.com>
Date: Mon, 3 Jul 2023 20:09:19 -0500
From: Mario Limonciello <mario.limonciello@....com>
To: Huang Rui <ray.huang@....com>
Cc: "rafael@...nel.org" <rafael@...nel.org>,
"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
"linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Karny, Wyes" <Wyes.Karny@....com>,
"Yuan, Perry" <Perry.Yuan@....com>
Subject: Re: [PATCH] cpufreq: amd-pstate: Add sysfs file for base frequency
On 7/3/23 02:06, Huang Rui wrote:
> On Thu, Jun 29, 2023 at 09:54:54PM +0800, Limonciello, Mario wrote:
>> Some applications may want to query the base frequency to tell when
>> a processor is operating in boost.
>>
>> Tested-by: Wyes Karny <wyes.karny@....com>
>> Reviewed-by: Wyes Karny <wyes.karny@....com>
>> Co-developed-by: Perry Yuan <perry.yuan@....com>
>> Signed-off-by: Perry Yuan <perry.yuan@....com>
>> Signed-off-by: Mario Limonciello <mario.limonciello@....com>
>> ---
>> Documentation/admin-guide/pm/amd-pstate.rst | 4 ++++
>> drivers/cpufreq/amd-pstate.c | 15 +++++++++++++++
>> 2 files changed, 19 insertions(+)
>>
>> diff --git a/Documentation/admin-guide/pm/amd-pstate.rst b/Documentation/admin-guide/pm/amd-pstate.rst
>> index 1cf40f69278cd..e68267857e859 100644
>> --- a/Documentation/admin-guide/pm/amd-pstate.rst
>> +++ b/Documentation/admin-guide/pm/amd-pstate.rst
>> @@ -281,6 +281,10 @@ integer values defined between 0 to 255 when EPP feature is enabled by platform
>> firmware, if EPP feature is disabled, driver will ignore the written value
>> This attribute is read-write.
>>
>> +``base_frequency``
>> + Shows the base frequency of the CPU. Frequencies above this will be in the
>> + ``boost`` range. This attribute is read-only.
>> +
>> Other performance and frequency values can be read back from
>> ``/sys/devices/system/cpu/cpuX/acpi_cppc/``, see :ref:`cppc_sysfs`.
>>
>> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
>> index 81fba0dcbee99..0fec66b3f7241 100644
>> --- a/drivers/cpufreq/amd-pstate.c
>> +++ b/drivers/cpufreq/amd-pstate.c
>> @@ -1037,6 +1037,19 @@ static ssize_t store_status(struct kobject *a, struct kobj_attribute *b,
>> return ret < 0 ? ret : count;
>> }
>>
>> +static ssize_t show_base_frequency(struct cpufreq_policy *policy, char *buf)
>> +{
>> + struct amd_cpudata *cpudata = policy->driver_data;
>> + u32 nominal_freq;
>> +
>> + nominal_freq = amd_get_nominal_freq(cpudata);
>> + if (nominal_freq < 0)
>> + return nominal_freq;
>> +
>> + return sysfs_emit(buf, "%d\n", nominal_freq);
>> +}
>
> User can get it from nominal_freq at drivers/acpi/cppc_acpi.c:
>
> show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, nominal_freq);
Thanks for sharing that, I wasn't aware. This patch is unnecessary indeed.
>
> Thanks,
> Ray
>
>> +
>> +cpufreq_freq_attr_ro(base_frequency);
>> cpufreq_freq_attr_ro(amd_pstate_max_freq);
>> cpufreq_freq_attr_ro(amd_pstate_lowest_nonlinear_freq);
>>
>> @@ -1049,6 +1062,7 @@ static struct freq_attr *amd_pstate_attr[] = {
>> &amd_pstate_max_freq,
>> &amd_pstate_lowest_nonlinear_freq,
>> &amd_pstate_highest_perf,
>> + &base_frequency,
>> NULL,
>> };
>>
>> @@ -1058,6 +1072,7 @@ static struct freq_attr *amd_pstate_epp_attr[] = {
>> &amd_pstate_highest_perf,
>> &energy_performance_preference,
>> &energy_performance_available_preferences,
>> + &base_frequency,
>> NULL,
>> };
>>
>> --
>> 2.34.1
>>
Powered by blists - more mailing lists