lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 9 Sep 2021 18:12:48 +0800
From:   Huang Rui <ray.huang@....com>
To:     "Fontenot, Nathan" <Nathan.Fontenot@....com>
CC:     "Rafael J . Wysocki" <rafael.j.wysocki@...el.com>,
        Viresh Kumar <viresh.kumar@...aro.org>,
        Shuah Khan <skhan@...uxfoundation.org>,
        "Borislav Petkov" <bp@...e.de>, Ingo Molnar <mingo@...nel.org>,
        "linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
        "Sharma, Deepak" <Deepak.Sharma@....com>,
        "Deucher, Alexander" <Alexander.Deucher@....com>,
        "Limonciello, Mario" <Mario.Limonciello@....com>,
        "Su, Jinzhou (Joe)" <Jinzhou.Su@....com>,
        "Du, Xiaojian" <Xiaojian.Du@....com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "x86@...nel.org" <x86@...nel.org>
Subject: Re: [PATCH 08/19] cpufreq: amd: add boost mode support for amd-pstate

On Thu, Sep 09, 2021 at 02:24:54AM +0800, Fontenot, Nathan wrote:
> On 9/8/2021 9:59 AM, Huang Rui wrote:
> > If the sbios supports the boost mode of amd-pstate, let's switch to
> > boost enabled by default.
> > 
> > Signed-off-by: Huang Rui <ray.huang@....com>
> > ---
> >  drivers/cpufreq/amd-pstate.c | 50 ++++++++++++++++++++++++++++++++++++
> >  1 file changed, 50 insertions(+)
> > 
> > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> > index ea965a122431..67a9a117f524 100644
> > --- a/drivers/cpufreq/amd-pstate.c
> > +++ b/drivers/cpufreq/amd-pstate.c
> > @@ -75,6 +75,8 @@ struct amd_cpudata {
> >  	u32	min_freq;
> >  	u32	nominal_freq;
> >  	u32	lowest_nonlinear_freq;
> > +
> > +	bool	boost_supported;
> >  };
> >  
> >  struct amd_pstate_perf_funcs {
> > @@ -229,6 +231,19 @@ amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf,
> >  				      max_perf, fast_switch);
> >  }
> >  
> > +static bool amd_pstate_boost_supported(struct amd_cpudata *cpudata)
> > +{
> > +	u32 highest_perf, nominal_perf;
> > +
> > +	highest_perf = READ_ONCE(cpudata->highest_perf);
> > +	nominal_perf = READ_ONCE(cpudata->nominal_perf);
> > +
> > +	if (highest_perf > nominal_perf)
> > +		return true;
> > +
> > +	return false;
> > +}
> > +
> >  static int amd_pstate_verify(struct cpufreq_policy_data *policy)
> >  {
> >  	cpufreq_verify_within_cpu_limits(policy);
> > @@ -402,6 +417,37 @@ static int amd_get_lowest_nonlinear_freq(struct amd_cpudata *cpudata)
> >  	return lowest_nonlinear_freq * 1000;
> >  }
> >  
> > +static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state)
> > +{
> > +	struct amd_cpudata *cpudata = policy->driver_data;
> > +	int ret;
> > +
> > +	if (!cpudata->boost_supported) {
> > +		pr_err("Boost mode is not supported by this processor or SBIOS\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	if (state)
> > +		policy->cpuinfo.max_freq = cpudata->max_freq;
> > +	else
> > +		policy->cpuinfo.max_freq = cpudata->nominal_freq;
> > +
> > +	policy->max = policy->cpuinfo.max_freq;
> > +
> > +	ret = freq_qos_update_request(&cpudata->req[1],
> > +				      policy->cpuinfo.max_freq);
> > +	if (ret < 0)
> > +		return ret;
> > +
> > +	return 0;
> > +}
> > +
> > +static void amd_pstate_boost_init(struct amd_cpudata *cpudata)
> > +{
> > +	cpudata->boost_supported = true;
> > +	amd_pstate_driver.boost_enabled = true;
> > +}
> > +
> >  static int amd_pstate_init_freqs_in_cpudata(struct amd_cpudata *cpudata,
> >  					    u32 max_freq, u32 min_freq,
> >  					    u32 nominal_freq,
> > @@ -504,6 +550,9 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
> >  
> >  	policy->driver_data = cpudata;
> >  
> > +	if (amd_pstate_boost_supported(cpudata))
> > +		amd_pstate_boost_init(cpudata);
> 
> Is there any reason to not merge amd_pstate_boost_supported() and
> amd_pstate_boost_init() into a single function? I don't see that
> amd_pstate_boost_supported() is called anywhere else.
> 

Sounds reasonable. Will update it in V2 as well.

Thanks,
Ray

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ