Skip to content

Commit dead17b

Browse files
committed
Merge tag 'amd-pstate-v6.15-2025-04-15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/superm1/linux
Merge amd-pstate content for 6.15 (4/15/25) from Mario Limonciello: "Add a fix for X3D processors where depending upon what BIOS was set initially rankings might be set improperly. Add a fix for changing min/max limits while on the performance governor." * tag 'amd-pstate-v6.15-2025-04-15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/superm1/linux: cpufreq/amd-pstate: Enable ITMT support after initializing core rankings cpufreq/amd-pstate: Fix min_limit perf and freq updation for performance governor
2 parents 7491cdf + d87e402 commit dead17b

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -607,13 +607,16 @@ static void amd_pstate_update_min_max_limit(struct cpufreq_policy *policy)
607607
union perf_cached perf = READ_ONCE(cpudata->perf);
608608

609609
perf.max_limit_perf = freq_to_perf(perf, cpudata->nominal_freq, policy->max);
610-
perf.min_limit_perf = freq_to_perf(perf, cpudata->nominal_freq, policy->min);
610+
WRITE_ONCE(cpudata->max_limit_freq, policy->max);
611611

612-
if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE)
612+
if (cpudata->policy == CPUFREQ_POLICY_PERFORMANCE) {
613613
perf.min_limit_perf = min(perf.nominal_perf, perf.max_limit_perf);
614+
WRITE_ONCE(cpudata->min_limit_freq, min(cpudata->nominal_freq, cpudata->max_limit_freq));
615+
} else {
616+
perf.min_limit_perf = freq_to_perf(perf, cpudata->nominal_freq, policy->min);
617+
WRITE_ONCE(cpudata->min_limit_freq, policy->min);
618+
}
614619

615-
WRITE_ONCE(cpudata->max_limit_freq, policy->max);
616-
WRITE_ONCE(cpudata->min_limit_freq, policy->min);
617620
WRITE_ONCE(cpudata->perf, perf);
618621
}
619622

@@ -791,16 +794,6 @@ static void amd_perf_ctl_reset(unsigned int cpu)
791794
wrmsrl_on_cpu(cpu, MSR_AMD_PERF_CTL, 0);
792795
}
793796

794-
/*
795-
* Set amd-pstate preferred core enable can't be done directly from cpufreq callbacks
796-
* due to locking, so queue the work for later.
797-
*/
798-
static void amd_pstste_sched_prefcore_workfn(struct work_struct *work)
799-
{
800-
sched_set_itmt_support();
801-
}
802-
static DECLARE_WORK(sched_prefcore_work, amd_pstste_sched_prefcore_workfn);
803-
804797
#define CPPC_MAX_PERF U8_MAX
805798

806799
static void amd_pstate_init_prefcore(struct amd_cpudata *cpudata)
@@ -811,14 +804,8 @@ static void amd_pstate_init_prefcore(struct amd_cpudata *cpudata)
811804

812805
cpudata->hw_prefcore = true;
813806

814-
/*
815-
* The priorities can be set regardless of whether or not
816-
* sched_set_itmt_support(true) has been called and it is valid to
817-
* update them at any time after it has been called.
818-
*/
807+
/* Priorities must be initialized before ITMT support can be toggled on. */
819808
sched_set_itmt_core_prio((int)READ_ONCE(cpudata->prefcore_ranking), cpudata->cpu);
820-
821-
schedule_work(&sched_prefcore_work);
822809
}
823810

824811
static void amd_pstate_update_limits(unsigned int cpu)
@@ -1193,6 +1180,9 @@ static ssize_t show_energy_performance_preference(
11931180

11941181
static void amd_pstate_driver_cleanup(void)
11951182
{
1183+
if (amd_pstate_prefcore)
1184+
sched_clear_itmt_support();
1185+
11961186
cppc_state = AMD_PSTATE_DISABLE;
11971187
current_pstate_driver = NULL;
11981188
}
@@ -1235,6 +1225,10 @@ static int amd_pstate_register_driver(int mode)
12351225
return ret;
12361226
}
12371227

1228+
/* Enable ITMT support once all CPUs have initialized their asym priorities. */
1229+
if (amd_pstate_prefcore)
1230+
sched_set_itmt_support();
1231+
12381232
return 0;
12391233
}
12401234

0 commit comments

Comments
 (0)