x86/aperfmperf: Untangle Intel and AMD frequency invariance init
AMD boot CPU initialization happens late via ACPI/CPPC which prevents the Intel parts from being marked __init. Split out the common code and provide a dedicated interface for the AMD initialization and mark the Intel specific code and data __init. The remaining text size is almost cut in half: text: 2614 -> 1350 init.text: 0 -> 786 Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Paul E. McKenney <paulmck@kernel.org> Link: https://lore.kernel.org/r/20220415161206.592465719@linutronix.de
This commit is contained in:
@ -50,20 +50,17 @@ int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val)
|
||||
return err;
|
||||
}
|
||||
|
||||
bool amd_set_max_freq_ratio(u64 *ratio)
|
||||
static void amd_set_max_freq_ratio(void)
|
||||
{
|
||||
struct cppc_perf_caps perf_caps;
|
||||
u64 highest_perf, nominal_perf;
|
||||
u64 perf_ratio;
|
||||
int rc;
|
||||
|
||||
if (!ratio)
|
||||
return false;
|
||||
|
||||
rc = cppc_get_perf_caps(0, &perf_caps);
|
||||
if (rc) {
|
||||
pr_debug("Could not retrieve perf counters (%d)\n", rc);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
highest_perf = amd_get_highest_perf();
|
||||
@ -71,7 +68,7 @@ bool amd_set_max_freq_ratio(u64 *ratio)
|
||||
|
||||
if (!highest_perf || !nominal_perf) {
|
||||
pr_debug("Could not retrieve highest or nominal performance\n");
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
perf_ratio = div_u64(highest_perf * SCHED_CAPACITY_SCALE, nominal_perf);
|
||||
@ -79,26 +76,27 @@ bool amd_set_max_freq_ratio(u64 *ratio)
|
||||
perf_ratio = (perf_ratio + SCHED_CAPACITY_SCALE) >> 1;
|
||||
if (!perf_ratio) {
|
||||
pr_debug("Non-zero highest/nominal perf values led to a 0 ratio\n");
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
*ratio = perf_ratio;
|
||||
arch_set_max_freq_ratio(false);
|
||||
|
||||
return true;
|
||||
freq_invariance_set_perf_ratio(perf_ratio, false);
|
||||
}
|
||||
|
||||
static DEFINE_MUTEX(freq_invariance_lock);
|
||||
|
||||
void init_freq_invariance_cppc(void)
|
||||
{
|
||||
static bool secondary;
|
||||
static bool init_done;
|
||||
|
||||
if (!cpu_feature_enabled(X86_FEATURE_APERFMPERF))
|
||||
return;
|
||||
|
||||
if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
|
||||
return;
|
||||
|
||||
mutex_lock(&freq_invariance_lock);
|
||||
|
||||
if (!secondary)
|
||||
bp_init_freq_invariance(true);
|
||||
secondary = true;
|
||||
|
||||
if (!init_done)
|
||||
amd_set_max_freq_ratio();
|
||||
init_done = true;
|
||||
mutex_unlock(&freq_invariance_lock);
|
||||
}
|
||||
|
Reference in New Issue
Block a user