Attention is currently required from: Andrey Petrov.
Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/69223 )
Change subject: mp_service_ppi: Use struct device to fill in buffer ......................................................................
mp_service_ppi: Use struct device to fill in buffer
Now the CPU topology is filled in struct device during mp_init.
Change-Id: I7322b43f5b95dda5fbe81e7427f5269c9d6f8755 Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/drivers/intel/fsp2_0/ppi/mp_service_ppi.c M src/soc/intel/common/block/cpu/cpulib.c M src/soc/intel/common/block/include/intelblocks/cpulib.h 3 files changed, 20 insertions(+), 65 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/23/69223/1
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 66bbc2f..07d5f39 100644 --- a/src/drivers/intel/fsp2_0/ppi/mp_service_ppi.c +++ b/src/drivers/intel/fsp2_0/ppi/mp_service_ppi.c @@ -28,24 +28,20 @@ efi_return_status_t mp_get_processor_info(efi_uintn_t processor_number, efi_processor_information *processor_info_buffer) { - int apicid; uint8_t package, core, thread;
- if (cpu_index() < 0) - return FSP_DEVICE_ERROR; - if (processor_info_buffer == NULL) return FSP_INVALID_PARAMETER;
if (processor_number >= get_cpu_count()) return FSP_NOT_FOUND;
- apicid = cpu_get_apic_id(processor_number); + /* We can't use cpu_info() as we operate from FSP context here */ + struct device dev = *dev_find_lapic(lapicid()); + if (dev == NULL) + return FSP_NOT_FOUND;
- if (apicid < 0) - return FSP_DEVICE_ERROR; - - processor_info_buffer->ProcessorId = apicid; + processor_info_buffer->ProcessorId = dev->path.apic.initial_lapicid;
processor_info_buffer->StatusFlag = PROCESSOR_HEALTH_STATUS_BIT | PROCESSOR_ENABLED_BIT; @@ -53,12 +49,9 @@ if (processor_number == BSP_CPU_SLOT) processor_info_buffer->StatusFlag |= PROCESSOR_AS_BSP_BIT;
- /* Fill EFI_CPU_PHYSICAL_LOCATION structure information */ - get_cpu_topology_from_apicid(apicid, &package, &core, &thread); - - processor_info_buffer->Location.Package = package; - processor_info_buffer->Location.Core = core; - processor_info_buffer->Location.Thread = thread; + processor_info_buffer->Location.Package = dev->path.apic.package_id; + processor_info_buffer->Location.Core = dev->path.apic.core_id; + processor_info_buffer->Location.Thread = dev->path.apic.thread_id;
return FSP_SUCCESS; } diff --git a/src/soc/intel/common/block/cpu/cpulib.c b/src/soc/intel/common/block/cpu/cpulib.c index 4898066..99a1399 100644 --- a/src/soc/intel/common/block/cpu/cpulib.c +++ b/src/soc/intel/common/block/cpu/cpulib.c @@ -435,52 +435,6 @@ return valid_size; }
-/* Get number of bits for core ID and SMT ID */ -static void get_cpu_core_thread_bits(uint32_t *core_bits, uint32_t *thread_bits) -{ - struct cpuid_result cpuid_regs; - int level_num, cpu_id_op = 0; - const uint32_t cpuid_max_func = cpuid_get_max_func(); - - /* Assert if extended CPU topology not supported */ - assert(cpuid_max_func >= CPUID_EXTENDED_CPU_TOPOLOGY); - - cpu_id_op = CPUID_EXTENDED_CPU_TOPOLOGY; - - *core_bits = level_num = 0; - cpuid_regs = cpuid_ext(cpu_id_op, level_num); - - /* Sub-leaf index 0 enumerates SMT level, if not assert */ - assert(CPUID_CPU_TOPOLOGY_LEVEL(cpuid_regs) == LEVEL_TYPE_SMT); - - *thread_bits = CPUID_CPU_TOPOLOGY_THREAD_BITS(cpuid_regs); - do { - level_num++; - cpuid_regs = cpuid_ext(cpu_id_op, level_num); - if (CPUID_CPU_TOPOLOGY_LEVEL(cpuid_regs) == LEVEL_TYPE_CORE) { - *core_bits = CPUID_CPU_TOPOLOGY_CORE_BITS(cpuid_regs, *thread_bits); - break; - } - /* Stop when level type is invalid i.e 0 */ - } while (CPUID_CPU_TOPOLOGY_LEVEL(cpuid_regs)); -} - -void get_cpu_topology_from_apicid(uint32_t apicid, uint8_t *package, - uint8_t *core, uint8_t *thread) -{ - - uint32_t core_bits, thread_bits; - - get_cpu_core_thread_bits(&core_bits, &thread_bits); - - if (package) - *package = apicid >> (thread_bits + core_bits); - if (core) - *core = (apicid >> thread_bits) & ((1 << core_bits) - 1); - if (thread) - *thread = apicid & ((1 << thread_bits) - 1); -} - static void sync_core_prmrr(void) { static msr_t msr_base, msr_mask; diff --git a/src/soc/intel/common/block/include/intelblocks/cpulib.h b/src/soc/intel/common/block/include/intelblocks/cpulib.h index 7878bf4..6d9b18d 100644 --- a/src/soc/intel/common/block/include/intelblocks/cpulib.h +++ b/src/soc/intel/common/block/include/intelblocks/cpulib.h @@ -183,10 +183,6 @@ */ void enable_pm_timer_emulation(void);
-/* Derive core, package and thread information from lapic ID */ -void get_cpu_topology_from_apicid(uint32_t apicid, uint8_t *package, - uint8_t *core, uint8_t *thread); - /* * Initialize core PRMRR *