Skip to content

Commit 4e16c11

Browse files
committed
cpufreq/amd-pstate: Stop caching EPP
EPP values are cached in the cpudata structure per CPU. This is needless though because they are also cached in the CPPC request variable. Drop the separate cache for EPP values and always reference the CPPC request variable when needed. Reviewed-by: Dhananjay Ugwekar <[email protected]> Reviewed-by: Gautham R. Shenoy <[email protected]> Signed-off-by: Mario Limonciello <[email protected]>
1 parent 2064543 commit 4e16c11

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,6 @@ static int msr_update_perf(struct cpufreq_policy *policy, u8 min_perf,
268268
}
269269

270270
WRITE_ONCE(cpudata->cppc_req_cached, value);
271-
if (epp != cpudata->epp_cached)
272-
WRITE_ONCE(cpudata->epp_cached, epp);
273271

274272
return 0;
275273
}
@@ -318,7 +316,6 @@ static int msr_set_epp(struct cpufreq_policy *policy, u8 epp)
318316
}
319317

320318
/* update both so that msr_update_perf() can effectively check */
321-
WRITE_ONCE(cpudata->epp_cached, epp);
322319
WRITE_ONCE(cpudata->cppc_req_cached, value);
323320

324321
return ret;
@@ -335,9 +332,12 @@ static int shmem_set_epp(struct cpufreq_policy *policy, u8 epp)
335332
{
336333
struct amd_cpudata *cpudata = policy->driver_data;
337334
struct cppc_perf_ctrls perf_ctrls;
335+
u8 epp_cached;
338336
u64 value;
339337
int ret;
340338

339+
340+
epp_cached = FIELD_GET(AMD_CPPC_EPP_PERF_MASK, cpudata->cppc_req_cached);
341341
if (trace_amd_pstate_epp_perf_enabled()) {
342342
union perf_cached perf = cpudata->perf;
343343

@@ -348,10 +348,10 @@ static int shmem_set_epp(struct cpufreq_policy *policy, u8 epp)
348348
FIELD_GET(AMD_CPPC_MAX_PERF_MASK,
349349
cpudata->cppc_req_cached),
350350
policy->boost_enabled,
351-
epp != cpudata->epp_cached);
351+
epp != epp_cached);
352352
}
353353

354-
if (epp == cpudata->epp_cached)
354+
if (epp == epp_cached)
355355
return 0;
356356

357357
perf_ctrls.energy_perf = epp;
@@ -360,7 +360,6 @@ static int shmem_set_epp(struct cpufreq_policy *policy, u8 epp)
360360
pr_debug("failed to set energy perf value (%d)\n", ret);
361361
return ret;
362362
}
363-
WRITE_ONCE(cpudata->epp_cached, epp);
364363

365364
value = READ_ONCE(cpudata->cppc_req_cached);
366365
value &= ~AMD_CPPC_EPP_PERF_MASK;
@@ -1168,9 +1167,11 @@ static ssize_t show_energy_performance_preference(
11681167
struct cpufreq_policy *policy, char *buf)
11691168
{
11701169
struct amd_cpudata *cpudata = policy->driver_data;
1171-
u8 preference;
1170+
u8 preference, epp;
1171+
1172+
epp = FIELD_GET(AMD_CPPC_EPP_PERF_MASK, cpudata->cppc_req_cached);
11721173

1173-
switch (cpudata->epp_cached) {
1174+
switch (epp) {
11741175
case AMD_CPPC_EPP_PERFORMANCE:
11751176
preference = EPP_INDEX_PERFORMANCE;
11761177
break;
@@ -1533,7 +1534,7 @@ static int amd_pstate_epp_update_limit(struct cpufreq_policy *policy)
15331534
if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE)
15341535
epp = 0;
15351536
else
1536-
epp = READ_ONCE(cpudata->epp_cached);
1537+
epp = FIELD_GET(AMD_CPPC_EPP_PERF_MASK, cpudata->cppc_req_cached);
15371538

15381539
perf = READ_ONCE(cpudata->perf);
15391540

drivers/cpufreq/amd-pstate.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ struct amd_cpudata {
102102
bool hw_prefcore;
103103

104104
/* EPP feature related attributes*/
105-
u8 epp_cached;
106105
u32 policy;
107106
bool suspended;
108107
u8 epp_default;

0 commit comments

Comments
 (0)