Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: e4731baaf294 ("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>

authored by

Dhananjay Ugwekar and committed by
Mario Limonciello
f21ab5ed 6d588891

+7 -5
+7 -5
drivers/cpufreq/amd-pstate-ut.c
··· 202 202 int cpu = 0; 203 203 struct cpufreq_policy *policy = NULL; 204 204 struct amd_cpudata *cpudata = NULL; 205 + u32 nominal_freq_khz; 205 206 206 207 for_each_possible_cpu(cpu) { 207 208 policy = cpufreq_cpu_get(cpu); ··· 210 209 break; 211 210 cpudata = policy->driver_data; 212 211 213 - if (!((cpudata->max_freq >= cpudata->nominal_freq) && 214 - (cpudata->nominal_freq > cpudata->lowest_nonlinear_freq) && 212 + nominal_freq_khz = cpudata->nominal_freq*1000; 213 + if (!((cpudata->max_freq >= nominal_freq_khz) && 214 + (nominal_freq_khz > cpudata->lowest_nonlinear_freq) && 215 215 (cpudata->lowest_nonlinear_freq > cpudata->min_freq) && 216 216 (cpudata->min_freq > 0))) { 217 217 amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; 218 218 pr_err("%s cpu%d max=%d >= nominal=%d > lowest_nonlinear=%d > min=%d > 0, the formula is incorrect!\n", 219 - __func__, cpu, cpudata->max_freq, cpudata->nominal_freq, 219 + __func__, cpu, cpudata->max_freq, nominal_freq_khz, 220 220 cpudata->lowest_nonlinear_freq, cpudata->min_freq); 221 221 goto skip_test; 222 222 } ··· 231 229 232 230 if (cpudata->boost_supported) { 233 231 if ((policy->max == cpudata->max_freq) || 234 - (policy->max == cpudata->nominal_freq)) 232 + (policy->max == nominal_freq_khz)) 235 233 amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS; 236 234 else { 237 235 amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL; 238 236 pr_err("%s cpu%d policy_max=%d should be equal cpu_max=%d or cpu_nominal=%d !\n", 239 237 __func__, cpu, policy->max, cpudata->max_freq, 240 - cpudata->nominal_freq); 238 + nominal_freq_khz); 241 239 goto skip_test; 242 240 } 243 241 } else {