Skip to content

Commit

Permalink
x86/ACPI: CPPC: Move init_freq_invariance_cppc() into x86 CPPC
Browse files Browse the repository at this point in the history
The init_freq_invariance_cppc code actually doesn't need the SMP
functionality. So setting the CONFIG_SMP as the check condition for
init_freq_invariance_cppc may cause the confusion to misunderstand the
CPPC. And the x86 CPPC file is better space to store the CPPC related
functions, while the init_freq_invariance_cppc is out of smpboot, that
means, the CONFIG_SMP won't be mandatory condition any more. And It's more
clear than before.

Signed-off-by: Huang Rui <ray.huang@amd.com>
[ rjw: Subject adjustment ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Huang Rui authored and Rafael J. Wysocki committed Mar 8, 2022
1 parent 666f6ec commit eb5616d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
4 changes: 1 addition & 3 deletions arch/x86/include/asm/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,10 @@ static inline void init_freq_invariance(bool secondary, bool cppc_ready)
}
#endif

#if defined(CONFIG_ACPI_CPPC_LIB) && defined(CONFIG_SMP)
#ifdef CONFIG_ACPI_CPPC_LIB
void init_freq_invariance_cppc(void);
#define init_freq_invariance_cppc init_freq_invariance_cppc
#endif

#ifdef CONFIG_ACPI_CPPC_LIB
bool amd_set_max_freq_ratio(u64 *ratio);
#else
static inline bool amd_set_max_freq_ratio(u64 *ratio)
Expand Down
14 changes: 14 additions & 0 deletions arch/x86/kernel/acpi/cppc.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,17 @@ bool amd_set_max_freq_ratio(u64 *ratio)

return true;
}

static DEFINE_MUTEX(freq_invariance_lock);

void init_freq_invariance_cppc(void)
{
static bool secondary;

mutex_lock(&freq_invariance_lock);

init_freq_invariance(secondary, true);
secondary = true;

mutex_unlock(&freq_invariance_lock);
}
20 changes: 0 additions & 20 deletions arch/x86/kernel/smpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@
#include <asm/hw_irq.h>
#include <asm/stackprotector.h>

#ifdef CONFIG_ACPI_CPPC_LIB
#include <acpi/cppc_acpi.h>
#endif

/* representing HT siblings of each logical CPU */
DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_map);
EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
Expand Down Expand Up @@ -2156,22 +2152,6 @@ void init_freq_invariance(bool secondary, bool cppc_ready)
}
}

#ifdef CONFIG_ACPI_CPPC_LIB
static DEFINE_MUTEX(freq_invariance_lock);

void init_freq_invariance_cppc(void)
{
static bool secondary;

mutex_lock(&freq_invariance_lock);

init_freq_invariance(secondary, true);
secondary = true;

mutex_unlock(&freq_invariance_lock);
}
#endif

static void disable_freq_invariance_workfn(struct work_struct *work)
{
static_branch_disable(&arch_scale_freq_key);
Expand Down

0 comments on commit eb5616d

Please sign in to comment.