+ serial-convert-early_uart-to-earlycon-for-8250.patch added to -mm tree
[email protected]
tree noticeThe patch titled
serial: convert early_uart to earlycon for 8250
has been added to the -mm tree. Its filename is
serial-convert-early_uart-to-earlycon-for-8250.patch
*** Remember to use Documentation/SubmitChecklist when testing your code ***
See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this
------------------------------------------------------
Subject: serial: convert early_uart to earlycon for 8250
From: Yinghai Lu <[email protected]>
Beacuse SERIAL_PORT_DFNS is removed from include/asm-i386/serial.h and include/asm-x86_64/serial.h. the serial8250_ports need to be probed late in serial initializing stage. the console_init=>serial8250_console_init=> register_console=>serial8250_console_setup will return -ENDEV, and console ttyS0 can not be enabled at that time. need to wait till uart_add_one_port in drivers/serial/serial_core.c to call register_console to get console ttyS0. that is too late.
Make early_uart to use early_param, so uart console can be used earlier. Make it to be bootconsole with CON_BOOT flag, so can use console handover feature. and it will switch to corresponding normal serial console automatically.
new command line will be:
console=uart8250,io,0x3f8,9600n8 console=uart8250,mmio,0xff5e0000,115200n8 or earlycon=uart8250,io,0x3f8,9600n8 earlycon=uart8250,mmio,0xff5e0000,115200n8
it will print in very early stage:
Early serial console at I/O port 0x3f8 (options '9600n8') console [uart0] enabled later for console it will print: console handover: boot [uart0] -> real [ttyS0]
---
Documentation/kernel-parameters.txt | 11 ++ arch/ia64/kernel/setup.c | 4 drivers/serial/8250.c | 28 +----- drivers/serial/8250_early.c | 108 ++++++++++++-------------- drivers/serial/Kconfig | 14 +++ include/asm-i386/fixmap.h | 2 include/asm-i386/io.h | 1 include/asm-x86_64/fixmap.h | 4 include/asm-x86_64/io.h | 1 include/linux/console.h | 2 include/linux/serial.h | 6 - include/linux/serial_8250.h | 3 init/main.c | 5 - kernel/printk.c | 22 +++++ 14 files changed, 118 insertions(+), 93 deletions(-)
Documentation/kernel-parameters.txt renamed from Documentation/kernel-parameters.txt~serial-convert-early_uart-to-earlycon-for-8250 +9 -2
@@ -464,13 +464,20 @@ and is between 256 and 4096 characters. Documentation/networking/netconsole.txt for an alternative. - uart,io,<addr>[,options] - uart,mmio,<addr>[,options] + uart8250,io,<addr>[,options] + uart8250,mmio,<addr>[,options] Start an early, polled-mode console on the 8250/16550 UART at the specified I/O port or MMIO address, switching to the matching ttyS device later. The options are the same as for ttyS, above. + earlycon= [KNL] Output early console device and options. + uart8250,io,<addr>[,options] + uart8250,mmio,<addr>[,options] + Start an early, polled-mode console on the 8250/16550 + UART at the specified I/O port or MMIO address. + The options are the same as for ttyS, above. + cpcihp_generic= [HW,PCI] Generic port I/O CompactPCI driver Format: <first_slot>,<last_slot>,<port>,<enum_bit>[,<debug>]
arch/ia64/kernel/setup.c renamed from arch/ia64/kernel/setup.c~serial-convert-early_uart-to-earlycon-for-8250 +0 -4
@@ -390,10 +390,6 @@ early_console_setup (char *cmdline)if (!efi_setup_pcdp_console (cmdline)) earlycons++;#endif -#ifdef CONFIG_SERIAL_8250_CONSOLE -if (!early_serial_console_init (cmdline)) - earlycons++; -#endif return (earlycons) ?0 :-1 ; }
drivers/serial/8250.c renamed from drivers/serial/8250.c~serial-convert-early_uart-to-earlycon-for-8250 +7 -21
@@ -2514,12 +2514,18 @@ static int __init serial8250_console_setreturn uart_set_options (port, co, baud, parity, bits, flow); } +static int __init serial8250_console_early_setup (void ) +{ +return serial8250_find_port_for_earlycon (); +} +static struct uart_driver serial8250_reg;static struct console serial8250_console = { .name ="ttyS" , .write = serial8250_console_write, .device = uart_console_device, .setup = serial8250_console_setup, + .early_setup = serial8250_console_early_setup, .flags =CON_PRINTBUFFER , .index =-1 , .data = &serial8250_reg,
@@ -2533,7 +2539,7 @@ static int __init serial8250_console_ini }console_initcall (serial8250_console_init); -static int __init find_port (struct uart_port *p) +int serial8250_find_port (struct uart_port *p) {int line;struct uart_port *port;
@@ -2546,26 +2552,6 @@ static int __init find_port(struct uart_ return -ENODEV; } -int __init serial8250_start_console (struct uart_port *port,char *options) -{ -int line; - - line =find_port (port); -if (line <0 ) -return -ENODEV ; - -add_preferred_console ("ttyS" , line, options); -printk ("Adding console on ttyS%d at %s 0x%lx (options '%s')\n" , - line, port->iotype ==UPIO_MEM ?"MMIO" :"I/O port" , - port->iotype ==UPIO_MEM ? (unsigned long ) port->mapbase : - (unsigned long ) port->iobase, options); -if (!(serial8250_console.flags &CON_ENABLED )) { - serial8250_console.flags &= ~CON_PRINTBUFFER ; -register_console (&serial8250_console); - } -return line; -} -#define SERIAL8250_CONSOLE &serial8250_console#else #define SERIAL8250_CONSOLE NULL
drivers/serial/8250_early.c renamed from drivers/serial/8250_early.c~serial-convert-early_uart-to-earlycon-for-8250 +50 -58
186 lines not on this page · raw message
drivers/serial/Kconfig renamed from drivers/serial/Kconfig~serial-convert-early_uart-to-earlycon-for-8250 +14 -0
@@ -62,8 +62,22 @@ config SERIAL_8250_CONSOLE kernel will automatically use the first serial line, /dev/ttyS0, as system console. + you can set that using a kernel command line option such as + "console=uart8250,io,0x3f8,9600n8" + "console=uart8250,mmio,0xff5e0000,115200n8". + and it will switch to normal serial console when correponding port is + ready. + "earlycon=uart8250,io,0x3f8,9600n8" + "earlycon=uart8250,mmio,0xff5e0000,115200n8". + it will not only setup early console. + If unsure, say N. +config FIX_EARLYCON_MEM + bool + depends on X86 + default y + config SERIAL_8250_GSC tristate depends on SERIAL_8250 && GSC
include/asm-i386/fixmap.h renamed from include/asm-i386/fixmap.h~serial-convert-early_uart-to-earlycon-for-8250 +2 -0
@@ -54,6 +54,8 @@ extern unsigned long __FIXADDR_TOP;enum fixed_addresses {FIX_HOLE ,FIX_VDSO , +FIX_DBGP_BASE , +FIX_EARLYCON_MEM_BASE ,#ifdef CONFIG_X86_LOCAL_APIC FIX_APIC_BASE ,/* local (CPU) APIC) -- required for SMP or not */ #endif
include/asm-i386/io.h renamed from include/asm-i386/io.h~serial-convert-early_uart-to-earlycon-for-8250 +1 -0
@@ -129,6 +129,7 @@ extern void iounmap(volatile void __iome*/ extern void *bt_ioremap (unsigned long offset,unsigned long size);extern void bt_iounmap (void *addr,unsigned long size); +extern void __iomem *fix_ioremap (unsigned idx,unsigned long phys);/* Use early IO mappings for DMI because it's initialized early */ #define dmi_ioremap bt_ioremap
include/asm-x86_64/fixmap.h renamed from include/asm-x86_64/fixmap.h~serial-convert-early_uart-to-earlycon-for-8250 +3 -1
@@ -35,6 +35,8 @@ enum fixed_addresses {VSYSCALL_LAST_PAGE ,VSYSCALL_FIRST_PAGE =VSYSCALL_LAST_PAGE + ((VSYSCALL_END -VSYSCALL_START ) >>PAGE_SHIFT ) -1 ,VSYSCALL_HPET , +FIX_DBGP_BASE , +FIX_EARLYCON_MEM_BASE ,FIX_HPET_BASE ,FIX_APIC_BASE ,/* local (CPU) APIC) -- required for SMP or not */ FIX_IO_APIC_BASE_0,
@@ -84,7 +86,7 @@ static __always_inline unsigned long fixif (idx >= __end_of_fixed_addresses)__this_fixmap_does_not_exist (); - return __fix_to_virt(idx); + return __fix_to_virt(idx); }#endif
include/asm-x86_64/io.h renamed from include/asm-x86_64/io.h~serial-convert-early_uart-to-earlycon-for-8250 +1 -0
@@ -141,6 +141,7 @@ static inline void __iomem * ioremap (un*/ extern void __iomem *ioremap_nocache (unsigned long offset,unsigned long size);extern void iounmap (volatile void __iomem *addr); +extern void __iomem *fix_ioremap (unsigned idx,unsigned long phys);/* * ISA I/O bus memory addresses are 1:1 with the physical address.
include/linux/console.h renamed from include/linux/console.h~serial-convert-early_uart-to-earlycon-for-8250 +2 -0
@@ -99,6 +99,7 @@ struct console {struct tty_driver *(*device)(struct console *,int *);void (*unblank)(void );int (*setup)(struct console *,char *); +int (*early_setup)(void );short flags;short index;int cflag;
@@ -107,6 +108,7 @@ struct console { };extern int add_preferred_console (char *name,int idx,char *options); +extern int update_console_cmdline (char *name,int idx,char *name_new,int idx_new,char *options);extern void register_console (struct console *);extern int unregister_console (struct console *);extern struct console *console_drivers;
include/linux/serial.h renamed from include/linux/serial.h~serial-convert-early_uart-to-earlycon-for-8250 +0 -6
@@ -177,11 +177,5 @@ struct serial_icounter_struct {#ifdef __KERNEL__#include <linux/compiler.h> -/* Allow architectures to override entries in serial8250_ports[] at run time: */ -struct uart_port ;/* forward declaration */ -extern int early_serial_setup (struct uart_port *port); -extern int early_serial_console_init (char *options); -extern int serial8250_start_console (struct uart_port *port,char *options); -#endif /* __KERNEL__ */ #endif /* _LINUX_SERIAL_H */
include/linux/serial_8250.h renamed from include/linux/serial_8250.h~serial-convert-early_uart-to-earlycon-for-8250 +3 -0
@@ -60,4 +60,7 @@ void serial8250_unregister_port(int linevoid serial8250_suspend_port (int line);void serial8250_resume_port (int line); +extern int serial8250_find_port (struct uart_port *p); +extern int serial8250_find_port_for_earlycon (void ); +#endif
init/main.c renamed from init/main.c~serial-convert-early_uart-to-earlycon-for-8250 +4 -1
@@ -452,7 +452,10 @@ static int __init do_early_param(char *pstruct obs_kernel_param *p;for (p = __setup_start; p < __setup_end; p++) { -if (p->early &&strcmp (param, p->str) ==0 ) { +if ((p->early &&strcmp (param, p->str) ==0 ) || + (strcmp (param,"console" ) ==0 && +strcmp (p->str,"earlycon" ) ==0 ) + ) {if (p->setup_func (val) !=0 )printk (KERN_WARNING "Malformed early option '%s'\n" , param);
kernel/printk.c renamed from kernel/printk.c~serial-convert-early_uart-to-earlycon-for-8250 +22 -0
@@ -726,6 +726,25 @@ int __init add_preferred_console(char *nreturn 0 ; } +int __init update_console_cmdline (char *name,int idx,char *name_new,int idx_new,char *options) +{ +struct console_cmdline *c; +int i; + +for (i =0 ; i <MAX_CMDLINECONSOLES && console_cmdline[i].name[0 ]; i++) +if (strcmp (console_cmdline[i].name, name) ==0 && + console_cmdline[i].index == idx) { + c = &console_cmdline[i]; +memcpy (c->name, name_new,sizeof (c->name)); + c->name[sizeof (c->name) -1 ] =0 ; + c->options = options; + c->index = idx_new; +return i; + } +/* not found */ +return -1 ; +} +#ifndef CONFIG_DISABLE_CONSOLE_SUSPEND /** * suspend_console - suspend the console subsystem
@@ -942,6 +961,9 @@ void register_console(struct console *coif (preferred_console <0 || bootconsole || !console_drivers) preferred_console = selected_console; +if (console->early_setup) + console->early_setup (); +/* * See if we want to use this console driver. If we * didn't select a console we take the first one
_
Patches currently in -mm which might be from [email protected] are
x86_64-change-early_ioremap-to-static.patch console-more-buf-for-index-parsing.patch console-console-handover-to-preferred-console.patch serial-convert-early_uart-to-earlycon-for-8250.patch serial-assert-dtr-for-serial-console-devices.patch
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 serial : convert early_uart to earlycon for 8250 fix 3 alias
[PATCH] serial : convert early_uart to earlycon for 8250 fix 3 alias
make the console=uart,io,0x3f8,9600n8 like console=uart8250,io,0x3f8,9600 suggested by Andy Whitcroft.
Documentation/kernel-parameters.txt +4 -4
@@ -467,16 +467,16 @@ Documentation/networking/netconsole.txt for an alternative. - uart8250,io,<addr>[,options] - uart8250,mmio,<addr>[,options] + uart[8250],io,<addr>[,options] + uart[8250],mmio,<addr>[,options] Start an early, polled-mode console on the 8250/16550 UART at the specified I/O port or MMIO address, switching to the matching ttyS device later. The options are the same as for ttyS, above. earlycon= [KNL] Output early console device and options. - uart8250,io,<addr>[,options] - uart8250,mmio,<addr>[,options] + uart[8250],io,<addr>[,options] + uart[8250],mmio,<addr>[,options] Start an early, polled-mode console on the 8250/16550 UART at the specified I/O port or MMIO address. The options are the same as for ttyS, above.
drivers/serial/8250_early.c +12 -3
@@ -210,8 +210,11 @@int err; options =strstr (cmdline,"uart8250," ); -if (!options) -return 0 ; +if (!options) { + options =strstr (cmdline,"uart," ); +if (!options) +return 0 ; + } options =strchr (cmdline,',' ) +1 ;if ((err =early_serial8250_setup (options)) <0 )
@@ -227,6 +230,7 @@struct early_serial8250_device *device = &early_device;struct uart_port *port = &device->port;int line; +int ret;if (!device->port.membase && !device->port.iobase)return -ENODEV ;
@@ -235,8 +239,13 @@if (line <0 )return -ENODEV ; -return update_console_cmdline ("uart" ,8250 , + ret =update_console_cmdline ("uart" ,8250 , +"ttyS" , line, device->options); +if (ret <0 ) + ret =update_console_cmdline ("uart" ,0 ,"ttyS" , line, device->options); + +return ret; }early_param ("earlycon" , setup_early_serial8250_console);
Re: [PATCH] serial : convert early_uart to earlycon for 8250 fix 3 alias
Quoted 33 lines · Yinghai Lu
[PATCH] serial : convert
early_uartto earlycon for 8250 fix 3 aliasmake the console=uart,io,0x3f8,9600n8 like console=uart8250,io,0x3f8,9600 suggested by Andy Whitcroft.
Signed-off-by Yinghai Lu <[email protected]>Documentation/kernel-parameters.txt +4
-4@@ -467,16 +467,16 @@ Documentation/networking/netconsole.txt for an alternative. - uart8250,io,<addr>[,options] - uart8250,mmio,<addr>[,options] + uart[8250],io,<addr>[,options] + uart[8250],mmio,<addr>[,options] Start an early, polled-mode console on the 8250/16550 UART at the specified I/O port or MMIO address, switching to the matching ttyS device later. The options are the same as for ttyS, above. earlycon= [KNL] Output early console device and options. - uart8250,io,<addr>[,options] - uart8250,mmio,<addr>[,options] + uart[8250],io,<addr>[,options] + uart[8250],mmio,<addr>[,options] Start an early, polled-mode console on the 8250/16550 UART at the specified I/O port or MMIO address. The options are the same as for ttyS, above.
drivers/serial/8250_early.c line 217
Quoted 10 lines
drivers/serial/8250_early.c +5
-2@@ -210,8 +210,11 @@int err; options =strstr (cmdline,"uart8250," ); -if (!options) -return 0 ; +if (!options) { + options =strstr (cmdline,"uart," ); +if (!options) +return 0 ; + }
This could probabally be written as below and be a little clearer:
options = strstr(cmdline, "uart8250,");
if (!options)
options = strstr(cmdline, "uart,"); if (!options) return 0;
Quoted 16 lines
drivers/serial/8250_early.c +1
-1options =strchr (cmdline,',' ) +1 ;if ((err =early_serial8250_setup (options)) <0 )@@ -227,6 +230,7 @@struct early_serial8250_device *device = &early_device;struct uart_port *port = &device->port;int line; +int ret;if (!device->port.membase && !device->port.iobase)return -ENODEV ;@@ -235,8 +239,13 @@if (line <0 )return -ENODEV ; - return update_console_cmdline("uart", 8250,
drivers/serial/8250_early.c line 251
Quoted 10 lines
drivers/serial/8250_early.c +6
-0+ ret =update_console_cmdline ("uart" ,8250 , +"ttyS" , line, device->options); +if (ret <0 ) + ret =update_console_cmdline ("uart" ,0 ,"ttyS" , line, device->options); + +return ret; }early_param ("earlycon" , setup_early_serial8250_console);
Other than the little nit above I have tested this on the machine which was all upset over the change and it works like a charm.
-apw