Skip to content

Commit 474e721

Browse files
committed
cpufreq/amd-pstate: Only update the cached value in msr_set_epp() on success
If writing the MSR MSR_AMD_CPPC_REQ fails then the cached value in the amd_cpudata structure should not be updated. Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com> Link: https://lore.kernel.org/r/20241209185248.16301-8-mario.limonciello@amd.com Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
1 parent 88a95ba commit 474e721

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,15 @@ static int msr_set_epp(struct amd_cpudata *cpudata, u32 epp)
278278

279279
value &= ~AMD_CPPC_EPP_PERF_MASK;
280280
value |= FIELD_PREP(AMD_CPPC_EPP_PERF_MASK, epp);
281-
WRITE_ONCE(cpudata->cppc_req_cached, value);
282281

283282
ret = wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, value);
284-
if (!ret)
285-
cpudata->epp_cached = epp;
283+
if (ret) {
284+
pr_err("failed to set energy perf value (%d)\n", ret);
285+
return ret;
286+
}
287+
288+
cpudata->epp_cached = epp;
289+
WRITE_ONCE(cpudata->cppc_req_cached, value);
286290

287291
return ret;
288292
}

0 commit comments

Comments
 (0)