Sync the APIC startup sequence with amd64:
- Register APIC enumerators at SI_SUB_TUNABLES - 1 instead of SI_SUB_CPU - 1. - Probe CPUs at SI_SUB_TUNABLES - 1. This allows i386 to set a truly accurate mp_maxid value rather than always setting it to MAXCPU - 1.
This commit is contained in:
parent
6c3c2b8b87
commit
c5b0b5fc6b
@ -203,7 +203,7 @@ madt_register(void *dummy __unused)
|
||||
|
||||
apic_register_enumerator(&madt_enumerator);
|
||||
}
|
||||
SYSINIT(madt_register, SI_SUB_CPU - 1, SI_ORDER_SECOND, madt_register, NULL);
|
||||
SYSINIT(madt_register, SI_SUB_TUNABLES - 1, SI_ORDER_FIRST, madt_register, NULL);
|
||||
|
||||
/*
|
||||
* Call the handler routine for each entry in the MADT table.
|
||||
|
@ -465,8 +465,10 @@ cpu_add(u_int apic_id, char boot_cpu)
|
||||
boot_cpu_id = apic_id;
|
||||
cpu_info[apic_id].cpu_bsp = 1;
|
||||
}
|
||||
if (mp_ncpus < MAXCPU)
|
||||
if (mp_ncpus < MAXCPU) {
|
||||
mp_ncpus++;
|
||||
mp_maxid = mp_ncpus - 1;
|
||||
}
|
||||
if (bootverbose)
|
||||
printf("SMP: Added CPU %d (%s)\n", apic_id, boot_cpu ? "BSP" :
|
||||
"AP");
|
||||
@ -476,7 +478,19 @@ void
|
||||
cpu_mp_setmaxid(void)
|
||||
{
|
||||
|
||||
mp_maxid = MAXCPU - 1;
|
||||
/*
|
||||
* mp_maxid should be already set by calls to cpu_add().
|
||||
* Just sanity check its value here.
|
||||
*/
|
||||
if (mp_ncpus == 0)
|
||||
KASSERT(mp_maxid == 0,
|
||||
("%s: mp_ncpus is zero, but mp_maxid is not", __func__));
|
||||
else if (mp_ncpus == 1)
|
||||
mp_maxid = 0;
|
||||
else
|
||||
KASSERT(mp_maxid >= mp_ncpus - 1,
|
||||
("%s: counters out of sync: max %d, count %d", __func__,
|
||||
mp_maxid, mp_ncpus));
|
||||
}
|
||||
|
||||
int
|
||||
@ -504,6 +518,7 @@ cpu_mp_probe(void)
|
||||
* One CPU was found, so this must be a UP system with
|
||||
* an I/O APIC.
|
||||
*/
|
||||
mp_maxid = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ mptable_register(void *dummy __unused)
|
||||
|
||||
apic_register_enumerator(&mptable_enumerator);
|
||||
}
|
||||
SYSINIT(mptable_register, SI_SUB_CPU - 1, SI_ORDER_FIRST, mptable_register,
|
||||
SYSINIT(mptable_register, SI_SUB_TUNABLES - 1, SI_ORDER_FIRST, mptable_register,
|
||||
NULL);
|
||||
|
||||
|
||||
|
@ -1285,7 +1285,7 @@ apic_init(void *dummy __unused)
|
||||
if (resource_disabled("apic", 0))
|
||||
return;
|
||||
|
||||
/* First, probe all the enumerators to find the best match. */
|
||||
/* Probe all the enumerators to find the best match. */
|
||||
best_enum = NULL;
|
||||
best = 0;
|
||||
SLIST_FOREACH(enumerator, &enumerators, apic_next) {
|
||||
@ -1321,13 +1321,12 @@ apic_init(void *dummy __unused)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Second, probe the CPU's in the system. */
|
||||
/* Probe the CPU's in the system. */
|
||||
retval = best_enum->apic_probe_cpus();
|
||||
if (retval != 0)
|
||||
printf("%s: Failed to probe CPUs: returned %d\n",
|
||||
best_enum->apic_name, retval);
|
||||
|
||||
#ifdef __amd64__
|
||||
}
|
||||
SYSINIT(apic_init, SI_SUB_TUNABLES - 1, SI_ORDER_SECOND, apic_init, NULL);
|
||||
|
||||
@ -1342,19 +1341,14 @@ apic_setup_local(void *dummy __unused)
|
||||
|
||||
if (best_enum == NULL)
|
||||
return;
|
||||
#endif
|
||||
/* Third, initialize the local APIC. */
|
||||
|
||||
/* Initialize the local APIC. */
|
||||
retval = best_enum->apic_setup_local();
|
||||
if (retval != 0)
|
||||
printf("%s: Failed to setup the local APIC: returned %d\n",
|
||||
best_enum->apic_name, retval);
|
||||
}
|
||||
#ifdef __amd64__
|
||||
SYSINIT(apic_setup_local, SI_SUB_CPU, SI_ORDER_SECOND, apic_setup_local,
|
||||
NULL);
|
||||
#else
|
||||
SYSINIT(apic_init, SI_SUB_CPU, SI_ORDER_SECOND, apic_init, NULL);
|
||||
#endif
|
||||
SYSINIT(apic_setup_local, SI_SUB_CPU, SI_ORDER_SECOND, apic_setup_local, NULL);
|
||||
|
||||
/*
|
||||
* Setup the I/O APICs.
|
||||
|
@ -389,7 +389,7 @@ mptable_register(void *dummy __unused)
|
||||
|
||||
apic_register_enumerator(&mptable_enumerator);
|
||||
}
|
||||
SYSINIT(mptable_register, SI_SUB_CPU - 1, SI_ORDER_FIRST, mptable_register,
|
||||
SYSINIT(mptable_register, SI_SUB_TUNABLES - 1, SI_ORDER_FIRST, mptable_register,
|
||||
NULL);
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user