Linux Power Management development
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: K Prateek Nayak <kprateek.nayak@amd.com>,
	Marco Scardovi <scardracs@disroot.org>
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	perry.yuan@amd.com, rafael@kernel.org, ray.huang@amd.com,
	stuartmeckle@gmail.com, viresh.kumar@linaro.org,
	wyes.karny@amd.com
Subject: Re: [PATCH v4 1/1] cpufreq/amd-pstate: Fix EPP initialization for shared memory systems
Date: Mon, 8 Jun 2026 11:06:42 -0500	[thread overview]
Message-ID: <c64935f5-596d-4877-9968-88b375996111@amd.com> (raw)
In-Reply-To: <c97c81f1-1254-44fe-80b2-89f82fec73f6@amd.com>



On 6/7/26 23:21, K Prateek Nayak wrote:
> Hello Marco,
> 
> I don't mind the changes, except that it can be broken down into
> two patches as Mario suggested for easier backporting :-)

Totally agree. All the technical stuff I'm happy with too, just split it up.

> 
> Some notes below ...
> 
> On 6/6/2026 12:27 PM, Marco Scardovi wrote:
>> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
>> index 8d55e2be825b..a35cf126e335 100644
>> --- a/drivers/cpufreq/amd-pstate.c
>> +++ b/drivers/cpufreq/amd-pstate.c
>> @@ -199,7 +199,7 @@ static inline int get_mode_idx_from_str(const char *str, size_t size)
>>   
>>   static DEFINE_MUTEX(amd_pstate_driver_lock);
>>   
>> -static u8 msr_get_epp(struct amd_cpudata *cpudata)
>> +static int msr_get_epp(struct amd_cpudata *cpudata)
>>   {
>>   	u64 value;
>>   	int ret;
>> @@ -215,12 +215,12 @@ static u8 msr_get_epp(struct amd_cpudata *cpudata)
>>   
>>   DEFINE_STATIC_CALL(amd_pstate_get_epp, msr_get_epp);
>>   
>> -static inline s16 amd_pstate_get_epp(struct amd_cpudata *cpudata)
>> +static inline int amd_pstate_get_epp(struct amd_cpudata *cpudata)
> 
> The change to return type and the amd_pstate_epp_cpu_init() bits
> should be Patch 1/2 with:
> 
> Fixes: 555bbe67a622 ("cpufreq/amd-pstate: Convert all perf values to u8")
> 
> and commit message stating the necessary error handling that is
> required if amd_pstate_get_epp() fails.
> 
>>   {
>>   	return static_call(amd_pstate_get_epp)(cpudata);
>>   }
>>   
>> -static u8 shmem_get_epp(struct amd_cpudata *cpudata)
>> +static int shmem_get_epp(struct amd_cpudata *cpudata)
>>   {
>>   	u64 epp;
>>   	int ret;
>> @@ -525,10 +525,6 @@ static int shmem_init_perf(struct amd_cpudata *cpudata)
>>   	perf.lowest_perf = cppc_perf.lowest_perf;
>>   	WRITE_ONCE(cpudata->perf, perf);
>>   	WRITE_ONCE(cpudata->prefcore_ranking, cppc_perf.highest_perf);
>> -
>> -	if (cppc_state == AMD_PSTATE_ACTIVE)
>> -		return 0;
>> -
> 
> And this should be Patch 2/2 with:
> 
> Fixes: 2dd6d0ebf740 ("cpufreq: amd-pstate: Add guided autonomous mode")
> 
> and a commit message that reads it is necessary for AMD_PSTATE_ACTIVE mode
> on shared memory system to toggle on AUTO_SEL_ENABLE based on the
> ACPI spec for CPPC v2 and below.
> 
>>   	ret = cppc_get_auto_sel(cpudata->cpu, &auto_sel);
>>   	if (ret) {
>>   		pr_warn("failed to get auto_sel, ret: %d\n", ret);
>> @@ -1877,6 +1873,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
>>   	struct amd_cpudata *cpudata;
>>   	union perf_cached perf;
>>   	struct device *dev;
>> +	int default_epp;
>>   	int ret;
>>   
>>   	/*
>> @@ -1926,6 +1923,14 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
>>   
>>   	policy->boost_supported = READ_ONCE(cpudata->boost_supported);
>>   
>> +	/* Cache the firmware programmed EPP */
>> +	default_epp = amd_pstate_get_epp(cpudata);
>> +	if (default_epp < 0) {
>> +		ret = default_epp;
>> +		goto free_cpudata1;
>> +	}
>> +	FIELD_MODIFY(AMD_CPPC_EPP_PERF_MASK, &cpudata->cppc_req_cached, default_epp);
> 
> I would actually prefer this "cppc_req_cached" change to be a third
> patch that says caching the initial EPP saves on an unnecessary
> reprogramming later when the EPP is first set but I don't mind it
> being part of Patch 1 with a small note in the commit message.
> 
>> +
>>   	/*
>>   	 * Set the policy to provide a valid fallback value in case
>>   	 * the default cpufreq governor is neither powersave nor performance.
>> @@ -1933,7 +1938,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
>>   	if (amd_pstate_acpi_pm_profile_server() ||
>>   	    amd_pstate_acpi_pm_profile_undefined()) {
>>   		policy->policy = CPUFREQ_POLICY_PERFORMANCE;
>> -		cpudata->epp_default_ac = cpudata->epp_default_dc = amd_pstate_get_epp(cpudata);
>> +		cpudata->epp_default_ac = cpudata->epp_default_dc = default_epp;
>>   		cpudata->current_profile = PLATFORM_PROFILE_PERFORMANCE;
>>   	} else {
>>   		policy->policy = CPUFREQ_POLICY_POWERSAVE;
> 


      parent reply	other threads:[~2026-06-08 16:06 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-05 10:26 [PATCH v3 0/1] cpufreq/amd-pstate: Fix EPP initialization for shared memory systems Marco Scardovi
2026-06-05 10:26 ` [PATCH v3 1/1] " Marco Scardovi
2026-06-05 18:24   ` Mario Limonciello
2026-06-06  6:57 ` [PATCH v4 0/1] " Marco Scardovi
2026-06-06  6:57   ` [PATCH v4 1/1] " Marco Scardovi
2026-06-08  4:21     ` K Prateek Nayak
2026-06-08  7:31       ` [PATCH v5 0/3] cpufreq/amd-pstate: Fix EPP and auto_sel initialization Marco Scardovi
2026-06-08  7:31         ` [PATCH v5 1/3] cpufreq/amd-pstate: Fix EPP return type and handle errors during initialization Marco Scardovi
2026-06-09  4:45           ` K Prateek Nayak
2026-06-08  7:31         ` [PATCH v5 2/3] cpufreq/amd-pstate: Toggle auto_sel in active mode on shared memory systems Marco Scardovi
2026-06-09  4:47           ` K Prateek Nayak
2026-06-08  7:31         ` [PATCH v5 3/3] cpufreq/amd-pstate: Cache the firmware programmed EPP value Marco Scardovi
2026-06-09  4:50           ` K Prateek Nayak
2026-06-09  7:18         ` [PATCH v5 0/3] cpufreq/amd-pstate: Fix EPP and auto_sel initialization K Prateek Nayak
2026-06-09  7:29           ` [PATCH v6 " Marco Scardovi
2026-06-09  7:29             ` [PATCH v6 1/3] cpufreq/amd-pstate: Fix EPP return type and handle errors during initialization Marco Scardovi
2026-06-09  7:29             ` [PATCH v6 2/3] cpufreq/amd-pstate: Toggle auto_sel in active mode on shared memory systems Marco Scardovi
2026-06-09  7:29             ` [PATCH v6 3/3] cpufreq/amd-pstate: Cache the firmware programmed EPP value Marco Scardovi
2026-06-09 13:48             ` [PATCH v6 0/3] cpufreq/amd-pstate: Fix EPP and auto_sel initialization Mario Limonciello
2026-06-10  7:09               ` Marco Scardovi
2026-06-08 16:06       ` Mario Limonciello [this message]

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=c64935f5-596d-4877-9968-88b375996111@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=perry.yuan@amd.com \
    --cc=rafael@kernel.org \
    --cc=ray.huang@amd.com \
    --cc=scardracs@disroot.org \
    --cc=stuartmeckle@gmail.com \
    --cc=viresh.kumar@linaro.org \
    --cc=wyes.karny@amd.com \
    /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