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 <aamir.bohra@intel.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/50880
Reviewed-by: EricR Lai <ericr_lai@compal.corp-partner.google.com>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Aamir Bohra 2021-02-19 16:35:09 +05:30 committed by Furquan Shaikh
parent d192590e29
commit 01ae4a7706
1 changed files with 13 additions and 8 deletions

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <console/console.h>
#include <cpu/cpu.h>
#include <cpu/x86/mp.h>
#include <cpu/x86/lapic.h>
#include <cpu/intel/microcode.h>
@ -10,7 +11,6 @@
#include <intelblocks/mp_init.h>
#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;
}