[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5353e053-084d-9a29-bae5-c1e1d597d1e3@amd.com>
Date: Wed, 8 Sep 2021 12:32:37 -0500
From: "Fontenot, Nathan" <Nathan.Fontenot@....com>
To: Huang Rui <ray.huang@....com>,
"Rafael J . Wysocki" <rafael.j.wysocki@...el.com>,
Viresh Kumar <viresh.kumar@...aro.org>,
Shuah Khan <skhan@...uxfoundation.org>,
Borislav Petkov <bp@...e.de>, Ingo Molnar <mingo@...nel.org>,
linux-pm@...r.kernel.org
Cc: Deepak Sharma <deepak.sharma@....com>,
Alex Deucher <alexander.deucher@....com>,
Mario Limonciello <mario.limonciello@....com>,
Jinzhou Su <Jinzhou.Su@....com>,
Xiaojian Du <Xiaojian.Du@....com>,
linux-kernel@...r.kernel.org, x86@...nel.org
Subject: Re: [PATCH 16/19] cpupower: enable boost state support for amd-pstate
module
On 9/8/2021 9:59 AM, Huang Rui wrote:
> The AMD P-state boost API is different from ACPI hardware P-states, so
> implement the support for amd-pstate kernel module.
>
> Signed-off-by: Huang Rui <ray.huang@....com>
> ---
> tools/power/cpupower/lib/cpufreq.c | 20 ++++++++++++++++++++
> tools/power/cpupower/lib/cpufreq.h | 3 +++
> tools/power/cpupower/utils/helpers/misc.c | 7 +++++++
> 3 files changed, 30 insertions(+)
>
> diff --git a/tools/power/cpupower/lib/cpufreq.c b/tools/power/cpupower/lib/cpufreq.c
> index 3f92ddadaad2..37da87bdcfb1 100644
> --- a/tools/power/cpupower/lib/cpufreq.c
> +++ b/tools/power/cpupower/lib/cpufreq.c
> @@ -790,3 +790,23 @@ unsigned long cpufreq_get_transitions(unsigned int cpu)
> {
> return sysfs_cpufreq_get_one_value(cpu, STATS_NUM_TRANSITIONS);
> }
> +
> +int amd_pstate_boost_support(unsigned int cpu)
> +{
> + unsigned int highest_perf, nominal_perf;
> +
> + highest_perf = sysfs_cpufreq_get_one_value(cpu, AMD_PSTATE_HIGHEST_PERF);
> + nominal_perf = sysfs_cpufreq_get_one_value(cpu, AMD_PSTATE_NOMINAL_PERF);
> +
> + return highest_perf > nominal_perf ? 1 : 0;
> +}
> +
> +int amd_pstate_boost_enabled(unsigned int cpu)
> +{
> + unsigned int cpuinfo_max, amd_pstate_max;
> +
> + cpuinfo_max = sysfs_cpufreq_get_one_value(cpu, CPUINFO_MAX_FREQ);
> + amd_pstate_max = sysfs_cpufreq_get_one_value(cpu, AMD_PSTATE_MAX_FREQ);
> +
> + return cpuinfo_max == amd_pstate_max ? 1 : 0;
> +}
> diff --git a/tools/power/cpupower/lib/cpufreq.h b/tools/power/cpupower/lib/cpufreq.h
> index 95f4fd9e2656..d54d02a7a4f4 100644
> --- a/tools/power/cpupower/lib/cpufreq.h
> +++ b/tools/power/cpupower/lib/cpufreq.h
> @@ -203,6 +203,9 @@ int cpufreq_modify_policy_governor(unsigned int cpu, char *governor);
> int cpufreq_set_frequency(unsigned int cpu,
> unsigned long target_frequency);
>
> +int amd_pstate_boost_support(unsigned int cpu);
> +int amd_pstate_boost_enabled(unsigned int cpu);
> +
> #ifdef __cplusplus
> }
> #endif
> diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c
> index 07d80775fb68..aba979320760 100644
> --- a/tools/power/cpupower/utils/helpers/misc.c
> +++ b/tools/power/cpupower/utils/helpers/misc.c
> @@ -10,6 +10,7 @@
> #if defined(__i386__) || defined(__x86_64__)
>
> #include "cpupower_intern.h"
> +#include "cpufreq.h"
>
> #define MSR_AMD_HWCR 0xc0010015
>
> @@ -39,6 +40,12 @@ int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active,
> if (ret)
> return ret;
> }
> + } if ((cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATE) &&
Shouldn't this be
} else if ((cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATE) &&
-Nathan
> + amd_pstate_boost_support(cpu)) {
> + *support = 1;
> +
> + if (amd_pstate_boost_enabled(cpu))
> + *active = 1;
> } else if (cpupower_cpu_info.caps & CPUPOWER_CAP_INTEL_IDA)
> *support = *active = 1;
> return 0;
> --
> 2.25.1
>
Powered by blists - more mailing lists