Linux Documentation
 help / color / mirror / Atom feed
From: Mario Limonciello <superm1@kernel.org>
To: K Prateek Nayak <kprateek.nayak@amd.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Huang Rui <ray.huang@amd.com>
Cc: Perry Yuan <perry.yuan@amd.com>,
	linux-pm@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 1/6] cpufreq/amd-pstate: Extract platform profile to EPP conversion into a helper
Date: Wed, 1 Jul 2026 16:31:15 -0500	[thread overview]
Message-ID: <f0ffaa93-946d-4792-be28-db75a309e3ab@kernel.org> (raw)
In-Reply-To: <20260630185904.5602-2-kprateek.nayak@amd.com>



On 6/30/26 13:58, K Prateek Nayak wrote:
> Avoid duplication by extracting the switch case that derives EPP based
> on platform profile into the amd_pstate_get_epp_from_platform_profile()
> helper.
> 
> No functional changes intended.
> 
> Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
> ---
>   drivers/cpufreq/amd-pstate.c | 67 +++++++++++++++++-------------------
>   1 file changed, 32 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 20c30d14100f..1893b0054a6a 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -1179,6 +1179,24 @@ static int amd_pstate_power_supply_notifier(struct notifier_block *nb,
>   	return NOTIFY_OK;
>   }
>   
> +static int amd_pstate_get_epp_from_platform_profile(struct cpufreq_policy *policy,
> +						    enum platform_profile_option profile)
> +{
> +	switch (profile) {
> +	case PLATFORM_PROFILE_PERFORMANCE:
> +		return AMD_CPPC_EPP_PERFORMANCE;
> +	case PLATFORM_PROFILE_BALANCED:
> +		return amd_pstate_get_balanced_epp(policy);
> +	case PLATFORM_PROFILE_LOW_POWER:
> +		return AMD_CPPC_EPP_POWERSAVE;
> +	default:
> +		break;
> +	}
> +
> +	pr_err("Unknown Platform Profile %d\n", profile);
> +	return -EOPNOTSUPP;
> +}
> +
>   static int amd_pstate_profile_probe(void *drvdata, unsigned long *choices)
>   {
>   	set_bit(PLATFORM_PROFILE_LOW_POWER, choices);
> @@ -1204,28 +1222,16 @@ static int amd_pstate_profile_set(struct device *dev,
>   	struct amd_cpudata *cpudata = dev_get_drvdata(dev);
>   	struct cpufreq_policy *policy __free(put_cpufreq_policy) = cpufreq_cpu_get(cpudata->cpu);
>   	int ret;
> +	u8 epp;
>   
> -	switch (profile) {
> -	case PLATFORM_PROFILE_LOW_POWER:
> -		ret = amd_pstate_set_epp(policy, AMD_CPPC_EPP_POWERSAVE);
> -		if (ret)
> -			return ret;
> -		break;
> -	case PLATFORM_PROFILE_BALANCED:
> -		ret = amd_pstate_set_epp(policy,
> -					 amd_pstate_get_balanced_epp(policy));
> -		if (ret)
> -			return ret;
> -		break;
> -	case PLATFORM_PROFILE_PERFORMANCE:
> -		ret = amd_pstate_set_epp(policy, AMD_CPPC_EPP_PERFORMANCE);
> -		if (ret)
> -			return ret;
> -		break;
> -	default:
> -		pr_err("Unknown Platform Profile %d\n", profile);
> -		return -EOPNOTSUPP;
> -	}
> +	ret = amd_pstate_get_epp_from_platform_profile(policy, profile);
> +	if (ret < 0)
> +		return ret;
> +
> +	epp = (u8)ret;
> +	ret = amd_pstate_set_epp(policy, epp);
> +	if (ret)
> +		return ret;
>   
>   	cpudata->current_profile = profile;
>   
> @@ -1259,20 +1265,11 @@ static int amd_pstate_set_dynamic_epp(struct cpufreq_policy *policy)
>   	int ret;
>   	u8 epp;
>   
> -	switch (cpudata->current_profile) {
> -	case PLATFORM_PROFILE_PERFORMANCE:
> -		epp = AMD_CPPC_EPP_PERFORMANCE;
> -		break;
> -	case PLATFORM_PROFILE_LOW_POWER:
> -		epp = AMD_CPPC_EPP_POWERSAVE;
> -		break;
> -	case PLATFORM_PROFILE_BALANCED:
> -		epp = amd_pstate_get_balanced_epp(policy);
> -		break;
> -	default:
> -		pr_err("Unknown Platform Profile %d\n", cpudata->current_profile);
> -		return -EOPNOTSUPP;
> -	}
> +	ret = amd_pstate_get_epp_from_platform_profile(policy, cpudata->current_profile);
> +	if (ret < 0)
> +		return ret;
> +
> +	epp = (u8)ret;
>   	ret = amd_pstate_set_epp(policy, epp);
>   	if (ret)
>   		return ret;


  reply	other threads:[~2026-07-01 21:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30 18:58 [RFC PATCH 0/6] cpufreq/amd-pstate: Rework dynamic_epp as an energy_performance_preference mode K Prateek Nayak
2026-06-30 18:58 ` [RFC PATCH 1/6] cpufreq/amd-pstate: Extract platform profile to EPP conversion into a helper K Prateek Nayak
2026-07-01 21:31   ` Mario Limonciello [this message]
2026-06-30 18:59 ` [RFC PATCH 2/6] cpufreq/amd-pstate: Add dynamic EPP as an "energy_performance_preference" mode K Prateek Nayak
2026-07-01 21:33   ` Mario Limonciello
2026-06-30 18:59 ` [RFC PATCH 3/6] cpufreq/amd-pstate: Repurpose "amd_dynamic_epp" cmdline and corresponding sysfs K Prateek Nayak
2026-07-01 21:40   ` Mario Limonciello
2026-06-30 18:59 ` [RFC PATCH 4/6] Documentation/amd-pstate: Update dynamic_epp documentation with new behavior K Prateek Nayak
2026-06-30 19:03 ` K Prateek Nayak
2026-06-30 19:03 ` [RFC PATCH 5/6] cpufreq/amd-pstate: Reduce the scope of exported symbols K Prateek Nayak
2026-07-01 21:38   ` Mario Limonciello
2026-06-30 19:03 ` [RFC PATCH 6/6] cpufreq/amd-pstate-ut: Add unit test for "dynamic" EPP mode K Prateek Nayak

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=f0ffaa93-946d-4792-be28-db75a309e3ab@kernel.org \
    --to=superm1@kernel.org \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-doc@vger.kernel.org \
    --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=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