Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch make i386 and amd64 cpu_reboot() more similar. in ...



details:   https://anonhg.NetBSD.org/src/rev/99dcca8f844b
branches:  trunk
changeset: 777775:99dcca8f844b
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sat Mar 03 23:43:17 2012 +0000

description:
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.

diffstat:

 sys/arch/amd64/amd64/machdep.c |  50 ++++++++++++++++++++++++++++++-----------
 sys/arch/i386/i386/machdep.c   |  20 ++++++++--------
 2 files changed, 46 insertions(+), 24 deletions(-)

diffs (161 lines):

diff -r 2dec256e6ae8 -r 99dcca8f844b sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Sat Mar 03 23:16:47 2012 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Sat Mar 03 23:43:17 2012 +0000
@@ -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 @@
 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 @@
                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 @@
        }
 
        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 @@
 haltsys:
        doshutdownhooks();
 
-       pmf_system_shutdown(boothowto);
-
         if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
 #ifndef XEN
 #if NACPICA > 0
diff -r 2dec256e6ae8 -r 99dcca8f844b sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Sat Mar 03 23:16:47 2012 +0000
+++ b/sys/arch/i386/i386/machdep.c      Sat Mar 03 23:43:17 2012 +0000
@@ -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 @@
 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 @@
                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 @@
                                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 @@
        pmf_system_shutdown(boothowto);
 
        s = splhigh();
+
+       /* amd64 maybe_dump() */
+
 haltsys:
+       doshutdownhooks();
 
        if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
 #ifdef XEN



Home | Main Index | Thread Index | Old Index