From: "Gautham R. Shenoy" <gautham.shenoy@amd.com>
To: Perry Yuan <perry.yuan@amd.com>
Cc: rafael.j.wysocki@intel.com, Mario.Limonciello@amd.com,
viresh.kumar@linaro.org, Ray.Huang@amd.com,
Borislav.Petkov@amd.com, Alexander.Deucher@amd.com,
Xinmei.Huang@amd.com, Xiaojian.Du@amd.com, Li.Meng@amd.com,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 6/6] cpufreq:amd-pstate: initialize capabilities in amd_pstate_init_perf
Date: Thu, 14 Mar 2024 12:08:37 +0530 [thread overview]
Message-ID: <ZfKbbY2HfQngRfAl@BLR-5CG11610CF.amd.com> (raw)
In-Reply-To: <e450342257c4c80d42245723b273a80a521c00fb.1710323410.git.perry.yuan@amd.com>
Hello Perry,
On Wed, Mar 13, 2024 at 05:59:18PM +0800, Perry Yuan wrote:
> Moved the initialization of some perf and frequency values related
> to cpudata to the amd_pstate_init_perf and cppc_init_perf functions.
> It can avoid duplicate calls to cppc_get_perf_caps function.
Does it make sense to fold this into Patch 2 where you are caching the
nominal frequency for later use ?
Otherwise, this patch looks good to me.
--
Thanks and Regards
gautham.
>
> Signed-off-by: Perry Yuan <perry.yuan@amd.com>
> ---
> drivers/cpufreq/amd-pstate.c | 43 ++++++++++++++----------------------
> include/linux/amd-pstate.h | 1 +
> 2 files changed, 18 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 59bcdf829c93..3877d4ecb5d4 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -330,12 +330,18 @@ static int pstate_init_perf(struct amd_cpudata *cpudata)
> {
> u64 cap1;
> u32 highest_perf;
> + struct cppc_perf_caps cppc_perf;
> + int ret;
>
> - int ret = rdmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_CAP1,
> + ret = rdmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_CAP1,
> &cap1);
> if (ret)
> return ret;
>
> + ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);
> + if (ret)
> + return ret;
> +
> /* For platforms that do not support the preferred core feature, the
> * highest_pef may be configured with 166 or 255, to avoid max frequency
> * calculated wrongly. we take the AMD_CPPC_HIGHEST_PERF(cap1) value as
> @@ -353,6 +359,9 @@ static int pstate_init_perf(struct amd_cpudata *cpudata)
> WRITE_ONCE(cpudata->lowest_perf, AMD_CPPC_LOWEST_PERF(cap1));
> WRITE_ONCE(cpudata->prefcore_ranking, AMD_CPPC_HIGHEST_PERF(cap1));
> WRITE_ONCE(cpudata->min_limit_perf, AMD_CPPC_LOWEST_PERF(cap1));
> + WRITE_ONCE(cpudata->lowest_freq, cppc_perf.lowest_freq);
> + WRITE_ONCE(cpudata->nominal_freq, cppc_perf.nominal_freq);
> +
> return 0;
> }
>
> @@ -360,8 +369,9 @@ static int cppc_init_perf(struct amd_cpudata *cpudata)
> {
> struct cppc_perf_caps cppc_perf;
> u32 highest_perf;
> + int ret;
>
> - int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);
> + ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);
> if (ret)
> return ret;
>
> @@ -378,6 +388,8 @@ static int cppc_init_perf(struct amd_cpudata *cpudata)
> WRITE_ONCE(cpudata->lowest_perf, cppc_perf.lowest_perf);
> WRITE_ONCE(cpudata->prefcore_ranking, cppc_perf.highest_perf);
> WRITE_ONCE(cpudata->min_limit_perf, cppc_perf.lowest_perf);
> + WRITE_ONCE(cpudata->lowest_freq, cppc_perf.lowest_freq);
> + WRITE_ONCE(cpudata->nominal_freq, cppc_perf.nominal_freq);
>
> if (cppc_state == AMD_PSTATE_ACTIVE)
> return 0;
> @@ -642,17 +654,12 @@ static void amd_pstate_adjust_perf(unsigned int cpu,
>
> static int amd_get_min_freq(struct amd_cpudata *cpudata)
> {
> - struct cppc_perf_caps cppc_perf;
> u32 lowest_freq;
>
> - int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);
> - if (ret)
> - return ret;
> -
> if (quirks && quirks->lowest_freq)
> lowest_freq = quirks->lowest_freq;
> else
> - lowest_freq = cppc_perf.lowest_freq;
> + lowest_freq = READ_ONCE(cpudata->lowest_freq);
>
> /* Switch to khz */
> return lowest_freq * 1000;
> @@ -660,14 +667,9 @@ static int amd_get_min_freq(struct amd_cpudata *cpudata)
>
> static int amd_get_max_freq(struct amd_cpudata *cpudata)
> {
> - struct cppc_perf_caps cppc_perf;
> u32 max_perf, max_freq, nominal_freq, nominal_perf;
> u64 boost_ratio;
>
> - int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);
> - if (ret)
> - return ret;
> -
> nominal_freq = READ_ONCE(cpudata->nominal_freq);
> nominal_perf = READ_ONCE(cpudata->nominal_perf);
> max_perf = READ_ONCE(cpudata->highest_perf);
> @@ -683,36 +685,25 @@ static int amd_get_max_freq(struct amd_cpudata *cpudata)
>
> static int amd_get_nominal_freq(struct amd_cpudata *cpudata)
> {
> - struct cppc_perf_caps cppc_perf;
> u32 nominal_freq;
>
> - int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);
> - if (ret)
> - return ret;
> -
> if (quirks && quirks->nominal_freq)
> nominal_freq = quirks->nominal_freq;
> else
> - nominal_freq = cppc_perf.nominal_freq;
> + nominal_freq = READ_ONCE(cpudata->nominal_freq);
>
> return nominal_freq;
> }
>
> static int amd_get_lowest_nonlinear_freq(struct amd_cpudata *cpudata)
> {
> - struct cppc_perf_caps cppc_perf;
> u32 lowest_nonlinear_freq, lowest_nonlinear_perf,
> nominal_freq, nominal_perf;
> u64 lowest_nonlinear_ratio;
>
> - int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);
> - if (ret)
> - return ret;
> -
> nominal_freq = READ_ONCE(cpudata->nominal_freq);
> nominal_perf = READ_ONCE(cpudata->nominal_perf);
> -
> - lowest_nonlinear_perf = cppc_perf.lowest_nonlinear_perf;
> + lowest_nonlinear_perf = READ_ONCE(cpudata->lowest_nonlinear_perf);
>
> lowest_nonlinear_ratio = div_u64(lowest_nonlinear_perf << SCHED_CAPACITY_SHIFT,
> nominal_perf);
> diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h
> index 7b2cbb892fd9..1fbbe75c3dcc 100644
> --- a/include/linux/amd-pstate.h
> +++ b/include/linux/amd-pstate.h
> @@ -88,6 +88,7 @@ struct amd_cpudata {
> u32 min_freq;
> u32 nominal_freq;
> u32 lowest_nonlinear_freq;
> + u32 lowest_freq;
>
> struct amd_aperf_mperf cur;
> struct amd_aperf_mperf prev;
> --
> 2.34.1
>
next prev parent reply other threads:[~2024-03-14 6:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-13 9:59 [PATCH v7 0/6] AMD Pstate Fixes And Enhancements Perry Yuan
2024-03-13 9:59 ` [PATCH v7 1/6] cpufreq:amd-pstate: fix the nominal freq value set Perry Yuan
2024-03-14 5:48 ` Gautham R. Shenoy
2024-03-14 6:09 ` Yuan, Perry
2024-03-14 9:32 ` Gautham R. Shenoy
2024-03-14 10:05 ` Yuan, Perry
2024-03-13 9:59 ` [PATCH v7 2/6] cpufreq:amd-pstate: initialize nominal_freq of each cpudata Perry Yuan
2024-03-13 9:59 ` [PATCH v7 3/6] cpufreq:amd-pstate: get pstate transition delay and latency value from ACPI tables Perry Yuan
2024-03-14 6:23 ` Gautham R. Shenoy
2024-03-13 9:59 ` [PATCH v7 4/6] cppc_acpi: print error message if CPPC is unsupported Perry Yuan
2024-03-13 9:59 ` [PATCH v7 5/6] cpufreq:amd-pstate: add quirk for the pstate CPPC capabilities missing Perry Yuan
2024-03-13 9:59 ` [PATCH v7 6/6] cpufreq:amd-pstate: initialize capabilities in amd_pstate_init_perf Perry Yuan
2024-03-14 6:38 ` Gautham R. Shenoy [this message]
2024-03-14 8:24 ` Yuan, Perry
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=ZfKbbY2HfQngRfAl@BLR-5CG11610CF.amd.com \
--to=gautham.shenoy@amd.com \
--cc=Alexander.Deucher@amd.com \
--cc=Borislav.Petkov@amd.com \
--cc=Li.Meng@amd.com \
--cc=Mario.Limonciello@amd.com \
--cc=Ray.Huang@amd.com \
--cc=Xiaojian.Du@amd.com \
--cc=Xinmei.Huang@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=perry.yuan@amd.com \
--cc=rafael.j.wysocki@intel.com \
--cc=viresh.kumar@linaro.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