Messages in this thread | | | Date | Thu, 9 Sep 2021 18:12:48 +0800 | From | Huang Rui <> | 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@amd.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
| |