Skip to content

Commit 009d1c2

Browse files
committed
cpufreq/amd-pstate: Move perf values into a union
By storing perf values in a union all the writes and reads can be done atomically, removing the need for some concurrency protections. While making this change, also drop the cached frequency values, using inline helpers to calculate them on demand from perf value. Reviewed-by: Gautham R. Shenoy <[email protected]> Reviewed-by: Dhananjay Ugwekar <[email protected]> Signed-off-by: Mario Limonciello <[email protected]>
1 parent a9b9b4c commit 009d1c2

File tree

3 files changed

+162
-120
lines changed

3 files changed

+162
-120
lines changed

drivers/cpufreq/amd-pstate-ut.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ static void amd_pstate_ut_check_perf(u32 index)
129129
struct cppc_perf_caps cppc_perf;
130130
struct cpufreq_policy *policy = NULL;
131131
struct amd_cpudata *cpudata = NULL;
132+
union perf_cached cur_perf;
132133

133134
for_each_possible_cpu(cpu) {
134135
policy = cpufreq_cpu_get(cpu);
@@ -162,19 +163,20 @@ static void amd_pstate_ut_check_perf(u32 index)
162163
lowest_perf = AMD_CPPC_LOWEST_PERF(cap1);
163164
}
164165

165-
if (highest_perf != READ_ONCE(cpudata->highest_perf) && !cpudata->hw_prefcore) {
166+
cur_perf = READ_ONCE(cpudata->perf);
167+
if (highest_perf != cur_perf.highest_perf && !cpudata->hw_prefcore) {
166168
pr_err("%s cpu%d highest=%d %d highest perf doesn't match\n",
167-
__func__, cpu, highest_perf, cpudata->highest_perf);
169+
__func__, cpu, highest_perf, cur_perf.highest_perf);
168170
goto skip_test;
169171
}
170-
if ((nominal_perf != READ_ONCE(cpudata->nominal_perf)) ||
171-
(lowest_nonlinear_perf != READ_ONCE(cpudata->lowest_nonlinear_perf)) ||
172-
(lowest_perf != READ_ONCE(cpudata->lowest_perf))) {
172+
if (nominal_perf != cur_perf.nominal_perf ||
173+
(lowest_nonlinear_perf != cur_perf.lowest_nonlinear_perf) ||
174+
(lowest_perf != cur_perf.lowest_perf)) {
173175
amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
174176
pr_err("%s cpu%d nominal=%d %d lowest_nonlinear=%d %d lowest=%d %d, they should be equal!\n",
175-
__func__, cpu, nominal_perf, cpudata->nominal_perf,
176-
lowest_nonlinear_perf, cpudata->lowest_nonlinear_perf,
177-
lowest_perf, cpudata->lowest_perf);
177+
__func__, cpu, nominal_perf, cur_perf.nominal_perf,
178+
lowest_nonlinear_perf, cur_perf.lowest_nonlinear_perf,
179+
lowest_perf, cur_perf.lowest_perf);
178180
goto skip_test;
179181
}
180182

0 commit comments

Comments
 (0)