* [PATCH] cpufreq: amd-pstate: Add sysfs file for base frequency
@ 2023-06-29 13:54 Mario Limonciello
2023-07-03 7:06 ` Huang Rui
2023-07-11 4:32 ` kernel test robot
0 siblings, 2 replies; 4+ messages in thread
From: Mario Limonciello @ 2023-06-29 13:54 UTC (permalink / raw)
To: ray.huang, rafael
Cc: linux-pm, linux-doc, linux-kernel, Mario Limonciello, Wyes Karny,
Perry Yuan
Some applications may want to query the base frequency to tell when
a processor is operating in boost.
Tested-by: Wyes Karny <wyes.karny@amd.com>
Reviewed-by: Wyes Karny <wyes.karny@amd.com>
Co-developed-by: Perry Yuan <perry.yuan@amd.com>
Signed-off-by: Perry Yuan <perry.yuan@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.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);
+}
+
+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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] cpufreq: amd-pstate: Add sysfs file for base frequency
2023-06-29 13:54 [PATCH] cpufreq: amd-pstate: Add sysfs file for base frequency Mario Limonciello
@ 2023-07-03 7:06 ` Huang Rui
2023-07-04 1:09 ` Mario Limonciello
2023-07-11 4:32 ` kernel test robot
1 sibling, 1 reply; 4+ messages in thread
From: Huang Rui @ 2023-07-03 7:06 UTC (permalink / raw)
To: Limonciello, Mario
Cc: rafael@kernel.org, linux-pm@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Karny, Wyes, Yuan, Perry
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@amd.com>
> Reviewed-by: Wyes Karny <wyes.karny@amd.com>
> Co-developed-by: Perry Yuan <perry.yuan@amd.com>
> Signed-off-by: Perry Yuan <perry.yuan@amd.com>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.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,
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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cpufreq: amd-pstate: Add sysfs file for base frequency
2023-07-03 7:06 ` Huang Rui
@ 2023-07-04 1:09 ` Mario Limonciello
0 siblings, 0 replies; 4+ messages in thread
From: Mario Limonciello @ 2023-07-04 1:09 UTC (permalink / raw)
To: Huang Rui
Cc: rafael@kernel.org, linux-pm@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Karny, Wyes, Yuan, Perry
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@amd.com>
>> Reviewed-by: Wyes Karny <wyes.karny@amd.com>
>> Co-developed-by: Perry Yuan <perry.yuan@amd.com>
>> Signed-off-by: Perry Yuan <perry.yuan@amd.com>
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.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
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cpufreq: amd-pstate: Add sysfs file for base frequency
2023-06-29 13:54 [PATCH] cpufreq: amd-pstate: Add sysfs file for base frequency Mario Limonciello
2023-07-03 7:06 ` Huang Rui
@ 2023-07-11 4:32 ` kernel test robot
1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2023-07-11 4:32 UTC (permalink / raw)
To: Mario Limonciello, ray.huang, rafael
Cc: oe-kbuild-all, linux-pm, linux-doc, linux-kernel,
Mario Limonciello, Wyes Karny, Perry Yuan
Hi Mario,
kernel test robot noticed the following build warnings:
[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on linus/master v6.5-rc1 next-20230711]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Mario-Limonciello/cpufreq-amd-pstate-Add-sysfs-file-for-base-frequency/20230630-203900
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link: https://lore.kernel.org/r/20230629135454.177421-1-mario.limonciello%40amd.com
patch subject: [PATCH] cpufreq: amd-pstate: Add sysfs file for base frequency
reproduce: (https://download.01.org/0day-ci/archive/20230711/202307111214.8H56UUiU-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202307111214.8H56UUiU-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> Documentation/admin-guide/pm/amd-pstate.rst:286: WARNING: Block quote ends without a blank line; unexpected unindent.
vim +286 Documentation/admin-guide/pm/amd-pstate.rst
283
284 ``base_frequency``
285 Shows the base frequency of the CPU. Frequencies above this will be in the
> 286 ``boost`` range. This attribute is read-only.
287
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-11 4:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-29 13:54 [PATCH] cpufreq: amd-pstate: Add sysfs file for base frequency Mario Limonciello
2023-07-03 7:06 ` Huang Rui
2023-07-04 1:09 ` Mario Limonciello
2023-07-11 4:32 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).