From 01ae4a7706f95bfe77fd629516d3b9436ae9629d Mon Sep 17 00:00:00 2001 From: Aamir Bohra Date: Fri, 19 Feb 2021 16:35:09 +0530 Subject: intel/fsp2_0: Fix the mp_get_processor_info FSP expects mp_get_processor_info to give processor specfic apic ID, core(zero-indexed), package(zero-indexed) and thread(zero-indexed) info. This function is run from BSP for all logical processor, With current implementation the location information returned is incorrect per logical processor. Also the processor id returned does not correspond to the processor index, rather is returned only for the BSP. BUG=b:179113790 Change-Id: Ief8677e4830a765af61a0df9621ecaa372730fca Signed-off-by: Aamir Bohra Reviewed-on: https://review.coreboot.org/c/coreboot/+/50880 Reviewed-by: EricR Lai Reviewed-by: Furquan Shaikh Reviewed-by: Tim Wawrzynczak Tested-by: build bot (Jenkins) --- src/drivers/intel/fsp2_0/ppi/mp_service_ppi.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/drivers/intel/fsp2_0/ppi/mp_service_ppi.c b/src/drivers/intel/fsp2_0/ppi/mp_service_ppi.c index 87056a5b7c..29a02b108c 100644 --- a/src/drivers/intel/fsp2_0/ppi/mp_service_ppi.c +++ b/src/drivers/intel/fsp2_0/ppi/mp_service_ppi.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include #include #include #include @@ -10,7 +11,6 @@ #include #define BSP_CPU_SLOT 0 -#define SINGLE_CHIP_PACKAGE 0 efi_return_status_t mp_get_number_of_processors(efi_uintn_t *number_of_processors, efi_uintn_t *number_of_enabled_processors) @@ -28,7 +28,8 @@ efi_return_status_t mp_get_number_of_processors(efi_uintn_t *number_of_processor efi_return_status_t mp_get_processor_info(efi_uintn_t processor_number, efi_processor_information *processor_info_buffer) { - unsigned int num_virt_cores, num_phys_cores; + int apicid; + uint8_t package, core, thread; if (cpu_index() < 0) return FSP_DEVICE_ERROR; @@ -39,7 +40,12 @@ efi_return_status_t mp_get_processor_info(efi_uintn_t processor_number, if (processor_number >= get_cpu_count()) return FSP_NOT_FOUND; - processor_info_buffer->ProcessorId = lapicid(); + apicid = cpu_get_apic_id(processor_number); + + if (apicid < 0) + return FSP_DEVICE_ERROR; + + processor_info_buffer->ProcessorId = apicid; processor_info_buffer->StatusFlag = PROCESSOR_HEALTH_STATUS_BIT | PROCESSOR_ENABLED_BIT; @@ -48,12 +54,11 @@ efi_return_status_t mp_get_processor_info(efi_uintn_t processor_number, processor_info_buffer->StatusFlag |= PROCESSOR_AS_BSP_BIT; /* Fill EFI_CPU_PHYSICAL_LOCATION structure information */ - cpu_read_topology(&num_phys_cores, &num_virt_cores); + get_cpu_topology_from_apicid(apicid, &package, &core, &thread); - /* FSP will add one to the value in this Package field */ - processor_info_buffer->Location.Package = SINGLE_CHIP_PACKAGE; - processor_info_buffer->Location.Core = num_phys_cores; - processor_info_buffer->Location.Thread = num_virt_cores; + processor_info_buffer->Location.Package = package; + processor_info_buffer->Location.Core = core; + processor_info_buffer->Location.Thread = thread; return FSP_SUCCESS; } -- cgit v1.2.3