Commit 35bafd11 authored by Maciej W. Rozycki's avatar Maciej W. Rozycki Committed by Linus Torvalds

[PATCH] "console=" parameter ignored

I've noticed that under specific circumstances the "console=" kernel
parameter is ignored.  This happens when EARLY_PRINTK is enabled and the
serial console is the only available.  In this case unregister_console()
when called for the early console sets preferred_console back to -1
replacing the value that was recorded by console_setup() -- the order of
calls is as follows:

1. register_console() -- for the early console,

2. console_setup() -- recording the console index for the real console,

3. unregister_console() -- for the early console, erasing the console
   index recorded above,

4. register_console() -- for the real console, picking up the first device
   available, instead of the selected one.

I've observed this problem with a DECstation system using ttyS3 -- its
default console device from the firmware's point of view.

The solution is to restore the setting of "console=" upon
unregister_console().  This made a snapshot of 2.4.26 work for me.  I
wasn't able to test the changes with 2.6 because DECstation drivers don't
support it yet, but the code responsible for console selection appears
functionally the same.  So I've concluded it needs the same change.  Here's
a patch.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 151d6611
...@@ -109,6 +109,7 @@ struct console_cmdline ...@@ -109,6 +109,7 @@ struct console_cmdline
#define MAX_CMDLINECONSOLES 8 #define MAX_CMDLINECONSOLES 8
static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES]; static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES];
static int selected_console = -1;
static int preferred_console = -1; static int preferred_console = -1;
/* Flag: console code may call schedule() */ /* Flag: console code may call schedule() */
...@@ -174,12 +175,12 @@ int __init add_preferred_console(char *name, int idx, char *options) ...@@ -174,12 +175,12 @@ int __init add_preferred_console(char *name, int idx, char *options)
for(i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++) for(i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++)
if (strcmp(console_cmdline[i].name, name) == 0 && if (strcmp(console_cmdline[i].name, name) == 0 &&
console_cmdline[i].index == idx) { console_cmdline[i].index == idx) {
preferred_console = i; selected_console = i;
return 0; return 0;
} }
if (i == MAX_CMDLINECONSOLES) if (i == MAX_CMDLINECONSOLES)
return -E2BIG; return -E2BIG;
preferred_console = i; selected_console = i;
c = &console_cmdline[i]; c = &console_cmdline[i];
memcpy(c->name, name, sizeof(c->name)); memcpy(c->name, name, sizeof(c->name));
c->name[sizeof(c->name) - 1] = 0; c->name[sizeof(c->name) - 1] = 0;
...@@ -746,6 +747,9 @@ void register_console(struct console * console) ...@@ -746,6 +747,9 @@ void register_console(struct console * console)
int i; int i;
unsigned long flags; unsigned long flags;
if (preferred_console < 0)
preferred_console = selected_console;
/* /*
* See if we want to use this console driver. If we * See if we want to use this console driver. If we
* didn't select a console we take the first one * didn't select a console we take the first one
...@@ -836,7 +840,7 @@ int unregister_console(struct console * console) ...@@ -836,7 +840,7 @@ int unregister_console(struct console * console)
* would prevent fbcon from taking over. * would prevent fbcon from taking over.
*/ */
if (console_drivers == NULL) if (console_drivers == NULL)
preferred_console = -1; preferred_console = selected_console;
release_console_sem(); release_console_sem();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment