Module Name:    src
Committed By:   mrg
Date:           Sat Mar  3 23:43:18 UTC 2012

Modified Files:
        src/sys/arch/amd64/amd64: machdep.c
        src/sys/arch/i386/i386: machdep.c

Log Message:
make i386 and amd64 cpu_reboot() more similar.  in particular, bring
in the unmount/sync code from i386 to amd64, and call doshutdownhooks()
for i386.  the amd64 changes avoid umass triggering an assert later
when sd@umass is trying to sync the cache.

XXX merge x86 cpu_reboot(), but there's non-trivially different still.


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.723 -r1.724 src/sys/arch/i386/i386/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.179 src/sys/arch/amd64/amd64/machdep.c:1.180
--- src/sys/arch/amd64/amd64/machdep.c:1.179	Fri Mar  2 16:43:30 2012
+++ src/sys/arch/amd64/amd64/machdep.c	Sat Mar  3 23:43:17 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.179 2012/03/02 16:43:30 bouyer Exp $	*/
+/*	$NetBSD: machdep.c,v 1.180 2012/03/03 23:43:17 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.179 2012/03/02 16:43:30 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.180 2012/03/03 23:43:17 mrg Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -309,6 +309,8 @@ u_long	cpu_dump_mempagecnt(void);
 void	dodumpsys(void);
 void	dumpsys(void);
 
+extern int time_adjusted;	/* XXX no common header */
+
 void dump_misc_init(void);
 void dump_seg_prep(void);
 int dump_seg_iter(int (*)(paddr_t, paddr_t));
@@ -711,12 +713,12 @@ sendsig_siginfo(const ksiginfo_t *ksi, c
 		l->l_sigstk.ss_flags |= SS_ONSTACK;
 }
 
-int	waittime = -1;
 struct pcb dumppcb;
 
 void
 cpu_reboot(int howto, char *bootstr)
 {
+	static bool syncdone = false;
 	int s = IPL_NONE;
 
 	if (cold) {
@@ -725,15 +727,37 @@ cpu_reboot(int howto, char *bootstr)
 	}
 
 	boothowto = howto;
-	if ((howto & RB_NOSYNC) == 0 && waittime < 0) {
-		waittime = 0;
-		vfs_shutdown();
-		/*
-		 * If we've been adjusting the clock, the todr
-		 * will be out of synch; adjust it now.
-		 */
-		resettodr();
-	}
+
+	/* i386 maybe_dump() */
+
+	/*
+	 * If we've panic'd, don't make the situation potentially
+	 * worse by syncing or unmounting the file systems.
+	 */
+	if ((howto & RB_NOSYNC) == 0 && panicstr == NULL) {
+		if (!syncdone) {
+			syncdone = true;
+			/* XXX used to force unmount as well, here */
+			vfs_sync_all(curlwp);
+			/*
+			 * If we've been adjusting the clock, the todr
+			 * will be out of synch; adjust it now.
+			 *
+			 * XXX used to do this after unmounting all
+			 * filesystems with vfs_shutdown().
+			 */
+			if (time_adjusted != 0)
+				resettodr();
+		}
+
+		while (vfs_unmountall1(curlwp, false, false) ||
+		       config_detach_all(boothowto) ||
+		       vfs_unmount_forceone(curlwp))
+			;	/* do nothing */
+	} else
+		suspendsched();
+
+	pmf_system_shutdown(boothowto);
 
 	/* Disable interrupts. */
 	s = splhigh();
@@ -745,8 +769,6 @@ cpu_reboot(int howto, char *bootstr)
 haltsys:
 	doshutdownhooks();
 
-	pmf_system_shutdown(boothowto);
-
         if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
 #ifndef XEN
 #if NACPICA > 0

Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.723 src/sys/arch/i386/i386/machdep.c:1.724
--- src/sys/arch/i386/i386/machdep.c:1.723	Fri Mar  2 16:43:31 2012
+++ src/sys/arch/i386/i386/machdep.c	Sat Mar  3 23:43:17 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.723 2012/03/02 16:43:31 bouyer Exp $	*/
+/*	$NetBSD: machdep.c,v 1.724 2012/03/03 23:43:17 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.723 2012/03/02 16:43:31 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.724 2012/03/03 23:43:17 mrg Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -835,11 +835,7 @@ void
 cpu_reboot(int howto, char *bootstr)
 {
 	static bool syncdone = false;
-	struct lwp *l;
-	int s;
-
-	s = IPL_NONE;
-	l = (curlwp == NULL) ? &lwp0 : curlwp;
+	int s = IPL_NONE;
 
 	if (cold) {
 		howto |= RB_HALT;
@@ -861,7 +857,7 @@ cpu_reboot(int howto, char *bootstr)
 		if (!syncdone) {
 			syncdone = true;
 			/* XXX used to force unmount as well, here */
-			vfs_sync_all(l);
+			vfs_sync_all(curlwp);
 			/*
 			 * If we've been adjusting the clock, the todr
 			 * will be out of synch; adjust it now.
@@ -873,9 +869,9 @@ cpu_reboot(int howto, char *bootstr)
 				resettodr();
 		}
 
-		while (vfs_unmountall1(l, false, false) ||
+		while (vfs_unmountall1(curlwp, false, false) ||
 		       config_detach_all(boothowto) ||
-		       vfs_unmount_forceone(l))
+		       vfs_unmount_forceone(curlwp))
 			;	/* do nothing */
 	} else
 		suspendsched();
@@ -883,7 +879,11 @@ cpu_reboot(int howto, char *bootstr)
 	pmf_system_shutdown(boothowto);
 
 	s = splhigh();
+
+	/* amd64 maybe_dump() */
+
 haltsys:
+	doshutdownhooks();
 
 	if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
 #ifdef XEN

Reply via email to