aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/printk.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@suse.de>2007-05-08 03:26:49 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:04 -0400
commit69331af79cf29e26d1231152a172a1a10c2df511 (patch)
tree0c6f805fc78c1969b8c46f02070cb9dc39f3f944 /kernel/printk.c
parent6ae9200f2cab7b328e505fc9a7021db64e0590cf (diff)
Fixes and cleanups for earlyprintk aka boot console
The console subsystem already has an idea of a boot console, using the CON_BOOT flag. The implementation has some flaws though. The major problem is that presence of a boot console makes register_console() ignore any other console devices (unless explicitly specified on the kernel command line). This patch fixes the console selection code to *not* consider a boot console a full-featured one, so the first non-boot console registering will become the default console instead. This way the unregister call for the boot console in the register_console() function actually triggers and the handover from the boot console to the real console device works smoothly. Added a printk for the handover, so you know which console device the output goes to when the boot console stops printing messages. The disable_early_printk() call is obsolete with that patch, explicitly disabling the early console isn't needed any more as it works automagically with that patch. I've walked through the tree, dropped all disable_early_printk() instances found below arch/ and tagged the consoles with CON_BOOT if needed. The code is tested on x86, sh (thanks to Paul) and mips (thanks to Ralf). Changes to last version: Rediffed against -rc3, adapted to mips cleanups by Ralf, fixed "udbg-immortal" cmd line arg on powerpc. Signed-off-by: Gerd Hoffmann <kraxel@exsuse.de> Acked-by: Paul Mundt <lethal@linux-sh.org> Acked-by: Ralf Baechle <ralf@linux-mips.org> Cc: Andi Kleen <ak@suse.de> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Paul Mackerras <paulus@samba.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Jeremy Fitzhardinge <jeremy@goop.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/printk.c')
-rw-r--r--kernel/printk.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/kernel/printk.c b/kernel/printk.c
index 4b47e59248df..c4c5a29a7bed 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -931,8 +931,16 @@ void register_console(struct console *console)
931{ 931{
932 int i; 932 int i;
933 unsigned long flags; 933 unsigned long flags;
934 struct console *bootconsole = NULL;
934 935
935 if (preferred_console < 0) 936 if (console_drivers) {
937 if (console->flags & CON_BOOT)
938 return;
939 if (console_drivers->flags & CON_BOOT)
940 bootconsole = console_drivers;
941 }
942
943 if (preferred_console < 0 || bootconsole || !console_drivers)
936 preferred_console = selected_console; 944 preferred_console = selected_console;
937 945
938 /* 946 /*
@@ -978,8 +986,11 @@ void register_console(struct console *console)
978 if (!(console->flags & CON_ENABLED)) 986 if (!(console->flags & CON_ENABLED))
979 return; 987 return;
980 988
981 if (console_drivers && (console_drivers->flags & CON_BOOT)) { 989 if (bootconsole) {
982 unregister_console(console_drivers); 990 printk(KERN_INFO "console handover: boot [%s%d] -> real [%s%d]\n",
991 bootconsole->name, bootconsole->index,
992 console->name, console->index);
993 unregister_console(bootconsole);
983 console->flags &= ~CON_PRINTBUFFER; 994 console->flags &= ~CON_PRINTBUFFER;
984 } 995 }
985 996
@@ -1030,16 +1041,11 @@ int unregister_console(struct console *console)
1030 } 1041 }
1031 } 1042 }
1032 1043
1033 /* If last console is removed, we re-enable picking the first 1044 /*
1034 * one that gets registered. Without that, pmac early boot console
1035 * would prevent fbcon from taking over.
1036 *
1037 * If this isn't the last console and it has CON_CONSDEV set, we 1045 * If this isn't the last console and it has CON_CONSDEV set, we
1038 * need to set it on the next preferred console. 1046 * need to set it on the next preferred console.
1039 */ 1047 */
1040 if (console_drivers == NULL) 1048 if (console_drivers != NULL && console->flags & CON_CONSDEV)
1041 preferred_console = selected_console;
1042 else if (console->flags & CON_CONSDEV)
1043 console_drivers->flags |= CON_CONSDEV; 1049 console_drivers->flags |= CON_CONSDEV;
1044 1050
1045 release_console_sem(); 1051 release_console_sem();