From: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
To: Mario Limonciello <superm1@kernel.org>,
"Gautham R . Shenoy" <gautham.shenoy@amd.com>,
Perry Yuan <perry.yuan@amd.com>
Cc: "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<linux-kernel@vger.kernel.org>,
"open list:CPU FREQUENCY SCALING FRAMEWORK"
<linux-pm@vger.kernel.org>,
Mario Limonciello <mario.limonciello@amd.com>
Subject: Re: [PATCH v2 1/5] cpufreq/amd-pstate: Add dynamic energy performance preference
Date: Wed, 19 Mar 2025 09:13:25 +0530 [thread overview]
Message-ID: <5eb7d32e-d251-4536-a4e8-61670aa34869@amd.com> (raw)
In-Reply-To: <4e0ab8ce-908e-49a1-8445-14129a41afda@kernel.org>
On 3/19/2025 1:06 AM, Mario Limonciello wrote:
> On 3/12/2025 07:16, Dhananjay Ugwekar wrote:
>> On 3/4/2025 8:53 PM, Mario Limonciello wrote:
>>> From: Mario Limonciello <mario.limonciello@amd.com>
>>>
>>> Dynamic energy performance preference will change the EPP profile
>>> based on whether the machine is running on AC or DC power.
>>>
>>> A notification chain from the power supply core is used to adjust
>>> EPP values on plug in or plug out events.
>>>
>>> For non-server systems:
>>> * the default EPP for AC mode is `performance`.
>>> * the default EPP for DC mode is `balance_performance`.
>>>
>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>> ---
>>> v1->v2:
>>> * Change defaults to performance (AC) and balance_performance (DC)
>>> * Default Kconfig to disabled for now
>>> * Rebase on latest branch
>>> ---
>>> Documentation/admin-guide/pm/amd-pstate.rst | 18 ++-
>>> drivers/cpufreq/Kconfig.x86 | 12 ++
>>> drivers/cpufreq/amd-pstate.c | 129 ++++++++++++++++++--
>>> drivers/cpufreq/amd-pstate.h | 5 +-
>>> 4 files changed, 155 insertions(+), 9 deletions(-)
>>>
>> [Snip]
>>> @@ -1556,6 +1667,10 @@ static int amd_pstate_epp_set_policy(struct cpufreq_policy *policy)
>>> if (!policy->cpuinfo.max_freq)
>>> return -ENODEV;
>>> + /* policy can't be changed to performance policy while dynamic epp is enabled */
>>> + if (policy->policy == CPUFREQ_POLICY_PERFORMANCE && cpudata->dynamic_epp)
>>> + return -EBUSY;
>>
>> We might need to tweak this condition, because if we enable "CONFIG_X86_AMD_PSTATE_DYNAMIC_EPP" in config
>> and boot with "amd_pstate=active" it lands here (cpufreq_online()->amd_pstate_epp_set_policy()) driver init fails
>> as the default governor is performance.
>>
>
> The check is important to make sure that you can't go to performance mode after init.
>
> I think this is the way I would want to solve it.
> Set policy to powersave before enabling dynamic epp for amd_pstate_epp_cpu_init().
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 824756ac0010e..4a0f561d0e2d1 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -1729,8 +1729,10 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
> WRITE_ONCE(cpudata->cppc_req_cached, value);
> }
>
> - if (dynamic_epp)
> + if (dynamic_epp) {
> + policy->policy = CPUFREQ_POLICY_POWERSAVE;
> ret = amd_pstate_set_dynamic_epp(policy);
> + }
> else
> ret = amd_pstate_set_epp(policy, amd_pstate_get_balanced_epp(policy));
^^^^^^^^^^^^ (mentioned below)
> if (ret)
>
> Thoughts?
Yes, this looks good, because anyway there is no point in having performance governor and dynamic
epp set at the same time.
I found one related quirk though, we are setting performance governor for server platforms in
amd_pstate_epp_cpu_init() and then setting epp at the line highlighted above. We dont have a
check in *_set_epp() functions for performance governor. This could alter the performance governor
behavior if we set a "balanced" epp for it. I haven't tested this part yet.
Thanks,
Dhananjay
>
>>> +
>>> cpudata->policy = policy->policy;
>>> ret = amd_pstate_epp_update_limit(policy);
>>> diff --git a/drivers/cpufreq/amd-pstate.h b/drivers/cpufreq/amd-pstate.h
>>> index fbe1c08d3f061..6882876f895de 100644
>>> --- a/drivers/cpufreq/amd-pstate.h
>>> +++ b/drivers/cpufreq/amd-pstate.h
>>> @@ -104,7 +104,10 @@ struct amd_cpudata {
>>> /* EPP feature related attributes*/
>>> u32 policy;
>>> bool suspended;
>>> - u8 epp_default;
>>> + u8 epp_default_ac;
>>> + u8 epp_default_dc;
>>> + bool dynamic_epp;
>>> + struct notifier_block power_nb;
>>> };
>>> /*
>>
>
next prev parent reply other threads:[~2025-03-19 3:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-04 15:23 [PATCH v2 0/5] amd-pstate Dynamic EPP and raw EPP Mario Limonciello
2025-03-04 15:23 ` [PATCH v2 1/5] cpufreq/amd-pstate: Add dynamic energy performance preference Mario Limonciello
2025-03-07 6:45 ` Gautham R. Shenoy
2025-03-11 6:34 ` Dhananjay Ugwekar
2025-03-18 19:08 ` Mario Limonciello
2025-03-12 12:16 ` Dhananjay Ugwekar
2025-03-18 19:36 ` Mario Limonciello
2025-03-19 3:43 ` Dhananjay Ugwekar [this message]
2025-03-19 16:50 ` Mario Limonciello
2025-03-19 17:13 ` Mario Limonciello
2025-03-04 15:23 ` [PATCH v2 2/5] cpufreq/amd-pstate: add kernel command line to override dynamic epp Mario Limonciello
2025-03-07 8:53 ` Gautham R. Shenoy
2025-03-04 15:23 ` [PATCH v2 3/5] cpufreq/amd-pstate: Add support for platform profile class Mario Limonciello
2025-03-07 16:22 ` Gautham R. Shenoy
2025-03-07 16:55 ` Mario Limonciello
2025-03-08 4:30 ` Mario Limonciello
2025-03-10 5:09 ` Gautham R. Shenoy
2025-03-18 19:07 ` Mario Limonciello
2025-03-04 15:23 ` [PATCH v2 4/5] cpufreq/amd-pstate: Add support for raw EPP writes Mario Limonciello
2025-03-04 15:23 ` [PATCH v2 5/5] cpufreq/amd-pstate-ut: Add a unit test for raw EPP Mario Limonciello
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=5eb7d32e-d251-4536-a4e8-61670aa34869@amd.com \
--to=dhananjay.ugwekar@amd.com \
--cc=gautham.shenoy@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=perry.yuan@amd.com \
--cc=superm1@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.