soc/amd/cezanne,picasso,sabrina: factor out get_threads_per_core

This code is common to at least all Zen-based APUs (Picasso, Cezanne,
Sabrina) and is also useful outside of the SoC-specific dynamic ACPI
table generation code.

Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: Ie96d4429fb6ed9223efed9b3c754e04052d7ca7c
Reviewed-on: https://review.coreboot.org/c/coreboot/+/61357
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Rob Barnes <robbarnes@google.com>
Reviewed-by: Chris Wang <chris.wang@amd.corp-partner.google.com>
Reviewed-by: Eric Peers <epeers@google.com>
This commit is contained in:
Felix Held 2022-01-25 04:14:05 +01:00
parent 978930e860
commit d4b5ad0ce3
5 changed files with 11 additions and 9 deletions

View File

@ -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) threads_per_core = get_threads_per_core();
>> CPUID_EBX_THREADS_SHIFT)
+ 1;
pstate_count = get_pstate_info(pstate_values, pstate_xpss_values); pstate_count = get_pstate_info(pstate_values, pstate_xpss_values);
logical_cores = get_cpu_count(); logical_cores = get_cpu_count();

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */ /* SPDX-License-Identifier: GPL-2.0-only */
#include <amdblocks/cpu.h> #include <amdblocks/cpu.h>
#include <cpu/amd/cpuid.h>
#include <cpu/cpu.h> #include <cpu/cpu.h>
#include <cpu/x86/msr.h> #include <cpu/x86/msr.h>
#include <cpu/amd/msr.h> #include <cpu/amd/msr.h>
@ -11,6 +12,12 @@ int get_cpu_count(void)
return 1 + (cpuid_ecx(0x80000008) & 0xff); 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) void set_cstate_io_addr(void)
{ {
msr_t cst_addr; msr_t cst_addr;

View File

@ -5,6 +5,7 @@
void early_cache_setup(void); void early_cache_setup(void);
int get_cpu_count(void); int get_cpu_count(void);
unsigned int get_threads_per_core(void);
void set_cstate_io_addr(void); void set_cstate_io_addr(void);
void write_resume_eip(void); void write_resume_eip(void);

View File

@ -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) threads_per_core = get_threads_per_core();
>> CPUID_EBX_THREADS_SHIFT)
+ 1;
pstate_count = get_pstate_info(pstate_values, pstate_xpss_values); pstate_count = get_pstate_info(pstate_values, pstate_xpss_values);
logical_cores = get_cpu_count(); logical_cores = get_cpu_count();

View File

@ -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) threads_per_core = get_threads_per_core();
>> CPUID_EBX_THREADS_SHIFT)
+ 1;
pstate_count = get_pstate_info(pstate_values, pstate_xpss_values); pstate_count = get_pstate_info(pstate_values, pstate_xpss_values);
logical_cores = get_cpu_count(); logical_cores = get_cpu_count();