Skip to content

Commit 50a062a

Browse files
committed
cpufreq/amd-pstate: Store the boost numerator as highest perf again
commit ad4caad ("cpufreq: amd-pstate: Merge amd_pstate_highest_perf_set() into amd_get_boost_ratio_numerator()") changed the semantics for highest perf and commit 18d9b52 ("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: ad4caad ("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>
1 parent 919bfa9 commit 50a062a

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

Documentation/admin-guide/pm/amd-pstate.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,7 @@ performance supported in `AMD CPPC Performance Capability <perf_cap_>`_).
251251
In some ASICs, the highest CPPC performance is not the one in the ``_CPC``
252252
table, so we need to expose it to sysfs. If boost is not active, but
253253
still supported, this maximum frequency will be larger than the one in
254-
``cpuinfo``. On systems that support preferred core, the driver will have
255-
different values for some cores than others and this will reflect the values
256-
advertised by the platform at bootup.
254+
``cpuinfo``.
257255
This attribute is read-only.
258256

259257
``amd_pstate_lowest_nonlinear_freq``

drivers/cpufreq/amd-pstate.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,19 @@ static inline int amd_pstate_cppc_enable(bool enable)
374374

375375
static int msr_init_perf(struct amd_cpudata *cpudata)
376376
{
377-
u64 cap1;
377+
u64 cap1, numerator;
378378

379379
int ret = rdmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_CAP1,
380380
&cap1);
381381
if (ret)
382382
return ret;
383383

384-
WRITE_ONCE(cpudata->highest_perf, AMD_CPPC_HIGHEST_PERF(cap1));
385-
WRITE_ONCE(cpudata->max_limit_perf, AMD_CPPC_HIGHEST_PERF(cap1));
384+
ret = amd_get_boost_ratio_numerator(cpudata->cpu, &numerator);
385+
if (ret)
386+
return ret;
387+
388+
WRITE_ONCE(cpudata->highest_perf, numerator);
389+
WRITE_ONCE(cpudata->max_limit_perf, numerator);
386390
WRITE_ONCE(cpudata->nominal_perf, AMD_CPPC_NOMINAL_PERF(cap1));
387391
WRITE_ONCE(cpudata->lowest_nonlinear_perf, AMD_CPPC_LOWNONLIN_PERF(cap1));
388392
WRITE_ONCE(cpudata->lowest_perf, AMD_CPPC_LOWEST_PERF(cap1));
@@ -394,13 +398,18 @@ static int msr_init_perf(struct amd_cpudata *cpudata)
394398
static int shmem_init_perf(struct amd_cpudata *cpudata)
395399
{
396400
struct cppc_perf_caps cppc_perf;
401+
u64 numerator;
397402

398403
int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf);
399404
if (ret)
400405
return ret;
401406

402-
WRITE_ONCE(cpudata->highest_perf, cppc_perf.highest_perf);
403-
WRITE_ONCE(cpudata->max_limit_perf, cppc_perf.highest_perf);
407+
ret = amd_get_boost_ratio_numerator(cpudata->cpu, &numerator);
408+
if (ret)
409+
return ret;
410+
411+
WRITE_ONCE(cpudata->highest_perf, numerator);
412+
WRITE_ONCE(cpudata->max_limit_perf, numerator);
404413
WRITE_ONCE(cpudata->nominal_perf, cppc_perf.nominal_perf);
405414
WRITE_ONCE(cpudata->lowest_nonlinear_perf,
406415
cppc_perf.lowest_nonlinear_perf);
@@ -889,7 +898,6 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
889898
{
890899
int ret;
891900
u32 min_freq, max_freq;
892-
u64 numerator;
893901
u32 nominal_perf, nominal_freq;
894902
u32 lowest_nonlinear_perf, lowest_nonlinear_freq;
895903
u32 boost_ratio, lowest_nonlinear_ratio;
@@ -911,10 +919,7 @@ static int amd_pstate_init_freq(struct amd_cpudata *cpudata)
911919

912920
nominal_perf = READ_ONCE(cpudata->nominal_perf);
913921

914-
ret = amd_get_boost_ratio_numerator(cpudata->cpu, &numerator);
915-
if (ret)
916-
return ret;
917-
boost_ratio = div_u64(numerator << SCHED_CAPACITY_SHIFT, nominal_perf);
922+
boost_ratio = div_u64(cpudata->highest_perf << SCHED_CAPACITY_SHIFT, nominal_perf);
918923
max_freq = (nominal_freq * boost_ratio >> SCHED_CAPACITY_SHIFT) * 1000;
919924

920925
lowest_nonlinear_perf = READ_ONCE(cpudata->lowest_nonlinear_perf);

0 commit comments

Comments
 (0)