Commit f21ab5ed authored by Dhananjay Ugwekar's avatar Dhananjay Ugwekar Committed by Mario Limonciello

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: e4731baa ("cpufreq: amd-pstate: Fix the inconsistency in max frequency units")
Reported-by: default avatarDavid Arcari <darcari@redhat.com>
Signed-off-by: default avatarDhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
Reviewed-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Reviewed-by: default avatarGautham R. Shenoy <gautham.shenoy@amd.com>
Link: https://lore.kernel.org/r/20240702081413.5688-2-Dhananjay.Ugwekar@amd.comSigned-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
parent 6d588891
...@@ -202,6 +202,7 @@ static void amd_pstate_ut_check_freq(u32 index) ...@@ -202,6 +202,7 @@ static void amd_pstate_ut_check_freq(u32 index)
int cpu = 0; int cpu = 0;
struct cpufreq_policy *policy = NULL; struct cpufreq_policy *policy = NULL;
struct amd_cpudata *cpudata = NULL; struct amd_cpudata *cpudata = NULL;
u32 nominal_freq_khz;
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
policy = cpufreq_cpu_get(cpu); policy = cpufreq_cpu_get(cpu);
...@@ -209,13 +210,14 @@ static void amd_pstate_ut_check_freq(u32 index) ...@@ -209,13 +210,14 @@ static void amd_pstate_ut_check_freq(u32 index)
break; break;
cpudata = policy->driver_data; cpudata = policy->driver_data;
if (!((cpudata->max_freq >= cpudata->nominal_freq) && nominal_freq_khz = cpudata->nominal_freq*1000;
(cpudata->nominal_freq > cpudata->lowest_nonlinear_freq) && if (!((cpudata->max_freq >= nominal_freq_khz) &&
(nominal_freq_khz > cpudata->lowest_nonlinear_freq) &&
(cpudata->lowest_nonlinear_freq > cpudata->min_freq) && (cpudata->lowest_nonlinear_freq > cpudata->min_freq) &&
(cpudata->min_freq > 0))) { (cpudata->min_freq > 0))) {
amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
pr_err("%s cpu%d max=%d >= nominal=%d > lowest_nonlinear=%d > min=%d > 0, the formula is incorrect!\n", pr_err("%s cpu%d max=%d >= nominal=%d > lowest_nonlinear=%d > min=%d > 0, the formula is incorrect!\n",
__func__, cpu, cpudata->max_freq, cpudata->nominal_freq, __func__, cpu, cpudata->max_freq, nominal_freq_khz,
cpudata->lowest_nonlinear_freq, cpudata->min_freq); cpudata->lowest_nonlinear_freq, cpudata->min_freq);
goto skip_test; goto skip_test;
} }
...@@ -229,13 +231,13 @@ static void amd_pstate_ut_check_freq(u32 index) ...@@ -229,13 +231,13 @@ static void amd_pstate_ut_check_freq(u32 index)
if (cpudata->boost_supported) { if (cpudata->boost_supported) {
if ((policy->max == cpudata->max_freq) || if ((policy->max == cpudata->max_freq) ||
(policy->max == cpudata->nominal_freq)) (policy->max == nominal_freq_khz))
amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS; amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS;
else { else {
amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
pr_err("%s cpu%d policy_max=%d should be equal cpu_max=%d or cpu_nominal=%d !\n", pr_err("%s cpu%d policy_max=%d should be equal cpu_max=%d or cpu_nominal=%d !\n",
__func__, cpu, policy->max, cpudata->max_freq, __func__, cpu, policy->max, cpudata->max_freq,
cpudata->nominal_freq); nominal_freq_khz);
goto skip_test; goto skip_test;
} }
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment