Decouple ACPI CPU Ids from FreeBSD's cpuid. The ACPI Ids can be

sparse, which causes a kernel assert.

Approved by:	re (kensmith)
This commit is contained in:
Marcel Moolenaar 2009-08-16 01:43:08 +00:00
parent a38fdf2946
commit 97e84697ae
3 changed files with 19 additions and 20 deletions

View File

@ -91,7 +91,6 @@ ASSYM(MC_SPECIAL_RNAT, offsetof(mcontext_t, mc_special.rnat));
ASSYM(PAGE_SHIFT, PAGE_SHIFT);
ASSYM(PAGE_SIZE, PAGE_SIZE);
ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid));
ASSYM(PC_CURRENT_PMAP, offsetof(struct pcpu, pc_current_pmap));
ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread));
ASSYM(PC_IDLETHREAD, offsetof(struct pcpu, pc_idlethread));

View File

@ -424,7 +424,11 @@ void
cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size)
{
pcpu->pc_acpi_id = cpuid;
/*
* Set pc_acpi_id to "uninitialized".
* See sys/dev/acpica/acpi_cpu.c
*/
pcpu->pc_acpi_id = 0xffffffff;
}
void

View File

@ -208,31 +208,25 @@ cpu_mp_add(u_int acpiid, u_int apicid, u_int apiceid)
struct pcpu *pc;
u_int64_t lid;
void *dpcpu;
/* Ignore any processor numbers outside our range */
if (acpiid > mp_maxid)
return;
KASSERT((all_cpus & (1UL << acpiid)) == 0,
("%s: cpu%d already in CPU map", __func__, acpiid));
u_int cpuid;
lid = LID_SAPIC_SET(apicid, apiceid);
cpuid = ((ia64_get_lid() & LID_SAPIC_MASK) == lid) ? 0 : smp_cpus++;
if ((ia64_get_lid() & LID_SAPIC_MASK) == lid) {
KASSERT(acpiid == 0,
("%s: the BSP must be cpu0", __func__));
}
KASSERT((all_cpus & (1UL << cpuid)) == 0,
("%s: cpu%d already in CPU map", __func__, acpiid));
if (acpiid != 0) {
if (cpuid != 0) {
pc = (struct pcpu *)malloc(sizeof(*pc), M_SMP, M_WAITOK);
pcpu_init(pc, cpuid, sizeof(*pc));
dpcpu = (void *)kmem_alloc(kernel_map, DPCPU_SIZE);
pcpu_init(pc, acpiid, sizeof(*pc));
dpcpu_init(dpcpu, acpiid);
dpcpu_init(dpcpu, cpuid);
} else
pc = pcpup;
pc->pc_acpi_id = acpiid;
pc->pc_lid = lid;
all_cpus |= (1UL << acpiid);
all_cpus |= (1UL << cpuid);
}
void
@ -244,8 +238,8 @@ cpu_mp_announce()
for (i = 0; i <= mp_maxid; i++) {
pc = pcpu_find(i);
if (pc != NULL) {
printf("cpu%d: SAPIC Id=%x, SAPIC Eid=%x", i,
LID_SAPIC_ID(pc->pc_lid),
printf("cpu%d: ACPI Id=%x, SAPIC Id=%x, SAPIC Eid=%x",
i, pc->pc_acpi_id, LID_SAPIC_ID(pc->pc_lid),
LID_SAPIC_EID(pc->pc_lid));
if (i == 0)
printf(" (BSP)\n");
@ -305,7 +299,9 @@ cpu_mp_unleash(void *dummy)
SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
cpus++;
if (pc->pc_awake) {
kproc_create(ia64_store_mca_state, (void*)((uintptr_t)pc->pc_cpuid), NULL, 0, 0, "mca %u", pc->pc_cpuid);
kproc_create(ia64_store_mca_state,
(void*)((uintptr_t)pc->pc_cpuid), NULL, 0, 0,
"mca %u", pc->pc_cpuid);
smp_cpus++;
}
}