Date: Tue, 30 Sep 2003 01:01:46 -0700 (PDT) From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 38856 for review Message-ID: <200309300801.h8U81kHw060244@repoman.freebsd.org>
index | next in thread | raw e-mail
http://perforce.freebsd.org/chv.cgi?CH=38856 Change 38856 by peter@peter_hammer on 2003/09/30 01:01:35 Add SMP reset hooks and includes Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/machdep.c#54 edit .. //depot/projects/hammer/sys/amd64/amd64/vm_machdep.c#14 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/machdep.c#54 (text+ko) ==== @@ -108,6 +108,9 @@ #include <machine/perfmon.h> #endif #include <machine/tss.h> +#ifdef SMP +#include <machine/smp.h> +#endif #include <isa/rtc.h> #include <sys/ptrace.h> ==== //depot/projects/hammer/sys/amd64/amd64/vm_machdep.c#14 (text+ko) ==== @@ -59,6 +59,7 @@ #include <sys/ktr.h> #include <sys/mbuf.h> #include <sys/mutex.h> +#include <sys/smp.h> #include <sys/socketvar.h> #include <sys/sysctl.h> #include <sys/unistd.h> @@ -80,6 +81,11 @@ #include <amd64/isa/isa.h> static void cpu_reset_real(void); +#ifdef SMP +static void cpu_reset_proxy(void); +static u_int cpu_reset_proxyid; +static volatile u_int cpu_reset_proxy_active; +#endif static void sf_buf_init(void *arg); SYSINIT(sock_sf, SI_SUB_MBUF, SI_ORDER_ANY, sf_buf_init, NULL) @@ -334,10 +340,69 @@ * Force reset the processor by invalidating the entire address space! */ +#ifdef SMP +static void +cpu_reset_proxy() +{ + + cpu_reset_proxy_active = 1; + while (cpu_reset_proxy_active == 1) + ; /* Wait for other cpu to see that we've started */ + stop_cpus((1<<cpu_reset_proxyid)); + printf("cpu_reset_proxy: Stopped CPU %d\n", cpu_reset_proxyid); + DELAY(1000000); + cpu_reset_real(); +} +#endif + void cpu_reset() { +#ifdef SMP + if (smp_active == 0) { + cpu_reset_real(); + /* NOTREACHED */ + } else { + + u_int map; + int cnt; + printf("cpu_reset called on cpu#%d\n", PCPU_GET(cpuid)); + + map = PCPU_GET(other_cpus) & ~ stopped_cpus; + + if (map != 0) { + printf("cpu_reset: Stopping other CPUs\n"); + stop_cpus(map); /* Stop all other CPUs */ + } + + if (PCPU_GET(cpuid) == 0) { + DELAY(1000000); + cpu_reset_real(); + /* NOTREACHED */ + } else { + /* We are not BSP (CPU #0) */ + + cpu_reset_proxyid = PCPU_GET(cpuid); + cpustop_restartfunc = cpu_reset_proxy; + cpu_reset_proxy_active = 0; + printf("cpu_reset: Restarting BSP\n"); + started_cpus = (1<<0); /* Restart CPU #0 */ + + cnt = 0; + while (cpu_reset_proxy_active == 0 && cnt < 10000000) + cnt++; /* Wait for BSP to announce restart */ + if (cpu_reset_proxy_active == 0) + printf("cpu_reset: Failed to restart BSP\n"); + enable_intr(); + cpu_reset_proxy_active = 2; + + while (1); + /* NOTREACHED */ + } + } +#else cpu_reset_real(); +#endif } static voidhome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200309300801.h8U81kHw060244>
