Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/64341 )
Change subject: cpu/x86/mp_init.c: Use existing code to create cpu struct device ......................................................................
cpu/x86/mp_init.c: Use existing code to create cpu struct device
Change-Id: I80baadd405b31d6be2fdbb894b0f4b7c775da6f8 Signed-off-by: Arthur Heymans arthur@aheymans.xyz Reviewed-on: https://review.coreboot.org/c/coreboot/+/64341 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Jonathan Zhang jonzhang@fb.com Reviewed-by: Felix Held felix-coreboot@felixheld.de --- M src/cpu/x86/mp_init.c 1 file changed, 21 insertions(+), 15 deletions(-)
Approvals: build bot (Jenkins): Verified Felix Held: Looks good to me, approved Jonathan Zhang: Looks good to me, approved
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c index febc30b..0e4a571 100644 --- a/src/cpu/x86/mp_init.c +++ b/src/cpu/x86/mp_init.c @@ -369,18 +369,9 @@
info = cpu_info(); for (i = 1; i < max_cpus; i++) { - struct device_path cpu_path; - struct device *new; - - /* Build the CPU device path */ - cpu_path.type = DEVICE_PATH_APIC; - /* Assuming linear APIC space allocation. AP will set its own APIC id in the ap_init() path above. */ - cpu_path.apic.apic_id = info->cpu->path.apic.apic_id + i; - - /* Allocate the new CPU device structure */ - new = alloc_find_dev(cpu_bus, &cpu_path); + struct device *new = add_cpu_device(cpu_bus, info->cpu->path.apic.apic_id + i, 1); if (new == NULL) { printk(BIOS_CRIT, "Could not allocate CPU device\n"); max_cpus--; @@ -532,7 +523,6 @@
static enum cb_err init_bsp(struct bus *cpu_bus) { - struct device_path cpu_path; struct cpu_info *info;
/* Print processor name */ @@ -543,13 +533,15 @@ enable_lapic(); setup_lapic_interrupts();
- /* Set the device path of the boot CPU. */ - cpu_path.type = DEVICE_PATH_APIC; - cpu_path.apic.apic_id = lapicid(); + struct device *bsp = add_cpu_device(cpu_bus, lapicid(), 1); + if (bsp == NULL) { + printk(BIOS_CRIT, "Failed to find or allocate BSP struct device\n"); + return CB_ERR; + }
/* Find the device structure for the boot CPU. */ info = cpu_info(); - info->cpu = alloc_find_dev(cpu_bus, &cpu_path); + info->cpu = bsp; info->cpu->name = processor_name;
if (info->index != 0) {