public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* RFC - printk handling more than one CON_BOOT
@ 2009-06-29 11:03 Robin Getz
  2009-06-30 22:25 ` Ingo Molnar
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Robin Getz @ 2009-06-29 11:03 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel

Today, register_console() assumes the following usage (with respect to boot
consoles/early_printk).

The first console to register with register_console() with a flags set to
CON_BOOT is the one and only bootconsole. 

If another register_console() is called with an additional CON_BOOT, today it
is silently rejected.

As soon as a console without the CON_BOOT set calls register_console(), the
one and only bootconsole is automatically unregistered.

Once there is a "standard" console - register_console() will silently reject
any consoles with it's CON_BOOT, set.


This changeset allows multiple boot consoles, and changes the functionality
to, be mostly the same as the above.

Any number of bootconsoles can be registered.
A "real" console will unregister all the bootconsoles.
Once a "real" console is registered, no more bootconsoles can be added.

Thoughts?

The use case is to have a console buffer which goes to serial, and a console
buffer which goes to a fixed memory buffer at the same time. (serial is what
most people use, but if serial is hosed for some reason, having things in
a buffer (which gets printed out by the bootloader) is the only way to
tell what is going on).

If you don't object I will send a properly formatted patch...

-------------


Index: kernel/printk.c
===================================================================
--- kernel/printk.c	(revision 6860)
+++ kernel/printk.c	(working copy)
@@ -1126,9 +1126,24 @@
 	unsigned long flags;
 	struct console *bootconsole = NULL;
 
+	/* before we register a new CON_BOOT console, make sure we don't
+	 * already have a valid console
+	 */
 	if (console_drivers) {
-		if (console->flags & CON_BOOT)
-			return;
+		if (console->flags & CON_BOOT) {
+			for (bootconsole = console_drivers;
+				bootconsole != NULL;
+				bootconsole = bootconsole->next) {
+				if (!(bootconsole->flags & CON_BOOT))
+					break;
+			}
+			if ((console->flags & CON_BOOT) &&
+				!(bootconsole->flags & CON_BOOT))
+				return;
+			if (!(bootconsole->flags & CON_BOOT))
+				bootconsole = NULL;
+		}
+
 		if (console_drivers->flags & CON_BOOT)
 			bootconsole = console_drivers;
 	}
@@ -1195,15 +1210,32 @@
 	if (!(console->flags & CON_ENABLED))
 		return;
 
-	if (bootconsole && (console->flags & CON_CONSDEV)) {
-		printk(KERN_INFO "console handover: boot [%s%d] -> real [%s%d]\n",
-		       bootconsole->name, bootconsole->index,
-		       console->name, console->index);
-		unregister_console(bootconsole);
+	if (bootconsole && (console->flags & CON_CONSDEV) &&
+		!(console->flags & CON_BOOT)) {
+		/* we need to iterate through twice, to make sure we print
+		 * everything out, before we unregister the console(s)
+		 */
+		printk(KERN_INFO "console handover: ");
+		for (bootconsole = console_drivers; bootconsole != NULL;
+			bootconsole = bootconsole->next) {
+			if (bootconsole->flags & CON_BOOT)
+				printk("boot [%s%d] ", bootconsole->name,
+					bootconsole->index);
+		}
+		printk(" -> real [%s%d]\n", console->name, console->index);
+		for (bootconsole = console_drivers; bootconsole != NULL;
+			bootconsole = bootconsole->next) {
+			if (bootconsole->flags & CON_BOOT)
+				unregister_console(bootconsole);
+		}
 		console->flags &= ~CON_PRINTBUFFER;
 	} else {
-		printk(KERN_INFO "console [%s%d] enabled\n",
-		       console->name, console->index);
+		if (console->flags & CON_BOOT)
+			printk(KERN_INFO "bootconsole [%s%d] enabled\n",
+				console->name, console->index);
+		else
+			printk(KERN_INFO "console [%s%d] enabled\n",
+				console->name, console->index);
 	}
 
 	/*

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2009-07-21 18:33 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-29 11:03 RFC - printk handling more than one CON_BOOT Robin Getz
2009-06-30 22:25 ` Ingo Molnar
2009-06-30 23:05   ` Robin Getz
2009-06-30 23:14     ` Ingo Molnar
2009-07-01  0:29       ` Robin Getz
2009-07-01  2:51 ` [RFC v2] kernel/printk.c - " Robin Getz
2009-07-01 19:44   ` Andrew Morton
2009-07-01 20:50     ` Robin Getz
2009-07-01 21:01       ` Andrew Morton
2009-07-01 21:14         ` Ingo Molnar
2009-07-01 21:28         ` Robin Getz
2009-07-01 21:31         ` Robin Getz
2009-07-02  1:08 ` [PATCH] - printk " Robin Getz
2009-07-03  8:58   ` [tip:core/printk] printk: Enable the use of more than one CON_BOOT (early console) tip-bot for Robin Getz
2009-07-21 18:37   ` [PATCH] - printk handling more than one CON_BOOT Robin Getz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox