Skip to content

Commit 6048245

Browse files
committed
cpufreq/amd-pstate: Drop boost_state variable
JIRA: https://issues.redhat.com/browse/RHEL-75923 commit 95fad7f Author: Mario Limonciello <mario.limonciello@amd.com> Date: Mon Dec 9 12:52:48 2024 -0600 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> Link: https://lore.kernel.org/r/20241209185248.16301-16-mario.limonciello@amd.com Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: David Arcari <darcari@redhat.com>
1 parent 2aa8a85 commit 6048245

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,10 @@ static int shmem_set_epp(struct amd_cpudata *cpudata, u32 epp)
316316
return ret;
317317
}
318318

319-
static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata,
320-
int pref_index)
319+
static int amd_pstate_set_energy_pref_index(struct cpufreq_policy *policy,
320+
int pref_index)
321321
{
322+
struct amd_cpudata *cpudata = policy->driver_data;
322323
int epp;
323324

324325
if (!pref_index)
@@ -336,7 +337,7 @@ static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata,
336337
epp,
337338
FIELD_GET(AMD_CPPC_MIN_PERF_MASK, cpudata->cppc_req_cached),
338339
FIELD_GET(AMD_CPPC_MAX_PERF_MASK, cpudata->cppc_req_cached),
339-
cpudata->boost_state);
340+
policy->boost_enabled);
340341
}
341342

342343
return amd_pstate_set_epp(cpudata, epp);
@@ -746,7 +747,6 @@ static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state)
746747
guard(mutex)(&amd_pstate_driver_lock);
747748

748749
ret = amd_pstate_cpu_boost_update(policy, state);
749-
WRITE_ONCE(cpudata->boost_state, !ret ? state : false);
750750
policy->boost_enabled = !ret ? state : false;
751751
refresh_frequency_limits(policy);
752752

@@ -768,9 +768,6 @@ static int amd_pstate_init_boost_support(struct amd_cpudata *cpudata)
768768
goto exit_err;
769769
}
770770

771-
/* at least one CPU supports CPB, even if others fail later on to set up */
772-
current_pstate_driver->boost_enabled = true;
773-
774771
ret = rdmsrl_on_cpu(cpudata->cpu, MSR_K7_HWCR, &boost_val);
775772
if (ret) {
776773
pr_err_once("failed to read initial CPU boost state!\n");
@@ -1178,7 +1175,6 @@ static ssize_t show_energy_performance_available_preferences(
11781175
static ssize_t store_energy_performance_preference(
11791176
struct cpufreq_policy *policy, const char *buf, size_t count)
11801177
{
1181-
struct amd_cpudata *cpudata = policy->driver_data;
11821178
char str_preference[21];
11831179
ssize_t ret;
11841180

@@ -1192,7 +1188,7 @@ static ssize_t store_energy_performance_preference(
11921188

11931189
guard(mutex)(&amd_pstate_limits_lock);
11941190

1195-
ret = amd_pstate_set_energy_pref_index(cpudata, ret);
1191+
ret = amd_pstate_set_energy_pref_index(policy, ret);
11961192

11971193
return ret ? ret : count;
11981194
}
@@ -1267,6 +1263,9 @@ static int amd_pstate_register_driver(int mode)
12671263
return ret;
12681264
}
12691265

1266+
/* at least one CPU supports CPB */
1267+
current_pstate_driver->boost_enabled = cpu_feature_enabled(X86_FEATURE_CPB);
1268+
12701269
ret = cpufreq_register_driver(current_pstate_driver);
12711270
if (ret) {
12721271
amd_pstate_driver_cleanup();
@@ -1607,8 +1606,9 @@ static int amd_pstate_epp_set_policy(struct cpufreq_policy *policy)
16071606
return 0;
16081607
}
16091608

1610-
static int amd_pstate_epp_reenable(struct amd_cpudata *cpudata)
1609+
static int amd_pstate_epp_reenable(struct cpufreq_policy *policy)
16111610
{
1611+
struct amd_cpudata *cpudata = policy->driver_data;
16121612
u64 max_perf;
16131613
int ret;
16141614

@@ -1622,7 +1622,7 @@ static int amd_pstate_epp_reenable(struct amd_cpudata *cpudata)
16221622
trace_amd_pstate_epp_perf(cpudata->cpu, cpudata->highest_perf,
16231623
cpudata->epp_cached,
16241624
FIELD_GET(AMD_CPPC_MIN_PERF_MASK, cpudata->cppc_req_cached),
1625-
max_perf, cpudata->boost_state);
1625+
max_perf, policy->boost_enabled);
16261626
}
16271627

16281628
return amd_pstate_update_perf(cpudata, 0, 0, max_perf, cpudata->epp_cached, false);
@@ -1635,7 +1635,7 @@ static int amd_pstate_epp_cpu_online(struct cpufreq_policy *policy)
16351635

16361636
pr_debug("AMD CPU Core %d going online\n", cpudata->cpu);
16371637

1638-
ret = amd_pstate_epp_reenable(cpudata);
1638+
ret = amd_pstate_epp_reenable(policy);
16391639
if (ret)
16401640
return ret;
16411641
cpudata->suspended = false;
@@ -1693,7 +1693,7 @@ static int amd_pstate_epp_resume(struct cpufreq_policy *policy)
16931693
guard(mutex)(&amd_pstate_limits_lock);
16941694

16951695
/* enable amd pstate from suspend state*/
1696-
amd_pstate_epp_reenable(cpudata);
1696+
amd_pstate_epp_reenable(policy);
16971697

16981698
cpudata->suspended = false;
16991699
}

drivers/cpufreq/amd-pstate.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ struct amd_cpudata {
9898
u64 cppc_cap1_cached;
9999
bool suspended;
100100
s16 epp_default;
101-
bool boost_state;
102101
};
103102

104103
/*

0 commit comments

Comments
 (0)