From 90c26b0d2df20caa46bf8352c9a36cfb464da5cf Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Sat, 10 Apr 1999 22:58:29 +0000 Subject: [PATCH] Let BSP wait until all APs are initialized. --- sys/amd64/amd64/mp_machdep.c | 5 ++++- sys/amd64/amd64/mpboot.S | 20 +++++++++++++++++++- sys/amd64/amd64/mptable.c | 5 ++++- sys/amd64/include/mptable.h | 5 ++++- sys/i386/i386/mp_machdep.c | 5 ++++- sys/i386/i386/mpboot.s | 20 +++++++++++++++++++- sys/i386/i386/mptable.c | 5 ++++- sys/i386/include/mptable.h | 5 ++++- sys/kern/subr_smp.c | 5 ++++- 9 files changed, 66 insertions(+), 9 deletions(-) diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index cde98a7b66e..6bd4ddcc358 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -22,7 +22,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp_machdep.c,v 1.93 1999/03/05 16:38:10 bde Exp $ + * $Id: mp_machdep.c,v 1.94 1999/04/07 17:08:40 peter Exp $ */ #include "opt_smp.h" @@ -1927,6 +1927,9 @@ start_all_aps(u_int boot_addr) for (i = 0; i < mp_ncpus; i++) { bcopy( (int *) PTD + KPTDI, (int *) IdlePTDS[i] + KPTDI, NKPDE * sizeof (int)); } + wait_ap(1000000); + if (smp_started == 0) + printf("WARNING: Failed to start all APs\n"); /* number of APs actually started */ return mp_ncpus - 1; diff --git a/sys/amd64/amd64/mpboot.S b/sys/amd64/amd64/mpboot.S index 0b9af854e36..7a5d431b65d 100644 --- a/sys/amd64/amd64/mpboot.S +++ b/sys/amd64/amd64/mpboot.S @@ -31,7 +31,7 @@ * mpboot.s: FreeBSD machine support for the Intel MP Spec * multiprocessor systems. * - * $Id: mpboot.s,v 1.7 1998/09/06 22:41:40 tegge Exp $ + * $Id: mpboot.s,v 1.8 1998/10/10 10:36:12 kato Exp $ */ #include "opt_vm86.h" @@ -133,6 +133,24 @@ mp_begin: /* now running relocated at KERNBASE */ /* let her rip! (loads new stack) */ jmp _cpu_switch +NON_GPROF_ENTRY(wait_ap) + pushl %ebp + movl %esp, %ebp + call _rel_mplock + movl %eax, 8(%ebp) +1: + cmpl $0, CNAME(smp_started) + jnz 2f + decl %eax + cmpl $0, %eax + jge 1b +2: + call _get_mplock + movl %ebp, %esp + popl %ebp + ret + + /* * This is the embedded trampoline or bootstrap that is * copied into 'real-mode' low memory, it is where the diff --git a/sys/amd64/amd64/mptable.c b/sys/amd64/amd64/mptable.c index cde98a7b66e..6bd4ddcc358 100644 --- a/sys/amd64/amd64/mptable.c +++ b/sys/amd64/amd64/mptable.c @@ -22,7 +22,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp_machdep.c,v 1.93 1999/03/05 16:38:10 bde Exp $ + * $Id: mp_machdep.c,v 1.94 1999/04/07 17:08:40 peter Exp $ */ #include "opt_smp.h" @@ -1927,6 +1927,9 @@ start_all_aps(u_int boot_addr) for (i = 0; i < mp_ncpus; i++) { bcopy( (int *) PTD + KPTDI, (int *) IdlePTDS[i] + KPTDI, NKPDE * sizeof (int)); } + wait_ap(1000000); + if (smp_started == 0) + printf("WARNING: Failed to start all APs\n"); /* number of APs actually started */ return mp_ncpus - 1; diff --git a/sys/amd64/include/mptable.h b/sys/amd64/include/mptable.h index cde98a7b66e..6bd4ddcc358 100644 --- a/sys/amd64/include/mptable.h +++ b/sys/amd64/include/mptable.h @@ -22,7 +22,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp_machdep.c,v 1.93 1999/03/05 16:38:10 bde Exp $ + * $Id: mp_machdep.c,v 1.94 1999/04/07 17:08:40 peter Exp $ */ #include "opt_smp.h" @@ -1927,6 +1927,9 @@ start_all_aps(u_int boot_addr) for (i = 0; i < mp_ncpus; i++) { bcopy( (int *) PTD + KPTDI, (int *) IdlePTDS[i] + KPTDI, NKPDE * sizeof (int)); } + wait_ap(1000000); + if (smp_started == 0) + printf("WARNING: Failed to start all APs\n"); /* number of APs actually started */ return mp_ncpus - 1; diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index cde98a7b66e..6bd4ddcc358 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -22,7 +22,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp_machdep.c,v 1.93 1999/03/05 16:38:10 bde Exp $ + * $Id: mp_machdep.c,v 1.94 1999/04/07 17:08:40 peter Exp $ */ #include "opt_smp.h" @@ -1927,6 +1927,9 @@ start_all_aps(u_int boot_addr) for (i = 0; i < mp_ncpus; i++) { bcopy( (int *) PTD + KPTDI, (int *) IdlePTDS[i] + KPTDI, NKPDE * sizeof (int)); } + wait_ap(1000000); + if (smp_started == 0) + printf("WARNING: Failed to start all APs\n"); /* number of APs actually started */ return mp_ncpus - 1; diff --git a/sys/i386/i386/mpboot.s b/sys/i386/i386/mpboot.s index 0b9af854e36..7a5d431b65d 100644 --- a/sys/i386/i386/mpboot.s +++ b/sys/i386/i386/mpboot.s @@ -31,7 +31,7 @@ * mpboot.s: FreeBSD machine support for the Intel MP Spec * multiprocessor systems. * - * $Id: mpboot.s,v 1.7 1998/09/06 22:41:40 tegge Exp $ + * $Id: mpboot.s,v 1.8 1998/10/10 10:36:12 kato Exp $ */ #include "opt_vm86.h" @@ -133,6 +133,24 @@ mp_begin: /* now running relocated at KERNBASE */ /* let her rip! (loads new stack) */ jmp _cpu_switch +NON_GPROF_ENTRY(wait_ap) + pushl %ebp + movl %esp, %ebp + call _rel_mplock + movl %eax, 8(%ebp) +1: + cmpl $0, CNAME(smp_started) + jnz 2f + decl %eax + cmpl $0, %eax + jge 1b +2: + call _get_mplock + movl %ebp, %esp + popl %ebp + ret + + /* * This is the embedded trampoline or bootstrap that is * copied into 'real-mode' low memory, it is where the diff --git a/sys/i386/i386/mptable.c b/sys/i386/i386/mptable.c index cde98a7b66e..6bd4ddcc358 100644 --- a/sys/i386/i386/mptable.c +++ b/sys/i386/i386/mptable.c @@ -22,7 +22,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp_machdep.c,v 1.93 1999/03/05 16:38:10 bde Exp $ + * $Id: mp_machdep.c,v 1.94 1999/04/07 17:08:40 peter Exp $ */ #include "opt_smp.h" @@ -1927,6 +1927,9 @@ start_all_aps(u_int boot_addr) for (i = 0; i < mp_ncpus; i++) { bcopy( (int *) PTD + KPTDI, (int *) IdlePTDS[i] + KPTDI, NKPDE * sizeof (int)); } + wait_ap(1000000); + if (smp_started == 0) + printf("WARNING: Failed to start all APs\n"); /* number of APs actually started */ return mp_ncpus - 1; diff --git a/sys/i386/include/mptable.h b/sys/i386/include/mptable.h index cde98a7b66e..6bd4ddcc358 100644 --- a/sys/i386/include/mptable.h +++ b/sys/i386/include/mptable.h @@ -22,7 +22,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp_machdep.c,v 1.93 1999/03/05 16:38:10 bde Exp $ + * $Id: mp_machdep.c,v 1.94 1999/04/07 17:08:40 peter Exp $ */ #include "opt_smp.h" @@ -1927,6 +1927,9 @@ start_all_aps(u_int boot_addr) for (i = 0; i < mp_ncpus; i++) { bcopy( (int *) PTD + KPTDI, (int *) IdlePTDS[i] + KPTDI, NKPDE * sizeof (int)); } + wait_ap(1000000); + if (smp_started == 0) + printf("WARNING: Failed to start all APs\n"); /* number of APs actually started */ return mp_ncpus - 1; diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index cde98a7b66e..6bd4ddcc358 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -22,7 +22,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp_machdep.c,v 1.93 1999/03/05 16:38:10 bde Exp $ + * $Id: mp_machdep.c,v 1.94 1999/04/07 17:08:40 peter Exp $ */ #include "opt_smp.h" @@ -1927,6 +1927,9 @@ start_all_aps(u_int boot_addr) for (i = 0; i < mp_ncpus; i++) { bcopy( (int *) PTD + KPTDI, (int *) IdlePTDS[i] + KPTDI, NKPDE * sizeof (int)); } + wait_ap(1000000); + if (smp_started == 0) + printf("WARNING: Failed to start all APs\n"); /* number of APs actually started */ return mp_ncpus - 1;