139 lines
4.4 KiB
Diff
139 lines
4.4 KiB
Diff
|
From ce0dd337e839cfa3033b9035a37de98e28abde1c Mon Sep 17 00:00:00 2001
|
||
|
From: Mario Limonciello <mario.limonciello@amd.com>
|
||
|
Date: Mon, 9 Dec 2024 12:52:48 -0600
|
||
|
Subject: cpufreq/amd-pstate: Drop boost_state variable
|
||
|
|
||
|
Currently boost_state is cached for every processor in cpudata structure
|
||
|
and driver boost state is set for every processor.
|
||
|
|
||
|
Both of these aren't necessary as the driver only needs to set once and
|
||
|
the policy stores whether boost is enabled.
|
||
|
|
||
|
Move the driver boost setting to registration and adjust all references
|
||
|
to cached value to pull from the policy instead.
|
||
|
|
||
|
Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
|
||
|
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
|
||
|
---
|
||
|
drivers/cpufreq/amd-pstate.c | 26 +++++++++++++-------------
|
||
|
drivers/cpufreq/amd-pstate.h | 1 -
|
||
|
2 files changed, 13 insertions(+), 14 deletions(-)
|
||
|
|
||
|
--- a/drivers/cpufreq/amd-pstate.c
|
||
|
+++ b/drivers/cpufreq/amd-pstate.c
|
||
|
@@ -345,9 +345,10 @@ static int shmem_set_epp(struct amd_cpud
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
-static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata,
|
||
|
- int pref_index)
|
||
|
+static int amd_pstate_set_energy_pref_index(struct cpufreq_policy *policy,
|
||
|
+ int pref_index)
|
||
|
{
|
||
|
+ struct amd_cpudata *cpudata = policy->driver_data;
|
||
|
int epp;
|
||
|
|
||
|
if (!pref_index)
|
||
|
@@ -365,7 +366,7 @@ static int amd_pstate_set_energy_pref_in
|
||
|
epp,
|
||
|
AMD_CPPC_MIN_PERF(cpudata->cppc_req_cached),
|
||
|
AMD_CPPC_MAX_PERF(cpudata->cppc_req_cached),
|
||
|
- cpudata->boost_state);
|
||
|
+ policy->boost_enabled);
|
||
|
}
|
||
|
|
||
|
return amd_pstate_set_epp(cpudata, epp);
|
||
|
@@ -776,7 +777,6 @@ static int amd_pstate_set_boost(struct c
|
||
|
guard(mutex)(&amd_pstate_driver_lock);
|
||
|
|
||
|
ret = amd_pstate_cpu_boost_update(policy, state);
|
||
|
- WRITE_ONCE(cpudata->boost_state, !ret ? state : false);
|
||
|
policy->boost_enabled = !ret ? state : false;
|
||
|
refresh_frequency_limits(policy);
|
||
|
|
||
|
@@ -798,9 +798,6 @@ static int amd_pstate_init_boost_support
|
||
|
goto exit_err;
|
||
|
}
|
||
|
|
||
|
- /* at least one CPU supports CPB, even if others fail later on to set up */
|
||
|
- current_pstate_driver->boost_enabled = true;
|
||
|
-
|
||
|
ret = rdmsrl_on_cpu(cpudata->cpu, MSR_K7_HWCR, &boost_val);
|
||
|
if (ret) {
|
||
|
pr_err_once("failed to read initial CPU boost state!\n");
|
||
|
@@ -1206,7 +1203,6 @@ static ssize_t show_energy_performance_a
|
||
|
static ssize_t store_energy_performance_preference(
|
||
|
struct cpufreq_policy *policy, const char *buf, size_t count)
|
||
|
{
|
||
|
- struct amd_cpudata *cpudata = policy->driver_data;
|
||
|
char str_preference[21];
|
||
|
ssize_t ret;
|
||
|
|
||
|
@@ -1220,7 +1216,7 @@ static ssize_t store_energy_performance_
|
||
|
|
||
|
guard(mutex)(&amd_pstate_limits_lock);
|
||
|
|
||
|
- ret = amd_pstate_set_energy_pref_index(cpudata, ret);
|
||
|
+ ret = amd_pstate_set_energy_pref_index(policy, ret);
|
||
|
|
||
|
return ret ? ret : count;
|
||
|
}
|
||
|
@@ -1295,6 +1291,9 @@ static int amd_pstate_register_driver(in
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
+ /* at least one CPU supports CPB */
|
||
|
+ current_pstate_driver->boost_enabled = cpu_feature_enabled(X86_FEATURE_CPB);
|
||
|
+
|
||
|
ret = cpufreq_register_driver(current_pstate_driver);
|
||
|
if (ret) {
|
||
|
amd_pstate_driver_cleanup();
|
||
|
@@ -1636,8 +1635,9 @@ static int amd_pstate_epp_set_policy(str
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
-static int amd_pstate_epp_reenable(struct amd_cpudata *cpudata)
|
||
|
+static int amd_pstate_epp_reenable(struct cpufreq_policy *policy)
|
||
|
{
|
||
|
+ struct amd_cpudata *cpudata = policy->driver_data;
|
||
|
u64 max_perf;
|
||
|
int ret;
|
||
|
|
||
|
@@ -1651,7 +1651,7 @@ static int amd_pstate_epp_reenable(struc
|
||
|
trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf,
|
||
|
cpudata->epp_cached,
|
||
|
AMD_CPPC_MIN_PERF(cpudata->cppc_req_cached),
|
||
|
- max_perf, cpudata->boost_state);
|
||
|
+ max_perf, policy->boost_enabled);
|
||
|
}
|
||
|
|
||
|
return amd_pstate_update_perf(cpudata, 0, 0, max_perf, cpudata->epp_cached, false);
|
||
|
@@ -1664,7 +1664,7 @@ static int amd_pstate_epp_cpu_online(str
|
||
|
|
||
|
pr_debug("AMD CPU Core %d going online\n", cpudata->cpu);
|
||
|
|
||
|
- ret = amd_pstate_epp_reenable(cpudata);
|
||
|
+ ret = amd_pstate_epp_reenable(policy);
|
||
|
if (ret)
|
||
|
return ret;
|
||
|
cpudata->suspended = false;
|
||
|
@@ -1722,7 +1722,7 @@ static int amd_pstate_epp_resume(struct
|
||
|
guard(mutex)(&amd_pstate_limits_lock);
|
||
|
|
||
|
/* enable amd pstate from suspend state*/
|
||
|
- amd_pstate_epp_reenable(cpudata);
|
||
|
+ amd_pstate_epp_reenable(policy);
|
||
|
|
||
|
cpudata->suspended = false;
|
||
|
}
|
||
|
--- a/drivers/cpufreq/amd-pstate.h
|
||
|
+++ b/drivers/cpufreq/amd-pstate.h
|
||
|
@@ -98,7 +98,6 @@ struct amd_cpudata {
|
||
|
u64 cppc_cap1_cached;
|
||
|
bool suspended;
|
||
|
s16 epp_default;
|
||
|
- bool boost_state;
|
||
|
};
|
||
|
|
||
|
/*
|