diff --git a/src/soc/amd/cezanne/acpi.c b/src/soc/amd/cezanne/acpi.c index d390ca4f22..47f05b4bb2 100644 --- a/src/soc/amd/cezanne/acpi.c +++ b/src/soc/amd/cezanne/acpi.c @@ -320,9 +320,7 @@ void generate_cpu_entries(const struct device *device) }, }; - threads_per_core = ((cpuid_ebx(CPUID_EBX_CORE_ID) & CPUID_EBX_THREADS_MASK) - >> CPUID_EBX_THREADS_SHIFT) - + 1; + threads_per_core = get_threads_per_core(); pstate_count = get_pstate_info(pstate_values, pstate_xpss_values); logical_cores = get_cpu_count(); diff --git a/src/soc/amd/common/block/cpu/noncar/cpu.c b/src/soc/amd/common/block/cpu/noncar/cpu.c index 98926bff7e..b635cad750 100644 --- a/src/soc/amd/common/block/cpu/noncar/cpu.c +++ b/src/soc/amd/common/block/cpu/noncar/cpu.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include #include #include #include @@ -11,6 +12,12 @@ int get_cpu_count(void) return 1 + (cpuid_ecx(0x80000008) & 0xff); } +unsigned int get_threads_per_core(void) +{ + return 1 + ((cpuid_ebx(CPUID_EBX_CORE_ID) & CPUID_EBX_THREADS_MASK) + >> CPUID_EBX_THREADS_SHIFT); +} + void set_cstate_io_addr(void) { msr_t cst_addr; diff --git a/src/soc/amd/common/block/include/amdblocks/cpu.h b/src/soc/amd/common/block/include/amdblocks/cpu.h index 6576c3b993..de3fb84d12 100644 --- a/src/soc/amd/common/block/include/amdblocks/cpu.h +++ b/src/soc/amd/common/block/include/amdblocks/cpu.h @@ -5,6 +5,7 @@ void early_cache_setup(void); int get_cpu_count(void); +unsigned int get_threads_per_core(void); void set_cstate_io_addr(void); void write_resume_eip(void); diff --git a/src/soc/amd/picasso/acpi.c b/src/soc/amd/picasso/acpi.c index fd95246eb2..622aa1645e 100644 --- a/src/soc/amd/picasso/acpi.c +++ b/src/soc/amd/picasso/acpi.c @@ -316,9 +316,7 @@ void generate_cpu_entries(const struct device *device) }, }; - threads_per_core = ((cpuid_ebx(CPUID_EBX_CORE_ID) & CPUID_EBX_THREADS_MASK) - >> CPUID_EBX_THREADS_SHIFT) - + 1; + threads_per_core = get_threads_per_core(); pstate_count = get_pstate_info(pstate_values, pstate_xpss_values); logical_cores = get_cpu_count(); diff --git a/src/soc/amd/sabrina/acpi.c b/src/soc/amd/sabrina/acpi.c index ea67bcfe86..8fbe624e6e 100644 --- a/src/soc/amd/sabrina/acpi.c +++ b/src/soc/amd/sabrina/acpi.c @@ -322,9 +322,7 @@ void generate_cpu_entries(const struct device *device) }, }; - threads_per_core = ((cpuid_ebx(CPUID_EBX_CORE_ID) & CPUID_EBX_THREADS_MASK) - >> CPUID_EBX_THREADS_SHIFT) - + 1; + threads_per_core = get_threads_per_core(); pstate_count = get_pstate_info(pstate_values, pstate_xpss_values); logical_cores = get_cpu_count();