public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Gautham R. Shenoy" <gautham.shenoy@amd.com>
To: Mario Limonciello <mario.limonciello@amd.com>
Cc: Perry Yuan <perry.yuan@amd.com>,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
Subject: Re: [PATCH v2 16/16] cpufreq/amd-pstate: Drop boost_state variable
Date: Mon, 9 Dec 2024 15:54:50 +0530	[thread overview]
Message-ID: <Z1bFcicdCUgVNCGw@BLRRASHENOY1.amd.com> (raw)
In-Reply-To: <20241208063031.3113-17-mario.limonciello@amd.com>

Hello Mario,

On Sun, Dec 08, 2024 at 12:30:31AM -0600, Mario Limonciello wrote:
> Currently boost_state is cached for every processor in cpudata structure
> and driver boost state is set for every processor.
> 
> Both of these aren't necessary as the driver only needs to set once and
> the policy stores whether boost is enabled.
> 
> Move the driver boost setting to registration and adjust all references
> to cached value to pull from the policy instead.
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

Thanks for cleaning this up.

Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>

--
Thanks and Regards
gautham.

> ---
>  drivers/cpufreq/amd-pstate.c | 26 +++++++++++++-------------
>  drivers/cpufreq/amd-pstate.h |  1 -
>  2 files changed, 13 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index a4ededb8d89df..3f6208828c063 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -315,9 +315,10 @@ static int shmem_set_epp(struct amd_cpudata *cpudata, u32 epp)
>  	return ret;
>  }
>  
> -static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata,
> -		int pref_index)
> +static int amd_pstate_set_energy_pref_index(struct cpufreq_policy *policy,
> +					    int pref_index)
>  {
> +	struct amd_cpudata *cpudata = policy->driver_data;
>  	int epp;
>  
>  	if (!pref_index)
> @@ -335,7 +336,7 @@ static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata,
>  					  epp,
>  					  FIELD_GET(AMD_CPPC_MIN_PERF_MASK, cpudata->cppc_req_cached),
>  					  FIELD_GET(AMD_CPPC_MAX_PERF_MASK, cpudata->cppc_req_cached),
> -					  cpudata->boost_state);
> +					  policy->boost_enabled);
>  	}
>  
>  	return amd_pstate_set_epp(cpudata, epp);
> @@ -746,7 +747,6 @@ static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state)
>  	guard(mutex)(&amd_pstate_driver_lock);
>  
>  	ret = amd_pstate_cpu_boost_update(policy, state);
> -	WRITE_ONCE(cpudata->boost_state, !ret ? state : false);
>  	policy->boost_enabled = !ret ? state : false;
>  	refresh_frequency_limits(policy);
>  
> @@ -768,9 +768,6 @@ static int amd_pstate_init_boost_support(struct amd_cpudata *cpudata)
>  		goto exit_err;
>  	}
>  
> -	/* at least one CPU supports CPB, even if others fail later on to set up */
> -	current_pstate_driver->boost_enabled = true;
> -
>  	ret = rdmsrl_on_cpu(cpudata->cpu, MSR_K7_HWCR, &boost_val);
>  	if (ret) {
>  		pr_err_once("failed to read initial CPU boost state!\n");
> @@ -1176,7 +1173,6 @@ static ssize_t show_energy_performance_available_preferences(
>  static ssize_t store_energy_performance_preference(
>  		struct cpufreq_policy *policy, const char *buf, size_t count)
>  {
> -	struct amd_cpudata *cpudata = policy->driver_data;
>  	char str_preference[21];
>  	ssize_t ret;
>  
> @@ -1190,7 +1186,7 @@ static ssize_t store_energy_performance_preference(
>  
>  	guard(mutex)(&amd_pstate_limits_lock);
>  
> -	ret = amd_pstate_set_energy_pref_index(cpudata, ret);
> +	ret = amd_pstate_set_energy_pref_index(policy, ret);
>  
>  	return ret ? ret : count;
>  }
> @@ -1265,6 +1261,9 @@ static int amd_pstate_register_driver(int mode)
>  		return ret;
>  	}
>  
> +	/* at least one CPU supports CPB */
> +	current_pstate_driver->boost_enabled = cpu_feature_enabled(X86_FEATURE_CPB);
> +
>  	ret = cpufreq_register_driver(current_pstate_driver);
>  	if (ret) {
>  		amd_pstate_driver_cleanup();
> @@ -1604,8 +1603,9 @@ static int amd_pstate_epp_set_policy(struct cpufreq_policy *policy)
>  	return 0;
>  }
>  
> -static int amd_pstate_epp_reenable(struct amd_cpudata *cpudata)
> +static int amd_pstate_epp_reenable(struct cpufreq_policy *policy)
>  {
> +	struct amd_cpudata *cpudata = policy->driver_data;
>  	u64 max_perf;
>  	int ret;
>  
> @@ -1619,7 +1619,7 @@ static int amd_pstate_epp_reenable(struct amd_cpudata *cpudata)
>  		trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf,
>  					  cpudata->epp_cached,
>  					  FIELD_GET(AMD_CPPC_MIN_PERF_MASK, cpudata->cppc_req_cached),
> -					  max_perf, cpudata->boost_state);
> +					  max_perf, policy->boost_enabled);
>  	}
>  
>  	return amd_pstate_update_perf(cpudata, 0, 0, max_perf, cpudata->epp_cached, false);
> @@ -1632,7 +1632,7 @@ static int amd_pstate_epp_cpu_online(struct cpufreq_policy *policy)
>  
>  	pr_debug("AMD CPU Core %d going online\n", cpudata->cpu);
>  
> -	ret = amd_pstate_epp_reenable(cpudata);
> +	ret = amd_pstate_epp_reenable(policy);
>  	if (ret)
>  		return ret;
>  	cpudata->suspended = false;
> @@ -1690,7 +1690,7 @@ static int amd_pstate_epp_resume(struct cpufreq_policy *policy)
>  		guard(mutex)(&amd_pstate_limits_lock);
>  
>  		/* enable amd pstate from suspend state*/
> -		amd_pstate_epp_reenable(cpudata);
> +		amd_pstate_epp_reenable(policy);
>  
>  		cpudata->suspended = false;
>  	}
> diff --git a/drivers/cpufreq/amd-pstate.h b/drivers/cpufreq/amd-pstate.h
> index 7765c82f975c6..9747e3be6ceee 100644
> --- a/drivers/cpufreq/amd-pstate.h
> +++ b/drivers/cpufreq/amd-pstate.h
> @@ -98,7 +98,6 @@ struct amd_cpudata {
>  	u64	cppc_cap1_cached;
>  	bool	suspended;
>  	s16	epp_default;
> -	bool	boost_state;
>  };
>  
>  /*
> -- 
> 2.43.0
> 

      reply	other threads:[~2024-12-09 10:25 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-08  6:30 [PATCH v2 00/16] amd-pstate fixes and improvements for 6.14 Mario Limonciello
2024-12-08  6:30 ` [PATCH v2 01/16] cpufreq/amd-pstate: Store the boost numerator as highest perf again Mario Limonciello
2024-12-08  6:30 ` [PATCH v2 02/16] cpufreq/amd-pstate: Use boost numerator for upper bound of frequencies Mario Limonciello
2024-12-08  6:30 ` [PATCH v2 03/16] cpufreq/amd-pstate: Add trace event for EPP perf updates Mario Limonciello
2024-12-08  6:30 ` [PATCH v2 04/16] cpufreq/amd-pstate: convert mutex use to guard() Mario Limonciello
2024-12-08  6:30 ` [PATCH v2 05/16] cpufreq/amd-pstate: Drop cached epp_policy variable Mario Limonciello
2024-12-08  6:30 ` [PATCH v2 06/16] cpufreq/amd-pstate: Use FIELD_PREP and FIELD_GET macros Mario Limonciello
2024-12-08  6:30 ` [PATCH v2 07/16] cpufreq/amd-pstate: Only update the cached value in msr_set_epp() on success Mario Limonciello
2024-12-08  6:30 ` [PATCH v2 08/16] cpufreq/amd-pstate: store all values in cpudata struct in khz Mario Limonciello
2024-12-08  6:30 ` [PATCH v2 09/16] cpufreq/amd-pstate: Change amd_pstate_update_perf() to return an int Mario Limonciello
2024-12-08  6:30 ` [PATCH v2 10/16] cpufreq/amd-pstate: Move limit updating code Mario Limonciello
2024-12-08  6:30 ` [PATCH v2 11/16] cpufreq/amd-pstate: Cache EPP value and use that everywhere Mario Limonciello
2024-12-08  6:30 ` [PATCH v2 12/16] cpufreq/amd-pstate: Always write EPP value when updating perf Mario Limonciello
2024-12-09  8:42   ` Gautham R. Shenoy
2024-12-09 16:49     ` Mario Limonciello
2024-12-09 17:15       ` Mario Limonciello
2024-12-10 11:10         ` Gautham R. Shenoy
2024-12-08  6:30 ` [PATCH v2 13/16] cpufreq/amd-pstate: Check if CPPC request has changed before writing to the MSR or shared memory Mario Limonciello
2024-12-09  8:56   ` Gautham R. Shenoy
2024-12-09 16:41     ` Mario Limonciello
2024-12-08  6:30 ` [PATCH v2 14/16] cpufreq/amd-pstate: Drop ret variable from amd_pstate_set_energy_pref_index() Mario Limonciello
2024-12-09  9:25   ` Gautham R. Shenoy
2024-12-08  6:30 ` [PATCH v2 15/16] cpufreq/amd-pstate: Set different default EPP policy for Epyc and Ryzen Mario Limonciello
2024-12-09  9:27   ` Gautham R. Shenoy
2024-12-08  6:30 ` [PATCH v2 16/16] cpufreq/amd-pstate: Drop boost_state variable Mario Limonciello
2024-12-09 10:24   ` Gautham R. Shenoy [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=Z1bFcicdCUgVNCGw@BLRRASHENOY1.amd.com \
    --to=gautham.shenoy@amd.com \
    --cc=Dhananjay.Ugwekar@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=perry.yuan@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