From b4a4a76a71fc72fe3d57f62e7e58ae04777184d5 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Wed, 23 Oct 2024 18:10:28 +0200 Subject: soc/intel/xeon_sp: Reduce code differences Use get_platform_thread_count() instead of duplicated get_thread_count(), that is also less precise. Change-Id: I70c095c284aab6898b8351e82243f534963f333b Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/c/coreboot/+/84845 Reviewed-by: Shuo Liu Tested-by: build bot (Jenkins) --- src/soc/intel/xeon_sp/cpx/cpu.c | 18 +----------------- src/soc/intel/xeon_sp/gnr/cpu.c | 17 +---------------- src/soc/intel/xeon_sp/spr/cpu.c | 17 +---------------- 3 files changed, 3 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/soc/intel/xeon_sp/cpx/cpu.c b/src/soc/intel/xeon_sp/cpx/cpu.c index 14535e2ee7..aaac83b583 100644 --- a/src/soc/intel/xeon_sp/cpx/cpu.c +++ b/src/soc/intel/xeon_sp/cpx/cpu.c @@ -173,22 +173,6 @@ static void pre_mp_init(void) x86_mtrr_check(); } -static int get_thread_count(void) -{ - unsigned int num_phys = 0, num_virts = 0; - - cpu_read_topology(&num_phys, &num_virts); - printk(BIOS_SPEW, "Detected %u cores and %u threads\n", num_phys, num_virts); - /* - * Currently we do not know a way to figure out how many CPUs we have total - * on multi-socketed. So we pretend all sockets are populated with CPUs with - * same thread/core fusing. - * TODO: properly figure out number of active sockets OR refactor MPinit code - * to remove requirements of having to know total number of CPUs in advance. - */ - return num_virts * CONFIG_MAX_SOCKET; -} - static void post_mp_init(void) { /* Set Max Ratio */ @@ -203,7 +187,7 @@ static void post_mp_init(void) static const struct mp_ops mp_ops = { .pre_mp_init = pre_mp_init, - .get_cpu_count = get_thread_count, + .get_cpu_count = get_platform_thread_count, .get_smm_info = get_smm_info, .pre_mp_smm_init = smm_southbridge_clear_state, .relocation_handler = smm_relocation_handler, diff --git a/src/soc/intel/xeon_sp/gnr/cpu.c b/src/soc/intel/xeon_sp/gnr/cpu.c index 580503537c..71edd70e7c 100644 --- a/src/soc/intel/xeon_sp/gnr/cpu.c +++ b/src/soc/intel/xeon_sp/gnr/cpu.c @@ -63,21 +63,6 @@ static void pre_mp_init(void) x86_mtrr_check(); } -static int get_thread_count(void) -{ - unsigned int num_phys = 0, num_virts = 0; - - /* - * This call calculates the thread count which is corresponding to num_virts - * (logical cores), while num_phys is corresponding to physical cores (in SMT - * system, one physical core has multiple threads, a.k.a. logical cores). - * Hence num_phys is not actually used. - */ - cpu_read_topology(&num_phys, &num_virts); - printk(BIOS_SPEW, "Detected %u cores and %u threads\n", num_phys, num_virts); - return num_virts * soc_get_num_cpus(); -} - static void post_mp_init(void) { if (CONFIG(HAVE_SMI_HANDLER)) @@ -86,7 +71,7 @@ static void post_mp_init(void) static const struct mp_ops mp_ops = { .pre_mp_init = pre_mp_init, - .get_cpu_count = get_thread_count, + .get_cpu_count = get_platform_thread_count, #if CONFIG(HAVE_SMI_HANDLER) .get_smm_info = get_smm_info, .pre_mp_smm_init = smm_southbridge_clear_state, diff --git a/src/soc/intel/xeon_sp/spr/cpu.c b/src/soc/intel/xeon_sp/spr/cpu.c index ad099ab70b..7af7f9a536 100644 --- a/src/soc/intel/xeon_sp/spr/cpu.c +++ b/src/soc/intel/xeon_sp/spr/cpu.c @@ -220,21 +220,6 @@ static void pre_mp_init(void) x86_mtrr_check(); } -static int get_thread_count(void) -{ - unsigned int num_phys = 0, num_virts = 0; - - /* - * This call calculates the thread count which is corresponding to num_virts - * (logical cores), while num_phys is corresponding to physical cores (in SMT - * system, one physical core has multiple threads, a.k.a. logical cores). - * Hence num_phys is not actually used. - */ - cpu_read_topology(&num_phys, &num_virts); - printk(BIOS_SPEW, "Detected %u cores and %u threads\n", num_phys, num_virts); - return num_virts * soc_get_num_cpus(); -} - static void post_mp_init(void) { /* Set Max Ratio */ @@ -249,7 +234,7 @@ static void post_mp_init(void) static const struct mp_ops mp_ops = { .pre_mp_init = pre_mp_init, - .get_cpu_count = get_thread_count, + .get_cpu_count = get_platform_thread_count, #if CONFIG(HAVE_SMI_HANDLER) .get_smm_info = get_smm_info, .pre_mp_smm_init = smm_southbridge_clear_state, -- cgit v1.2.3