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>
This commit is contained in:
parent
95f84c3aae
commit
21ca7753bf
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user