Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit e23f41c

Browse files
committed
Merge tag 'amd-pstate-v6.11-2024-07-07' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/superm1/linux
Merge more amd-pstate changes for 6.11 from Mario Liminciello: "This adds fixes for setting scaling max frequency on systems without a dedicated MSR for setting CPPC requests." * tag 'amd-pstate-v6.11-2024-07-07' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/superm1/linux: cpufreq/amd-pstate: Fix the scaling_max_freq setting on shared memory CPPC systems cpufreq/amd-pstate-ut: Convert nominal_freq to khz during comparisons
2 parents 29acea1 + 738d7d0 commit e23f41c

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

drivers/cpufreq/amd-pstate-ut.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,20 +202,22 @@ static void amd_pstate_ut_check_freq(u32 index)
202202
int cpu = 0;
203203
struct cpufreq_policy *policy = NULL;
204204
struct amd_cpudata *cpudata = NULL;
205+
u32 nominal_freq_khz;
205206

206207
for_each_possible_cpu(cpu) {
207208
policy = cpufreq_cpu_get(cpu);
208209
if (!policy)
209210
break;
210211
cpudata = policy->driver_data;
211212

212-
if (!((cpudata->max_freq >= cpudata->nominal_freq) &&
213-
(cpudata->nominal_freq > cpudata->lowest_nonlinear_freq) &&
213+
nominal_freq_khz = cpudata->nominal_freq*1000;
214+
if (!((cpudata->max_freq >= nominal_freq_khz) &&
215+
(nominal_freq_khz > cpudata->lowest_nonlinear_freq) &&
214216
(cpudata->lowest_nonlinear_freq > cpudata->min_freq) &&
215217
(cpudata->min_freq > 0))) {
216218
amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
217219
pr_err("%s cpu%d max=%d >= nominal=%d > lowest_nonlinear=%d > min=%d > 0, the formula is incorrect!\n",
218-
__func__, cpu, cpudata->max_freq, cpudata->nominal_freq,
220+
__func__, cpu, cpudata->max_freq, nominal_freq_khz,
219221
cpudata->lowest_nonlinear_freq, cpudata->min_freq);
220222
goto skip_test;
221223
}
@@ -229,13 +231,13 @@ static void amd_pstate_ut_check_freq(u32 index)
229231

230232
if (cpudata->boost_supported) {
231233
if ((policy->max == cpudata->max_freq) ||
232-
(policy->max == cpudata->nominal_freq))
234+
(policy->max == nominal_freq_khz))
233235
amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS;
234236
else {
235237
amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
236238
pr_err("%s cpu%d policy_max=%d should be equal cpu_max=%d or cpu_nominal=%d !\n",
237239
__func__, cpu, policy->max, cpudata->max_freq,
238-
cpudata->nominal_freq);
240+
nominal_freq_khz);
239241
goto skip_test;
240242
}
241243
} else {

drivers/cpufreq/amd-pstate.c

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,26 @@ static int amd_pstate_get_energy_pref_index(struct amd_cpudata *cpudata)
239239
return index;
240240
}
241241

242+
static void pstate_update_perf(struct amd_cpudata *cpudata, u32 min_perf,
243+
u32 des_perf, u32 max_perf, bool fast_switch)
244+
{
245+
if (fast_switch)
246+
wrmsrl(MSR_AMD_CPPC_REQ, READ_ONCE(cpudata->cppc_req_cached));
247+
else
248+
wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ,
249+
READ_ONCE(cpudata->cppc_req_cached));
250+
}
251+
252+
DEFINE_STATIC_CALL(amd_pstate_update_perf, pstate_update_perf);
253+
254+
static inline void amd_pstate_update_perf(struct amd_cpudata *cpudata,
255+
u32 min_perf, u32 des_perf,
256+
u32 max_perf, bool fast_switch)
257+
{
258+
static_call(amd_pstate_update_perf)(cpudata, min_perf, des_perf,
259+
max_perf, fast_switch);
260+
}
261+
242262
static int amd_pstate_set_epp(struct amd_cpudata *cpudata, u32 epp)
243263
{
244264
int ret;
@@ -255,6 +275,9 @@ static int amd_pstate_set_epp(struct amd_cpudata *cpudata, u32 epp)
255275
if (!ret)
256276
cpudata->epp_cached = epp;
257277
} else {
278+
amd_pstate_update_perf(cpudata, cpudata->min_limit_perf, 0U,
279+
cpudata->max_limit_perf, false);
280+
258281
perf_ctrls.energy_perf = epp;
259282
ret = cppc_set_epp_perf(cpudata->cpu, &perf_ctrls, 1);
260283
if (ret) {
@@ -442,16 +465,6 @@ static inline int amd_pstate_init_perf(struct amd_cpudata *cpudata)
442465
return static_call(amd_pstate_init_perf)(cpudata);
443466
}
444467

445-
static void pstate_update_perf(struct amd_cpudata *cpudata, u32 min_perf,
446-
u32 des_perf, u32 max_perf, bool fast_switch)
447-
{
448-
if (fast_switch)
449-
wrmsrl(MSR_AMD_CPPC_REQ, READ_ONCE(cpudata->cppc_req_cached));
450-
else
451-
wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ,
452-
READ_ONCE(cpudata->cppc_req_cached));
453-
}
454-
455468
static void cppc_update_perf(struct amd_cpudata *cpudata,
456469
u32 min_perf, u32 des_perf,
457470
u32 max_perf, bool fast_switch)
@@ -465,16 +478,6 @@ static void cppc_update_perf(struct amd_cpudata *cpudata,
465478
cppc_set_perf(cpudata->cpu, &perf_ctrls);
466479
}
467480

468-
DEFINE_STATIC_CALL(amd_pstate_update_perf, pstate_update_perf);
469-
470-
static inline void amd_pstate_update_perf(struct amd_cpudata *cpudata,
471-
u32 min_perf, u32 des_perf,
472-
u32 max_perf, bool fast_switch)
473-
{
474-
static_call(amd_pstate_update_perf)(cpudata, min_perf, des_perf,
475-
max_perf, fast_switch);
476-
}
477-
478481
static inline bool amd_pstate_sample(struct amd_cpudata *cpudata)
479482
{
480483
u64 aperf, mperf, tsc;

0 commit comments

Comments
 (0)