mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-09-03 17:51:23 +00:00
cpufreq/amd-pstate: Store the boost numerator as highest perf again
commitad4caad58d
("cpufreq: amd-pstate: Merge amd_pstate_highest_perf_set() into amd_get_boost_ratio_numerator()") changed the semantics for highest perf and commit18d9b52271
("cpufreq/amd-pstate: Use nominal perf for limits when boost is disabled") worked around those semantic changes. This however is a confusing result and furthermore makes it awkward to change frequency limits and boost due to the scaling differences. Restore the boost numerator to highest perf again. Suggested-by: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com> Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com> Fixes:ad4caad58d
("cpufreq: amd-pstate: Merge amd_pstate_highest_perf_set() into amd_get_boost_ratio_numerator()") Link: https://lore.kernel.org/r/20241209185248.16301-2-mario.limonciello@amd.com Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
This commit is contained in:
parent
919bfa9b2d
commit
50a062a762
@ -251,9 +251,7 @@ performance supported in `AMD CPPC Performance Capability <perf_cap_>`_).
|
|||||||
In some ASICs, the highest CPPC performance is not the one in the ``_CPC``
|
In some ASICs, the highest CPPC performance is not the one in the ``_CPC``
|
||||||
table, so we need to expose it to sysfs. If boost is not active, but
|
table, so we need to expose it to sysfs. If boost is not active, but
|
||||||
still supported, this maximum frequency will be larger than the one in
|
still supported, this maximum frequency will be larger than the one in
|
||||||
``cpuinfo``. On systems that support preferred core, the driver will have
|
``cpuinfo``.
|
||||||
different values for some cores than others and this will reflect the values
|
|
||||||
advertised by the platform at bootup.
|
|
||||||
This attribute is read-only.
|
This attribute is read-only.
|
||||||
|
|
||||||
``amd_pstate_lowest_nonlinear_freq``
|
``amd_pstate_lowest_nonlinear_freq``
|
||||||
|
@ -374,15 +374,19 @@ static inline int amd_pstate_cppc_enable(bool enable)
|
|||||||
|
|
||||||
static int msr_init_perf(struct amd_cpudata *cpudata)
|
static int msr_init_perf(struct amd_cpudata *cpudata)
|
||||||
{
|
{
|
||||||
u64 cap1;
|
u64 cap1, numerator;
|
||||||
|
|
||||||
int ret = rdmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_CAP1,
|
int ret = rdmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_CAP1,
|
||||||
&cap1);
|
&cap1);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
WRITE_ONCE(cpudata->highest_perf, AMD_CPPC_HIGHEST_PERF(cap1));
|
ret = amd_get_boost_ratio_numerator(cpudata->cpu, &numerator);
|
||||||
WRITE_ONCE(cpudata->max_limit_perf, AMD_CPPC_HIGHEST_PERF(cap1));
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
WRITE_ONCE(cpudata->highest_perf, numerator);
|
||||||
|
WRITE_ONCE(cpudata->max_limit_perf, numerator);
|
||||||
WRITE_ONCE(cpudata->nominal_perf, AMD_CPPC_NOMINAL_PERF(cap1));
|
WRITE_ONCE(cpudata->nominal_perf, AMD_CPPC_NOMINAL_PERF(cap1));
|
||||||
WRITE_ONCE(cpudata->lowest_nonlinear_perf, AMD_CPPC_LOWNONLIN_PERF(cap1));
|
WRITE_ONCE(cpudata->lowest_nonlinear_perf, AMD_CPPC_LOWNONLIN_PERF(cap1));
|
||||||
WRITE_ONCE(cpudata->lowest_perf, AMD_CPPC_LOWEST_PERF(cap1));
|
WRITE_ONCE(cpudata->lowest_perf, AMD_CPPC_LOWEST_PERF(cap1));
|
||||||
@ -394,13 +398,18 @@ static int msr_init_perf(struct amd_cpudata *cpudata)
|
|||||||
static int shmem_init_perf(struct amd_cpudata *cpudata)
|
static int shmem_init_perf(struct amd_cpudata *cpudata)
|
||||||
{
|
{
|
||||||
struct cppc_perf_caps cppc_perf;
|
struct cppc_perf_caps cppc_perf;
|
||||||
|
u64 numerator;
|
||||||
|
|
||||||
int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);
|
int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
WRITE_ONCE(cpudata->highest_perf, cppc_perf.highest_perf);
|
ret = amd_get_boost_ratio_numerator(cpudata->cpu, &numerator);
|
||||||
WRITE_ONCE(cpudata->max_limit_perf, cppc_perf.highest_perf);
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
WRITE_ONCE(cpudata->highest_perf, numerator);
|
||||||
|
WRITE_ONCE(cpudata->max_limit_perf, numerator);
|
||||||
WRITE_ONCE(cpudata->nominal_perf, cppc_perf.nominal_perf);
|
WRITE_ONCE(cpudata->nominal_perf, cppc_perf.nominal_perf);
|
||||||
WRITE_ONCE(cpudata->lowest_nonlinear_perf,
|
WRITE_ONCE(cpudata->lowest_nonlinear_perf,
|
||||||
cppc_perf.lowest_nonlinear_perf);
|
cppc_perf.lowest_nonlinear_perf);
|
||||||
@ -889,7 +898,6 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
u32 min_freq, max_freq;
|
u32 min_freq, max_freq;
|
||||||
u64 numerator;
|
|
||||||
u32 nominal_perf, nominal_freq;
|
u32 nominal_perf, nominal_freq;
|
||||||
u32 lowest_nonlinear_perf, lowest_nonlinear_freq;
|
u32 lowest_nonlinear_perf, lowest_nonlinear_freq;
|
||||||
u32 boost_ratio, lowest_nonlinear_ratio;
|
u32 boost_ratio, lowest_nonlinear_ratio;
|
||||||
@ -911,10 +919,7 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
|
|||||||
|
|
||||||
nominal_perf = READ_ONCE(cpudata->nominal_perf);
|
nominal_perf = READ_ONCE(cpudata->nominal_perf);
|
||||||
|
|
||||||
ret = amd_get_boost_ratio_numerator(cpudata->cpu, &numerator);
|
boost_ratio = div_u64(cpudata->highest_perf << SCHED_CAPACITY_SHIFT, nominal_perf);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
boost_ratio = div_u64(numerator << SCHED_CAPACITY_SHIFT, nominal_perf);
|
|
||||||
max_freq = (nominal_freq * boost_ratio >> SCHED_CAPACITY_SHIFT) * 1000;
|
max_freq = (nominal_freq * boost_ratio >> SCHED_CAPACITY_SHIFT) * 1000;
|
||||||
|
|
||||||
lowest_nonlinear_perf = READ_ONCE(cpudata->lowest_nonlinear_perf);
|
lowest_nonlinear_perf = READ_ONCE(cpudata->lowest_nonlinear_perf);
|
||||||
|
Loading…
Reference in New Issue
Block a user