[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a2718365-5975-5c91-350f-fe9098b4de7b@amd.com>
Date: Wed, 8 Sep 2021 13:24:54 -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 08/19] cpufreq: amd: add boost mode support for amd-pstate
On 9/8/2021 9:59 AM, Huang Rui wrote:
> If the sbios supports the boost mode of amd-pstate, let's switch to
> boost enabled by default.
>
> Signed-off-by: Huang Rui <ray.huang@....com>
> ---
> drivers/cpufreq/amd-pstate.c | 50 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 50 insertions(+)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index ea965a122431..67a9a117f524 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -75,6 +75,8 @@ struct amd_cpudata {
> u32 min_freq;
> u32 nominal_freq;
> u32 lowest_nonlinear_freq;
> +
> + bool boost_supported;
> };
>
> struct amd_pstate_perf_funcs {
> @@ -229,6 +231,19 @@ amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf,
> max_perf, fast_switch);
> }
>
> +static bool amd_pstate_boost_supported(struct amd_cpudata *cpudata)
> +{
> + u32 highest_perf, nominal_perf;
> +
> + highest_perf = READ_ONCE(cpudata->highest_perf);
> + nominal_perf = READ_ONCE(cpudata->nominal_perf);
> +
> + if (highest_perf > nominal_perf)
> + return true;
> +
> + return false;
> +}
> +
> static int amd_pstate_verify(struct cpufreq_policy_data *policy)
> {
> cpufreq_verify_within_cpu_limits(policy);
> @@ -402,6 +417,37 @@ static int amd_get_lowest_nonlinear_freq(struct amd_cpudata *cpudata)
> return lowest_nonlinear_freq * 1000;
> }
>
> +static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state)
> +{
> + struct amd_cpudata *cpudata = policy->driver_data;
> + int ret;
> +
> + if (!cpudata->boost_supported) {
> + pr_err("Boost mode is not supported by this processor or SBIOS\n");
> + return -EINVAL;
> + }
> +
> + if (state)
> + policy->cpuinfo.max_freq = cpudata->max_freq;
> + else
> + policy->cpuinfo.max_freq = cpudata->nominal_freq;
> +
> + policy->max = policy->cpuinfo.max_freq;
> +
> + ret = freq_qos_update_request(&cpudata->req[1],
> + policy->cpuinfo.max_freq);
> + if (ret < 0)
> + return ret;
> +
> + return 0;
> +}
> +
> +static void amd_pstate_boost_init(struct amd_cpudata *cpudata)
> +{
> + cpudata->boost_supported = true;
> + amd_pstate_driver.boost_enabled = true;
> +}
> +
> static int amd_pstate_init_freqs_in_cpudata(struct amd_cpudata *cpudata,
> u32 max_freq, u32 min_freq,
> u32 nominal_freq,
> @@ -504,6 +550,9 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
>
> policy->driver_data = cpudata;
>
> + if (amd_pstate_boost_supported(cpudata))
> + amd_pstate_boost_init(cpudata);
Is there any reason to not merge amd_pstate_boost_supported() and
amd_pstate_boost_init() into a single function? I don't see that
amd_pstate_boost_supported() is called anywhere else.
-Nathan
> +
> return 0;
>
> free_cpudata3:
> @@ -535,6 +584,7 @@ static struct cpufreq_driver amd_pstate_driver = {
> .fast_switch = amd_pstate_fast_switch,
> .init = amd_pstate_cpu_init,
> .exit = amd_pstate_cpu_exit,
> + .set_boost = amd_pstate_set_boost,
> .name = "amd-pstate",
> };
>
> --
> 2.25.1
>
Powered by blists - more mailing lists