summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Heymans <arthur@aheymans.xyz>2022-05-14 02:14:31 +0200
committerLean Sheng Tan <sheng.tan@9elements.com>2023-04-06 15:13:28 +0000
commit21ca7753bf619f1de8dca79fd1113a9c22335f11 (patch)
tree315d6c1a39c585878c96ec018529d42c1280178b
parent95f84c3aae04eaeeb59ce00a1e7cd6fd5ca0c0f8 (diff)
cpu/x86/mp_init.c: Keep track of initial lapic ID inside device_path
It's quite confusing to keep track of lapic ID inside the device struct and initial lapic ID inside an array. Change-Id: I4d9f8d23c0b0e5c142f6907593428d8509e4e7bb Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/c/coreboot/+/64342 Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com> Reviewed-by: Patrick Rudolph <siro@das-labor.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r--src/arch/x86/cpu.c18
-rw-r--r--src/cpu/x86/mp_init.c25
-rw-r--r--src/device/cpu_device.c1
-rw-r--r--src/include/cpu/cpu.h4
-rw-r--r--src/include/device/path.h1
5 files changed, 13 insertions, 36 deletions
diff --git a/src/arch/x86/cpu.c b/src/arch/x86/cpu.c
index b0227c2947..60b236c3c1 100644
--- a/src/arch/x86/cpu.c
+++ b/src/arch/x86/cpu.c
@@ -211,24 +211,6 @@ static void set_cpu_ops(struct device *cpu)
cpu->ops = driver ? driver->ops : NULL;
}
-/* Keep track of default APIC ids for SMM. */
-static int cpus_default_apic_id[CONFIG_MAX_CPUS];
-
-/* Function to keep track of cpu default apic_id */
-void cpu_add_map_entry(unsigned int index)
-{
- cpus_default_apic_id[index] = initial_lapicid();
-}
-
-/* Returns default APIC id based on logical_cpu number or < 0 on failure. */
-int cpu_get_apic_id(int logical_cpu)
-{
- if (logical_cpu >= CONFIG_MAX_CPUS || logical_cpu < 0)
- return -1;
-
- return cpus_default_apic_id[logical_cpu];
-}
-
void cpu_initialize(void)
{
/* Because we busy wait at the printk spinlock.
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c
index 8301e80a22..2909022b34 100644
--- a/src/cpu/x86/mp_init.c
+++ b/src/cpu/x86/mp_init.c
@@ -195,18 +195,16 @@ static asmlinkage void ap_init(unsigned int index)
set_cpu_info(index, dev);
- struct cpu_info *info = cpu_info();
- cpu_add_map_entry(info->index);
-
/* Fix up APIC id with reality. */
- info->cpu->path.apic.apic_id = lapicid();
+ dev->path.apic.apic_id = lapicid();
+ dev->path.apic.initial_lapicid = initial_lapicid();
if (cpu_is_intel())
- printk(BIOS_INFO, "AP: slot %zu apic_id %x, MCU rev: 0x%08x\n", info->index,
- info->cpu->path.apic.apic_id, get_current_microcode_rev());
+ printk(BIOS_INFO, "AP: slot %u apic_id %x, MCU rev: 0x%08x\n", index,
+ dev->path.apic.apic_id, get_current_microcode_rev());
else
- printk(BIOS_INFO, "AP: slot %zu apic_id %x\n", info->index,
- info->cpu->path.apic.apic_id);
+ printk(BIOS_INFO, "AP: slot %u apic_id %x\n", index,
+ dev->path.apic.apic_id);
/* Walk the flight plan */
ap_do_flight_plan();
@@ -547,6 +545,7 @@ static enum cb_err init_bsp(struct bus *cpu_bus)
printk(BIOS_CRIT, "Failed to find or allocate BSP struct device\n");
return CB_ERR;
}
+ bsp->path.apic.initial_lapicid = initial_lapicid();
/* Find the device structure for the boot CPU. */
set_cpu_info(0, bsp);
@@ -558,9 +557,6 @@ static enum cb_err init_bsp(struct bus *cpu_bus)
printk(BIOS_CRIT, "BSP index(%zd) != 0!\n", info->index);
return CB_ERR;
}
-
- /* Track BSP in cpu_map structures. */
- cpu_add_map_entry(info->index);
return CB_SUCCESS;
}
@@ -748,11 +744,12 @@ static asmlinkage void smm_do_relocation(void *arg)
static void adjust_smm_apic_id_map(struct smm_loader_params *smm_params)
{
- int i;
struct smm_stub_params *stub_params = smm_params->stub_params;
- for (i = 0; i < CONFIG_MAX_CPUS; i++)
- stub_params->apic_id_to_cpu[i] = cpu_get_apic_id(i);
+ int i = 0;
+ for (struct device *dev = g_cpu_bus->children; dev; dev = dev->sibling)
+ if (dev->enabled)
+ stub_params->apic_id_to_cpu[i++] = dev->path.apic.initial_lapicid;
}
static enum cb_err install_relocation_handler(int num_cpus, size_t save_state_size)
diff --git a/src/device/cpu_device.c b/src/device/cpu_device.c
index f406e23f89..9185cc67f2 100644
--- a/src/device/cpu_device.c
+++ b/src/device/cpu_device.c
@@ -13,6 +13,7 @@ struct device *add_cpu_device(struct bus *cpu_bus, unsigned int apic_id,
/* Build the CPU device path */
cpu_path.type = DEVICE_PATH_APIC;
cpu_path.apic.apic_id = apic_id;
+ cpu_path.apic.initial_lapicid = apic_id;
/* Update CPU in devicetree. */
if (enabled)
diff --git a/src/include/cpu/cpu.h b/src/include/cpu/cpu.h
index a77cb33b4a..fc662eec9e 100644
--- a/src/include/cpu/cpu.h
+++ b/src/include/cpu/cpu.h
@@ -7,11 +7,7 @@
#include <stdint.h>
void cpu_initialize(void);
-/* Returns default APIC id based on logical_cpu number or < 0 on failure. */
-int cpu_get_apic_id(int logical_cpu);
uintptr_t cpu_get_lapic_addr(void);
-/* Function to keep track of cpu default apic_id */
-void cpu_add_map_entry(unsigned int index);
struct bus;
int cpu_phys_address_size(void);
diff --git a/src/include/device/path.h b/src/include/device/path.h
index a1ea42c154..c0df66b821 100644
--- a/src/include/device/path.h
+++ b/src/include/device/path.h
@@ -73,6 +73,7 @@ struct spi_path {
};
struct apic_path {
+ unsigned int initial_lapicid;
unsigned int apic_id;
unsigned int package_id;
unsigned int node_id;