REGRESSION: serial_cs broken by 8250 changes
commit 18a8bd949d6adb311ea816125ff65050df1f3f6e breaks serial_cs badly with an oops, completely killing PCMCIA.
register_console() now calls console->early_setup(). which in case of 8250.c (the only user anyway) is serial8250_console_early_setup() which is __init, calling 8250_early.c:serial8250_find_port_for_earlycon() which is __init as well. boom.
the changelog mentions SERIAL_PORT_DFNS removal which happens to be commit 7e92b4fc345f5b6f57585fbe5ffdb0f24d7c9b26. but this got reverted by commit 57d4810ea0d9ca58a7bcc1336607f0cede0a2abf. so i'd suggest to just revert the 8250 changes as well.
rgds
-daniel
Quoted 8 lines · On Fri, 3 Aug 2007 01:06:32 +0200 Daniel Ritz <[email protected]>…
commit
18a8bd949d6adb311ea816125ff65050df1f3f6ebreaksserial_csbadly with an oops, completely killing PCMCIA.
register_console()now callsconsole->early_setup(). which in case of 8250.c (the only user anyway) isserial8250_console_early_setup()which is__init, calling 8250_early.c:serial8250_find_port_for_earlycon() which is__initas well. boom.
Quoted 5 lines
the changelog mentions
SERIAL_PORT_DFNSremoval which happens to be commit7e92b4fc345f5b6f57585fbe5ffdb0f24d7c9b26. but this got reverted by commit57d4810ea0d9ca58a7bcc1336607f0cede0a2abf. so i'd suggest to just revert the 8250 changes as well.
<head spins>
Sounds like you'd be the ideal person to propose a patch ;)
Quoted 8 lines · Daniel Ritz
commit
18a8bd949d6adb311ea816125ff65050df1f3f6ebreaksserial_csbadly with an oops, completely killing PCMCIA.
register_console()now callsconsole->early_setup(). which in case of 8250.c (the only user anyway) isserial8250_console_early_setup()which is__init, calling 8250_early.c:serial8250_find_port_for_earlycon() which is__initas well. boom.
Quoted 7 lines
the changelog mentions
SERIAL_PORT_DFNSremoval which happens to be commit7e92b4fc345f5b6f57585fbe5ffdb0f24d7c9b26. but this got reverted by commit57d4810ea0d9ca58a7bcc1336607f0cede0a2abf. so i'd suggest to just revert the 8250 changes as well.rgds
-daniel
Is there any flag or sign that init code has been released?
We could use that to prevent init code to be called after code is freed.
Thanks
Yinghai Lu
Quoted 14 lines · On Thu, 02 Aug 2007 16:24:42 -0700 Yinghai Lu <[email protected]> wrote:
Quoted 13 lines · Daniel Ritz
commit
18a8bd949d6adb311ea816125ff65050df1f3f6ebreaksserial_csbadly with an oops, completely killing PCMCIA.
register_console()now callsconsole->early_setup(). which in case of 8250.c (the only user anyway) isserial8250_console_early_setup()which is__init, calling 8250_early.c:serial8250_find_port_for_earlycon() which is__initas well. boom.the changelog mentions
SERIAL_PORT_DFNSremoval which happens to be commit7e92b4fc345f5b6f57585fbe5ffdb0f24d7c9b26. but this got reverted by commit57d4810ea0d9ca58a7bcc1336607f0cede0a2abf. so i'd suggest to just revert the 8250 changes as well.
Quoted 4 lines
Quoted 2 lines
rgds
-danielIs there any flag or sign that init code has been released?
Nope.
Quoted 1 line
We could use that to prevent init code to be called after code is freed.
If we can omit a function call without breaking anything then we shouldn't have been calling that function at all ;)
It sounds like making serial8250_console_early_setup() and serial8250_find_port_for_earlycon() non-__init will fix this.
Quoted 23 lines · Andrew Morton
Quoted 9 lines · On Thu, 02 Aug 2007 16:24:42 -0700 Yinghai Lu <[email protected]> wrote:
Quoted 8 lines · Daniel Ritz
commit
18a8bd949d6adb311ea816125ff65050df1f3f6ebreaksserial_csbadly with an oops, completely killing PCMCIA.
register_console()now callsconsole->early_setup(). which in case of 8250.c (the only user anyway) isserial8250_console_early_setup()which is__init, calling 8250_early.c:serial8250_find_port_for_earlycon() which is__initas well. boom.Quoted 8 lines
Quoted 7 lines
the changelog mentions
SERIAL_PORT_DFNSremoval which happens to be commit7e92b4fc345f5b6f57585fbe5ffdb0f24d7c9b26. but this got reverted by commit57d4810ea0d9ca58a7bcc1336607f0cede0a2abf. so i'd suggest to just revert the 8250 changes as well.rgds
-danielIs there any flag or sign that init code has been released?
Nope.
Quoted 8 lines
Quoted 1 line
We could use that to prevent init code to be called after code is freed.
If we can omit a function call without breaking anything then we shouldn't have been calling that function at all ;)
It sounds like making
serial8250_console_early_setup()andserial8250_find_port_for_earlycon()non-__init will fix this.
yes, together update_console_cmdline in kernel/printk.c
Daniel,
can you test that in your setup?
Thanks
Yinghai Lu
Quoted 29 lines · On Friday 03 August 2007 02:18:10 Yinghai Lu wrote:
Quoted 28 lines · Andrew Morton
Quoted 9 lines · On Thu, 02 Aug 2007 16:24:42 -0700 Yinghai Lu <[email protected]> wrote:
Quoted 8 lines · Daniel Ritz
commit
18a8bd949d6adb311ea816125ff65050df1f3f6ebreaksserial_csbadly with an oops, completely killing PCMCIA.
register_console()now callsconsole->early_setup(). which in case of 8250.c (the only user anyway) isserial8250_console_early_setup()which is__init, calling 8250_early.c:serial8250_find_port_for_earlycon() which is__initas well. boom.Quoted 8 lines
Quoted 7 lines
the changelog mentions
SERIAL_PORT_DFNSremoval which happens to be commit7e92b4fc345f5b6f57585fbe5ffdb0f24d7c9b26. but this got reverted by commit57d4810ea0d9ca58a7bcc1336607f0cede0a2abf. so i'd suggest to just revert the 8250 changes as well.rgds
-danielIs there any flag or sign that init code has been released?
Nope.
Quoted 1 line
We could use that to prevent init code to be called after code is freed.
If we can omit a function call without breaking anything then we shouldn't have been calling that function at all ;)
Quoted 9 lines
Quoted 3 lines
It sounds like making
serial8250_console_early_setup()andserial8250_find_port_for_earlycon()non-__init will fix this.yes, together
update_console_cmdlineinkernel/printk.cDaniel,
can you test that in your setup?
yep, seems to work. patch attached.
rgds
-daniel
----------
[PATCH] serial: fix 8250 early console setup
the early setup function serial8250_console_early_setup() can be called from non __init code (eg. hotpluggable serial ports like serial_cs) so remove the __init from the call chain to avoid crashes.
drivers/serial/8250.c +1 -1
@@ -2514,7 +2514,7 @@ static int __init serial8250_console_setup(struct console *co, char *options)return uart_set_options (port, co, baud, parity, bits, flow); } -static int __init serial8250_console_early_setup (void ) +static int serial8250_console_early_setup (void ) {return serial8250_find_port_for_earlycon (); }
drivers/serial/8250_early.c +1 -1
@@ -227,7 +227,7 @@ int __init setup_early_serial8250_console(char *cmdline)return 0 ; } -int __init serial8250_find_port_for_earlycon (void ) +int serial8250_find_port_for_earlycon (void ) {struct early_serial8250_device *device = &early_device;struct uart_port *port = &device->port;
kernel/printk.c +1 -1
@@ -732,7 +732,7 @@ int __init add_preferred_console(char *name, int idx, char *options)return 0 ; } -int __init update_console_cmdline (char *name,int idx,char *name_new,int idx_new,char *options) +int update_console_cmdline (char *name,int idx,char *name_new,int idx_new,char *options) {struct console_cmdline *c;int i;
Quoted 4 lines · Andrew Morton
Quoted 1 line
We could use that to prevent init code to be called after code is freed.
If we can omit a function call without breaking anything then we shouldn't have been calling that function at all ;)
Well, we can always put a couple of otherwise unneeded calls here and
there to make the compiler happy to enjoy its freedom to produce code and exercise the calling convention rules set by the ABI before the actual use. ;-)
Maciej