5074362 cmn_err() doesn't work when the system is shutting down
authoryx209491
Thu, 29 Nov 2007 18:24:24 -0800
changeset 5555 1d9a328be2ad
parent 5554 ebb3348a29ee
child 5556 491e9eb313d5
5074362 cmn_err() doesn't work when the system is shutting down
usr/src/uts/common/io/consconfig.c
usr/src/uts/common/os/logsubr.c
usr/src/uts/common/os/panic.c
usr/src/uts/common/sys/log.h
usr/src/uts/i86pc/os/machdep.c
usr/src/uts/intel/ia32/ml/modstubs.s
usr/src/uts/sparc/ml/modstubs.s
usr/src/uts/sun4u/os/mach_cpu_states.c
usr/src/uts/sun4v/os/mach_cpu_states.c
--- a/usr/src/uts/common/io/consconfig.c	Thu Nov 29 18:00:12 2007 -0800
+++ b/usr/src/uts/common/io/consconfig.c	Thu Nov 29 18:24:24 2007 -0800
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
  *
  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  * or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -58,7 +57,8 @@
 #include <sys/errno.h>
 #include <sys/devops.h>
 #include <sys/note.h>
-
+#include <sys/log.h>
+#include <sys/consdev.h>
 
 /*
  * On supported configurations, the firmware defines the keyboard and mouse
@@ -129,3 +129,17 @@
 		return (i_ddi_strdup(usb_ms_path, KM_SLEEP));
 	return (NULL);
 }
+
+void
+consconfig_teardown(void)
+{
+	/*
+	 * rconsvp is set to NULL to ensure that output messages
+	 * are sent to the underlying "hardware" device using the
+	 * monitor's printf routine since we are in the process of
+	 * either rebooting or halting the machine.
+	 */
+	rconsvp = NULL;
+
+	log_flushall();
+}
--- a/usr/src/uts/common/os/logsubr.c	Thu Nov 29 18:00:12 2007 -0800
+++ b/usr/src/uts/common/os/logsubr.c	Thu Nov 29 18:24:24 2007 -0800
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -252,7 +252,7 @@
 	printf("\rSunOS Release %s Version %s %u-bit\n",
 	    utsname.release, utsname.version, NBBY * (uint_t)sizeof (void *));
 	printf("Copyright 1983-2007 Sun Microsystems, Inc.  "
-		"All rights reserved.\nUse is subject to license terms.\n");
+	    "All rights reserved.\nUse is subject to license terms.\n");
 #ifdef DEBUG
 	printf("DEBUG enabled\n");
 #endif
@@ -742,6 +742,15 @@
 	} while ((qlast = q) != qfirst);
 }
 
+void
+log_flushall()
+{
+	if (log_intrq != NULL)
+		log_flushq(log_intrq);
+	if (log_consq != NULL && log_consq != log_backlogq)
+		log_printq(log_consq);
+}
+
 /* ARGSUSED */
 static int
 log_cons_constructor(void *buf, void *cdrarg, int kmflags)
--- a/usr/src/uts/common/os/panic.c	Thu Nov 29 18:00:12 2007 -0800
+++ b/usr/src/uts/common/os/panic.c	Thu Nov 29 18:24:24 2007 -0800
@@ -300,16 +300,7 @@
 		(void) FTRACE_STOP();
 		(void) callb_execute_class(CB_CL_PANIC, NULL);
 
-		if (log_intrq != NULL)
-			log_flushq(log_intrq);
-
-		/*
-		 * If log_consq has been initialized and syslogd has started,
-		 * print any messages in log_consq that haven't been consumed.
-		 */
-		if (log_consq != NULL && log_consq != log_backlogq)
-			log_printq(log_consq);
-
+		log_flushall();
 		fm_banner();
 
 #if defined(__x86)
--- a/usr/src/uts/common/sys/log.h	Thu Nov 29 18:00:12 2007 -0800
+++ b/usr/src/uts/common/sys/log.h	Thu Nov 29 18:24:24 2007 -0800
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
  *
  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  * or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -115,6 +114,7 @@
 extern void log_printq(queue_t *);
 extern log_t *log_alloc(minor_t);
 extern void log_free(log_t *);
+extern void log_flushall();
 
 #endif	/* _KERNEL */
 
--- a/usr/src/uts/i86pc/os/machdep.c	Thu Nov 29 18:00:12 2007 -0800
+++ b/usr/src/uts/i86pc/os/machdep.c	Thu Nov 29 18:24:24 2007 -0800
@@ -156,6 +156,7 @@
 
 extern void pm_cfb_check_and_powerup(void);
 extern void pm_cfb_rele(void);
+extern void consconfig_teardown();
 
 /*
  * Machine dependent code to reboot.
@@ -177,14 +178,6 @@
 	}
 
 	/*
-	 * XXX - rconsvp is set to NULL to ensure that output messages
-	 * are sent to the underlying "hardware" device using the
-	 * monitor's printf routine since we are in the process of
-	 * either rebooting or halting the machine.
-	 */
-	rconsvp = NULL;
-
-	/*
 	 * Print the reboot message now, before pausing other cpus.
 	 * There is a race condition in the printing support that
 	 * can deadlock multiprocessor machines.
@@ -237,6 +230,8 @@
 		mutex_exit(&cpu_lock);
 	}
 
+	consconfig_teardown();
+
 	/*
 	 * try and reset leaf devices.  reset_leaves() should only
 	 * be called when there are no other threads that could be
--- a/usr/src/uts/intel/ia32/ml/modstubs.s	Thu Nov 29 18:00:12 2007 -0800
+++ b/usr/src/uts/intel/ia32/ml/modstubs.s	Thu Nov 29 18:24:24 2007 -0800
@@ -829,6 +829,7 @@
 	STUB(consconfig, consconfig,	0);
 	STUB(consconfig, consconfig_get_usb_kb_path,	0);
 	STUB(consconfig, consconfig_get_usb_ms_path,	0);
+	STUB(consconfig, consconfig_teardown,    0);
 	END_MODULE(consconfig);
 #endif
 
--- a/usr/src/uts/sparc/ml/modstubs.s	Thu Nov 29 18:00:12 2007 -0800
+++ b/usr/src/uts/sparc/ml/modstubs.s	Thu Nov 29 18:24:24 2007 -0800
@@ -741,6 +741,7 @@
 	STUB(consconfig, consconfig,	0);
 	STUB(consconfig, consconfig_get_usb_kb_path,	0);
 	STUB(consconfig, consconfig_get_usb_ms_path,	0);
+	STUB(consconfig, consconfig_teardown,    0);
 	END_MODULE(consconfig);
 #endif
 
--- a/usr/src/uts/sun4u/os/mach_cpu_states.c	Thu Nov 29 18:00:12 2007 -0800
+++ b/usr/src/uts/sun4u/os/mach_cpu_states.c	Thu Nov 29 18:24:24 2007 -0800
@@ -51,6 +51,8 @@
 static void reboot_machine(char *);
 int disable_watchdog_on_exit = 0;
 
+extern void consconfig_teardown();
+
 /*
  * Machine dependent code to reboot.
  * "mdep" is interpreted as a character pointer; if non-null, it is a pointer
@@ -77,14 +79,6 @@
 	}
 
 	/*
-	 * XXX - rconsvp is set to NULL to ensure that output messages
-	 * are sent to the underlying "hardware" device using the
-	 * monitor's printf routine since we are in the process of
-	 * either rebooting or halting the machine.
-	 */
-	rconsvp = NULL;
-
-	/*
 	 * At a high interrupt level we can't:
 	 *	1) bring up the console
 	 * or
@@ -114,6 +108,8 @@
 	 */
 	stop_other_cpus();
 
+	consconfig_teardown();
+
 	/*
 	 * try and reset leaf devices.  reset_leaves() should only
 	 * be called when there are no other threads that could be
--- a/usr/src/uts/sun4v/os/mach_cpu_states.c	Thu Nov 29 18:00:12 2007 -0800
+++ b/usr/src/uts/sun4v/os/mach_cpu_states.c	Thu Nov 29 18:24:24 2007 -0800
@@ -98,6 +98,8 @@
 #define	BOOT_CMD_MAX_LEN	256
 #define	BOOT_CMD_BASE		"boot "
 
+extern void consconfig_teardown();
+
 /*
  * In an LDoms system we do not save the user's boot args in NVRAM
  * as is done on legacy systems.  Instead, we format and send a
@@ -160,14 +162,6 @@
 {
 	extern void pm_cfb_check_and_powerup(void);
 
-	/*
-	 * XXX - rconsvp is set to NULL to ensure that output messages
-	 * are sent to the underlying "hardware" device using the
-	 * monitor's printf routine since we are in the process of
-	 * either rebooting or halting the machine.
-	 */
-	rconsvp = NULL;
-
 	switch (fcn) {
 	case AD_HALT:
 	case AD_POWEROFF:
@@ -239,6 +233,8 @@
 	 */
 	stop_other_cpus();
 
+	consconfig_teardown();
+
 	/*
 	 * try and reset leaf devices.  reset_leaves() should only
 	 * be called when there are no other threads that could be