diff options
author | jhb <jhb@FreeBSD.org> | 2010-11-08 20:35:09 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2010-11-08 20:35:09 +0000 |
commit | bfc0fcbf5e493e04a8ec66e9d8c0b98cbe5db075 (patch) | |
tree | 6c6aa98a717af619eb82b7f2f15c5e0a2c1b1346 /sys | |
parent | dc5dbf87bcf2448420a9cacb5bc705c887318325 (diff) | |
download | FreeBSD-src-bfc0fcbf5e493e04a8ec66e9d8c0b98cbe5db075.zip FreeBSD-src-bfc0fcbf5e493e04a8ec66e9d8c0b98cbe5db075.tar.gz |
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.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/i386/acpica/madt.c | 2 | ||||
-rw-r--r-- | sys/i386/i386/mp_machdep.c | 19 | ||||
-rw-r--r-- | sys/i386/xen/mptable.c | 2 | ||||
-rw-r--r-- | sys/x86/x86/local_apic.c | 16 | ||||
-rw-r--r-- | sys/x86/x86/mptable.c | 2 |
5 files changed, 25 insertions, 16 deletions
diff --git a/sys/i386/acpica/madt.c b/sys/i386/acpica/madt.c index bcf60b1..13bbb55 100644 --- a/sys/i386/acpica/madt.c +++ b/sys/i386/acpica/madt.c @@ -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. diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index c4d2672..871ccb4 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -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); } diff --git a/sys/i386/xen/mptable.c b/sys/i386/xen/mptable.c index fe01cd5..d9942ab 100644 --- a/sys/i386/xen/mptable.c +++ b/sys/i386/xen/mptable.c @@ -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); diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c index 88f1fbe..7f8e583 100644 --- a/sys/x86/x86/local_apic.c +++ b/sys/x86/x86/local_apic.c @@ -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. diff --git a/sys/x86/x86/mptable.c b/sys/x86/x86/mptable.c index cad83a2..b99e2b2 100644 --- a/sys/x86/x86/mptable.c +++ b/sys/x86/x86/mptable.c @@ -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); /* |