From: Mario Limonciello <mario.limonciello@amd.com>
To: Meng Li <li.meng@amd.com>,
"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
Huang Rui <ray.huang@amd.com>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
x86@kernel.org, linux-acpi@vger.kernel.org,
Shuah Khan <skhan@linuxfoundation.org>,
linux-kselftest@vger.kernel.org,
Nathan Fontenot <nathan.fontenot@amd.com>,
Deepak Sharma <deepak.sharma@amd.com>,
Alex Deucher <alexander.deucher@amd.com>,
Shimmer Huang <shimmer.huang@amd.com>,
Perry Yuan <Perry.Yuan@amd.com>,
Xiaojian Du <Xiaojian.Du@amd.com>,
Viresh Kumar <viresh.kumar@linaro.org>,
Borislav Petkov <bp@alien8.de>
Subject: Re: [PATCH] cpufreq: amd-pstate: adjust min/max limit perf
Date: Tue, 27 Feb 2024 09:36:34 -0600 [thread overview]
Message-ID: <f1964180-458f-4c22-90f6-bda2aee5dbf8@amd.com> (raw)
In-Reply-To: <20240227073924.3573398-1-li.meng@amd.com>
On 2/27/2024 01:39, Meng Li wrote:
> The min/max limit perf values calculated based on frequency
> may exceed the reasonable range of perf(highest perf, lowest perf).
>
> Signed-off-by: Meng Li <li.meng@amd.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/cpufreq/amd-pstate.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index aa5e57e27d2b..2015c9fcc3c9 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -484,12 +484,19 @@ static int amd_pstate_verify(struct cpufreq_policy_data *policy)
>
> static int amd_pstate_update_min_max_limit(struct cpufreq_policy *policy)
> {
> - u32 max_limit_perf, min_limit_perf;
> + u32 max_limit_perf, min_limit_perf, lowest_perf;
> struct amd_cpudata *cpudata = policy->driver_data;
>
> max_limit_perf = div_u64(policy->max * cpudata->highest_perf, cpudata->max_freq);
> min_limit_perf = div_u64(policy->min * cpudata->highest_perf, cpudata->max_freq);
>
> + lowest_perf = READ_ONCE(cpudata->lowest_perf);
> + if (min_limit_perf < lowest_perf)
> + min_limit_perf = lowest_perf;
> +
> + if (max_limit_perf < min_limit_perf)
> + max_limit_perf = min_limit_perf;
> +
> WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf);
> WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf);
> WRITE_ONCE(cpudata->max_limit_freq, policy->max);
> @@ -1387,6 +1394,12 @@ static void amd_pstate_epp_update_limit(struct cpufreq_policy *policy)
> max_limit_perf = div_u64(policy->max * cpudata->highest_perf, cpudata->max_freq);
> min_limit_perf = div_u64(policy->min * cpudata->highest_perf, cpudata->max_freq);
>
> + if (min_limit_perf < min_perf)
> + min_limit_perf = min_perf;
> +
> + if (max_limit_perf < min_limit_perf)
> + max_limit_perf = min_limit_perf;
> +
> WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf);
> WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf);
>
next prev parent reply other threads:[~2024-02-27 15:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 7:39 [PATCH] cpufreq: amd-pstate: adjust min/max limit perf Meng Li
2024-02-27 15:36 ` Mario Limonciello [this message]
2024-02-29 19:13 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f1964180-458f-4c22-90f6-bda2aee5dbf8@amd.com \
--to=mario.limonciello@amd.com \
--cc=Perry.Yuan@amd.com \
--cc=Xiaojian.Du@amd.com \
--cc=alexander.deucher@amd.com \
--cc=bp@alien8.de \
--cc=deepak.sharma@amd.com \
--cc=li.meng@amd.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=nathan.fontenot@amd.com \
--cc=rafael.j.wysocki@intel.com \
--cc=ray.huang@amd.com \
--cc=shimmer.huang@amd.com \
--cc=skhan@linuxfoundation.org \
--cc=viresh.kumar@linaro.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox