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

Commit f21ab5e

Browse files
dhananjay-AMDsuperm1
authored andcommitted
cpufreq/amd-pstate-ut: Convert nominal_freq to khz during comparisons
cpudata->nominal_freq being in MHz whereas other frequencies being in KHz breaks the amd-pstate-ut frequency sanity check. This fixes it. Fixes: e4731ba ("cpufreq: amd-pstate: Fix the inconsistency in max frequency units") Reported-by: David Arcari <darcari@redhat.com> Signed-off-by: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com> Link: https://lore.kernel.org/r/20240702081413.5688-2-Dhananjay.Ugwekar@amd.com Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
1 parent 6d58889 commit f21ab5e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
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 {

0 commit comments

Comments
 (0)