Extensible console matching & direct earlycon
Subsystems (6)
cover Extensible console matching & direct earlycon
Hi Greg & Andrew,
This patch series implements:
1. console-definable (aka extensible) matching
2. generic earlycon-to-console handoff via extensible matching
3. arch/prom support for direct earlycon
Extensible console matching
Extensible console matching enables the console itself to define the conditions for a "command line" match. This mimics the design of device matching in the driver model. Two important use-cases which this feature enables are generic earlycon-to-console handoff and support for driver migration.
Earlycon-to-console handoff was implemented in 2007. Console command lines of the form:
console=uart,io,0x3f8,115200n8
start an earlycon and later allow the 8250 driver console to takeover. Unfortunately this implementation requires direct coupling between the earlycon and the console and is facilitated by ugly hacks like editing the console command line in-place.
Extensible console matching allows the 8250 driver to directly match that console command line instead, and enables other serial drivers to trivially support console handoff themselves.
In addition, extensible console matching allows a new driver to provide support for a different driver's console. This requirement stems from needing to minimize breakage when migrating serial drivers. Since many devices are based on the original 8250/16550 designs but sometimes have features incompatible with the existing 8250 driver support, the initial driver is often standalone. When/if the standalone driver is migrated to the 8250 driver, the problem of console names in the command line remains. Extensible console matching enables a simple migration path.
Direct earlycon
This feature enables arches and proms to start an earlycon directly, rather than requiring an "earlycon=" command line parameter. Devicetree can already do this via the 'linux,stdout-path' property, but arch and prom code requires direct coupling to the serial driver.
This support is implemented by judicious refactoring and the same construct that devicetree and early_param use: a link table containing the necessary information (name and setup() function) to find and bind the appropriate earlycon "driver".
NB: I combined these two features in this series because their implementations heavily overlap in the same source files.
Regards,
Peter Hurley (13):
serial: earlycon: Refactor parse_options into serial core
console: Preserve index after console setup()
console: Add extensible console matching
serial: core: Fix kernel doc for uart_console_write()
serial: 8250_early: Remove early_device variable
serial: earlycon: Move ->uartclk initialize
serial: 8250_early: Assume uart already initialized if no baud option
serial: 8250_early: Fix setup() error code
serial: earlycon: Ignore parse_options() error code
serial: earlycon: Allow earlycon params with name only
serial: earlycon: Refactor earlycon registration
serial: earlycon: Enable earlycon without command line param
serial: 8250_early: Remove setup_early_serial8250_console()
arch/mips/mti-malta/malta-init.c | 4 +- drivers/firmware/pcdp.c | 4 +- drivers/tty/serial/8250/8250_core.c | 64 ++++++++++++---- drivers/tty/serial/8250/8250_early.c | 51 +++---------- drivers/tty/serial/earlycon.c | 140 ++++++++++++++++++++++++----------- drivers/tty/serial/serial_core.c | 48 +++++++++++- include/asm-generic/vmlinux.lds.h | 9 +++ include/linux/console.h | 3 +- include/linux/serial_8250.h | 3 - include/linux/serial_core.h | 21 ++++-- kernel/printk/printk.c | 51 +++++-------- 11 files changed, 245 insertions(+), 153 deletions(-)
Signature · 1 line
2.3.0
PATCH 1/13 serial: earlycon: Refactor parse_options into serial core
Prepare to support console-defined matching; refactor the command line parameter string processing from parse_options() into a new core function, uart_parse_earlycon(), which decodes command line parameters of the form:
earlycon=<name>,io|mmio|mmio32,<addr>,<options> console=<name>,io|mmio|mmio32,<addr>,<options> earlycon=<name>,0x<addr>,<options> console=<name>,0x<addr>,<options>
--- drivers/tty/serial/earlycon.c | 39 ++++++++++++---------------------- drivers/tty/serial/serial_core.c | 46 ++++++++++++++++++++++++++++++++++++++++ include/linux/serial_core.h | 2 ++ 3 files changed, 61 insertions(+), 26 deletions(-)
drivers/tty/serial/earlycon.c +13 -26
@@ -54,44 +54,31 @@ static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)return base; } -static int __init parse_options (struct earlycon_device *device, -char *options) +static int __init parse_options (struct earlycon_device *device,char *options) {struct uart_port *port = &device->port; -int mmio, mmio32, length; +int length;unsigned long addr; -if (!options) -return -ENODEV ; +if (uart_parse_earlycon (options, &port->iotype, &addr, &options)) +return -EINVAL ; - mmio = !strncmp (options,"mmio," ,5 ); - mmio32 = !strncmp (options,"mmio32," ,7 ); -if (mmio || mmio32) { - port->iotype = (mmio ?UPIO_MEM :UPIO_MEM32 ); - options += mmio ?5 :7 ; - addr =simple_strtoul (options,NULL ,0 ); +switch (port->iotype) { +case UPIO_MEM32 : + port->regshift =2 ;/* fall-through */ +case UPIO_MEM : port->mapbase = addr; -if (mmio32) - port->regshift =2 ; - }else if (!strncmp (options,"io," ,3 )) { - port->iotype =UPIO_PORT ; - options +=3 ; - addr =simple_strtoul (options,NULL ,0 ); +break ; +case UPIO_PORT : port->iobase = addr; - mmio =0 ; - }else if (!strncmp (options,"0x" ,2 )) { - port->iotype =UPIO_MEM ; - addr =simple_strtoul (options,NULL ,0 ); - port->mapbase = addr; - }else { +break ; +default :return -EINVAL ; } port->uartclk =BASE_BAUD *16 ; - options =strchr (options,',' );if (options) { - options++; device->baud =simple_strtoul (options,NULL ,0 ); length =min (strcspn (options," " ) +1 , (size_t )(sizeof (device->options)));
@@ -100,7 +87,7 @@ static int __init parse_options(struct earlycon_device *device,if (port->iotype ==UPIO_MEM || port->iotype ==UPIO_MEM32 )pr_info ("Early serial console at MMIO%s 0x%llx (options '%s')\n" , - mmio32 ?"32" :"" , + (port->iotype ==UPIO_MEM32 ) ?"32" :"" , (unsigned long long )port->mapbase, device->options);else
drivers/tty/serial/serial_core.c +46 -0
52 lines not on this page · raw message
include/linux/serial_core.h +2 -0
@@ -354,6 +354,8 @@ early_param("earlycon", name ## _setup_earlycon);struct uart_port *uart_get_console (struct uart_port *ports,int nr,struct console *c); +int uart_parse_earlycon (char *p,unsigned char *iotype,unsigned long *addr, +char **options);void uart_parse_options (char *options,int *baud,int *parity,int *bits,int *flow); int uart_set_options(struct uart_port *port, struct console *co, int baud,
Signature · 1 line
2.3.0
Re: [PATCH -next 01/13] serial: earlycon: Refactor parse_options into serial core
Hi Joe,
checkpatch warns on the line below:
Quoted 120 lines · Peter Hurley
Prepare to support console-defined matching; refactor the command line parameter string processing from
parse_options()into a new core function,uart_parse_earlycon(), which decodes command line parameters of the form:earlycon=<name>,io|mmio|mmio32,<addr>,<options> console=<name>,io|mmio|mmio32,<addr>,<options> earlycon=<name>,0x<addr>,<options> console=<name>,0x<addr>,<options>Signed-off-by Peter Hurley <[email protected]>--- drivers/tty/serial/earlycon.c | 39 ++++++++++++---------------------- drivers/tty/serial/serial_core.c | 46 ++++++++++++++++++++++++++++++++++++++++ include/linux/serial_core.h | 2 ++ 3 files changed, 61 insertions(+), 26 deletions(-)drivers/tty/serial/earlycon.c +13
-26@@ -54,44 +54,31 @@ static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)return base; } -static int __init parse_options (struct earlycon_device *device, -char *options) +static int __init parse_options (struct earlycon_device *device,char *options) {struct uart_port *port = &device->port; -int mmio, mmio32, length; +int length;unsigned long addr; -if (!options) -return -ENODEV ; +if (uart_parse_earlycon (options, &port->iotype, &addr, &options)) +return -EINVAL ; - mmio = !strncmp (options,"mmio," ,5 ); - mmio32 = !strncmp (options,"mmio32," ,7 ); -if (mmio || mmio32) { - port->iotype = (mmio ?UPIO_MEM :UPIO_MEM32 ); - options += mmio ?5 :7 ; - addr =simple_strtoul (options,NULL ,0 ); +switch (port->iotype) { +case UPIO_MEM32 : + port->regshift =2 ;/* fall-through */ +case UPIO_MEM : port->mapbase = addr; -if (mmio32) - port->regshift =2 ; - }else if (!strncmp (options,"io," ,3 )) { - port->iotype =UPIO_PORT ; - options +=3 ; - addr =simple_strtoul (options,NULL ,0 ); +break ; +case UPIO_PORT : port->iobase = addr; - mmio =0 ; - }else if (!strncmp (options,"0x" ,2 )) { - port->iotype =UPIO_MEM ; - addr =simple_strtoul (options,NULL ,0 ); - port->mapbase = addr; - }else { +break ; +default :return -EINVAL ; } port->uartclk =BASE_BAUD *16 ; - options =strchr (options,',' );if (options) { - options++; device->baud =simple_strtoul (options,NULL ,0 ); length =min (strcspn (options," " ) +1 , (size_t )(sizeof (device->options)));@@ -100,7 +87,7 @@ static int __init parse_options(struct earlycon_device *device,if (port->iotype ==UPIO_MEM || port->iotype ==UPIO_MEM32 )pr_info ("Early serial console at MMIO%s 0x%llx (options '%s')\n" , - mmio32 ?"32" :"" , + (port->iotype ==UPIO_MEM32 ) ?"32" :"" , (unsigned long long )port->mapbase, device->options);else drivers/tty/serial/serial_core.c +26
-0@@ -1810,6 +1810,52 @@ uart_get_console(struct uart_port *ports, int nr, struct console *co) }/** +* uart_parse_earlycon - Parse earlycon options +* @p: ptr to 2nd field (ie., just beyond '<name>,') +* @iotype: ptr for decoded iotype (out) +* @addr: ptr for decoded mapbase/iobase (out) +* @options: ptr for <options> field; NULL if not present (out) +* +* Decodes earlycon kernel command line parameters of the form +* earlycon=<name>,io|mmio|mmio32,<addr>,<options> +* console=<name>,io|mmio|mmio32,<addr>,<options> +* +* The optional form +* earlycon=<name>,0x<addr>,<options> +* console=<name>,0x<addr>,<options> +* is also accepted; the returned @iotype will be UPIO_MEM. +* +* Returns 0 on success or -EINVAL on failure +*/ +int uart_parse_earlycon (char *p,unsigned char *iotype,unsigned long *addr, +char **options) +{ +if (strncmp (p,"mmio," ,5 ) ==0 ) { + *iotype =UPIO_MEM ; + p +=5 ; + }else if (strncmp (p,"mmio32," ,7 ) ==0 ) { + *iotype =UPIO_MEM32 ; + p +=7 ;
drivers/tty/serial/serial_core.c uart_get_console(struct uart_port *ports, int nr, struct console *co) · line 1848
Quoted 10 lines
drivers/tty/serial/serial_core.c +10
-0+ }else if (strncmp (p,"io," ,3 ) ==0 ) { + *iotype =UPIO_PORT ; + p +=3 ; + }else if (strncmp (p,"0x" ,2 ) ==0 ) { + *iotype =UPIO_MEM ; + }else { +return -EINVAL ; + } + + *addr =simple_strtoul (p,NULL ,0 );
WARNING: simple_strtoul is obsolete, use kstrtoul instead #136: FILE: drivers/tty/serial/serial_core.c:1848:
+ *addr = simple_strtoul(p, NULL, 0);
simple_strtoul() is _not_ obsolete.kstrtoul() cannot parse the <addr> field in a string of the form:
console=<name>,io|mmio|mmio32,<addr>,<options>
kstrtoul() returns EINVAL without the result.
It was pretty fun debugging that without a console :/
Regards,
Peter Hurley
Quoted 27 lines
drivers/tty/serial/serial_core.c +10
-0+ p =strchr (p,',' ); +if (p) + p++; + + *options = p; +return 0 ; +} +EXPORT_SYMBOL_GPL (uart_parse_earlycon); + +/** * uart_parse_options - Parse serial port baud/parity/bits/flow control. * @options: pointer to option string * @baud: pointer to an 'int' variable for the baud rate. include/linux/serial_core.h +2
-0@@ -354,6 +354,8 @@ early_param("earlycon", name ## _setup_earlycon);struct uart_port *uart_get_console (struct uart_port *ports,int nr,struct console *c); +int uart_parse_earlycon (char *p,unsigned char *iotype,unsigned long *addr, +char **options);void uart_parse_options (char *options,int *baud,int *parity,int *bits,int *flow); int uart_set_options(struct uart_port *port, struct console *co, int baud,
PATCH 2/13 console: Preserve index after console setup()
In reply to Peter HurleyBefore register_console() calls the setup() method of the matched console, the registering console index is already equal to the index from the console command line; ie. newcon->index == c->index.
This change is also required to support extensible console matching; (the command line index may have no relation to the console index assigned by the console-defined match() function).
--- kernel/printk/printk.c | 1 - 1 file changed, 1 deletion(-)
kernel/printk/printk.c +0 -1
@@ -2479,7 +2479,6 @@ void register_console(struct console *newcon) newcon->setup(newcon, console_cmdline[i].options) != 0)break ; newcon->flags |=CON_ENABLED ; - newcon->index = c->index;if (i == selected_console) { newcon->flags |=CON_CONSDEV ; preferred_console = selected_console;
Signature · 1 line
2.3.0
PATCH 3/13 console: Add extensible console matching
In reply to Peter HurleyAdd match() method to struct console which allows the console to perform console command line matching instead of (or in addition to) default console matching (ie., by fixed name and index).
The match() method returns 0 to indicate a successful match; normal console matching occurs if no match() method is defined or the match() method returns non-zero. The match() method is expected to set the console index if required.
Re-implement earlycon-to-console-handoff with direct matching of "console=uart|uart8250,..." to the 8250 ttyS console.
--- drivers/tty/serial/8250/8250_core.c | 64 +++++++++++++++++++++++++++--------- drivers/tty/serial/8250/8250_early.c | 23 ------------- include/linux/console.h | 3 +- include/linux/serial_8250.h | 2 -- kernel/printk/printk.c | 50 ++++++++++------------------ 5 files changed, 66 insertions(+), 76 deletions(-)
drivers/tty/serial/8250/8250_core.c +48 -16
@@ -3337,9 +3337,54 @@ static int serial8250_console_setup(struct console *co, char *options)return uart_set_options (port, co, baud, parity, bits, flow); } -static int serial8250_console_early_setup (void ) +/** +* serial8250_console_match - non-standard console matching +* @co: registering console +* @name: name from console command line +* @idx: index from console command line +* @options: ptr to option string from console command line +* +* Only attempts to match console command lines of the form: +* console=uart<>,io|mmio|mmio32,<addr>,<options> +* console=uart<>,<addr>,options +* This form is used to register an initial earlycon boot console and +* replace it with the serial8250_console at 8250 driver init. +* +* Performs console setup for a match (as required by interface) +* +* Returns 0 if console matches; otherwise non-zero to use default matching +*/ +static int serial8250_console_match (struct console *co,char *name,int idx, +char *options) { -return serial8250_find_port_for_earlycon (); +char match[] ="uart" ;/* 8250-specific earlycon name */ +unsigned char iotype; +unsigned long addr; +int i; + +if (strncmp (name, match,4 ) !=0 ) +return -ENODEV ; + +if (uart_parse_earlycon (options, &iotype, &addr, &options)) +return -ENODEV ; + +/* try to match the port specified on the command line */ +for (i =0 ; i < nr_uarts; i++) { +struct uart_port *port = &serial8250_ports[i].port; + +if (port->iotype != iotype) +continue ; +if ((iotype ==UPIO_MEM || iotype ==UPIO_MEM32 ) && + (port->mapbase != addr)) +continue ; +if (iotype ==UPIO_PORT && port->iobase != addr) +continue ; + + co->index = i; +return serial8250_console_setup (co, options); + } + +return -ENODEV ; }static struct console serial8250_console = {
@@ -3347,7 +3392,7 @@ static struct console serial8250_console = { .write = serial8250_console_write, .device = uart_console_device, .setup = serial8250_console_setup, - .early_setup = serial8250_console_early_setup, + .match = serial8250_console_match, .flags = CON_PRINTBUFFER | CON_ANYTIME, .index = -1, .data = &serial8250_reg,
@@ -3361,19 +3406,6 @@ static int __init serial8250_console_init(void) }console_initcall (serial8250_console_init); -int serial8250_find_port (struct uart_port *p) -{ -int line; -struct uart_port *port; - -for (line =0 ; line < nr_uarts; line++) { - port = &serial8250_ports[line].port; -if (uart_match_port (p, port)) -return line; - } -return -ENODEV ; -} -#define SERIAL8250_CONSOLE &serial8250_console#else #define SERIAL8250_CONSOLE NULL
drivers/tty/serial/8250/8250_early.c +0 -23
@@ -173,26 +173,3 @@ int __init setup_early_serial8250_console(char *cmdline)return setup_earlycon (cmdline, match, early_serial8250_setup); } - -int serial8250_find_port_for_earlycon (void ) -{ -struct earlycon_device *device = early_device; -struct uart_port *port = device ? &device->port :NULL ; -int line; -int ret; - -if (!port || (!port->membase && !port->iobase)) -return -ENODEV ; - - line =serial8250_find_port (port); -if (line <0 ) -return -ENODEV ; - - 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; -}
include/linux/console.h +1 -2
@@ -123,7 +123,7 @@ struct console {struct tty_driver *(*device)(struct console *,int *);void (*unblank)(void );int (*setup)(struct console *,char *); -int (*early_setup)(void ); +int (*match)(struct console *,char *name,int idx,char *options);short flags;short index;int cflag;
@@ -141,7 +141,6 @@ extern int console_set_on_cmdline;extern struct console *early_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_8250.h +0 -2
@@ -118,8 +118,6 @@ void serial8250_resume_port(int line);extern int early_serial_setup (struct uart_port *port); -extern int serial8250_find_port (struct uart_port *p); -extern int serial8250_find_port_for_earlycon (void );extern unsigned int serial8250_early_in (struct uart_port *port,int offset);extern void serial8250_early_out (struct uart_port *port,int offset,int value);extern int setup_early_serial8250_console (char *cmdline);
kernel/printk/printk.c +17 -33
70 lines not on this page · raw message
Signature · 1 line
2.3.0
Re: [PATCH -next 03/13] console: Add extensible console matching
Quoted 216 lines · Peter Hurley
Add
match()method to struct console which allows the console to perform console command line matching instead of (or in addition to) default console matching (ie., by fixed name and index).The
match()method returns 0 to indicate a successful match; normal console matching occurs if nomatch()method is defined or thematch()method returns non-zero. Thematch()method is expected to set the console index if required.Re-implement earlycon-to-console-handoff with direct matching of "console=uart|uart8250,..." to the 8250 ttyS console.
Signed-off-by Peter Hurley <[email protected]>--- drivers/tty/serial/8250/8250_core.c | 64 +++++++++++++++++++++++++++--------- drivers/tty/serial/8250/8250_early.c | 23 ------------- include/linux/console.h | 3 +- include/linux/serial_8250.h | 2 -- kernel/printk/printk.c | 50 ++++++++++------------------ 5 files changed, 66 insertions(+), 76 deletions(-)drivers/tty/serial/8250/8250_core.c +48
-16@@ -3337,9 +3337,54 @@ static int serial8250_console_setup(struct console *co, char *options)return uart_set_options (port, co, baud, parity, bits, flow); } -static int serial8250_console_early_setup (void ) +/** +* serial8250_console_match - non-standard console matching +* @co: registering console +* @name: name from console command line +* @idx: index from console command line +* @options: ptr to option string from console command line +* +* Only attempts to match console command lines of the form: +* console=uart<>,io|mmio|mmio32,<addr>,<options> +* console=uart<>,<addr>,options +* This form is used to register an initial earlycon boot console and +* replace it with the serial8250_console at 8250 driver init. +* +* Performs console setup for a match (as required by interface) +* +* Returns 0 if console matches; otherwise non-zero to use default matching +*/ +static int serial8250_console_match (struct console *co,char *name,int idx, +char *options) { -return serial8250_find_port_for_earlycon (); +char match[] ="uart" ;/* 8250-specific earlycon name */ +unsigned char iotype; +unsigned long addr; +int i; + +if (strncmp (name, match,4 ) !=0 ) +return -ENODEV ; + +if (uart_parse_earlycon (options, &iotype, &addr, &options)) +return -ENODEV ; + +/* try to match the port specified on the command line */ +for (i =0 ; i < nr_uarts; i++) { +struct uart_port *port = &serial8250_ports[i].port; + +if (port->iotype != iotype) +continue ; +if ((iotype ==UPIO_MEM || iotype ==UPIO_MEM32 ) && + (port->mapbase != addr)) +continue ; +if (iotype ==UPIO_PORT && port->iobase != addr) +continue ; + + co->index = i; +return serial8250_console_setup (co, options); + } + +return -ENODEV ; }static struct console serial8250_console = {@@ -3347,7 +3392,7 @@ static struct console serial8250_console = { .write = serial8250_console_write, .device = uart_console_device, .setup = serial8250_console_setup, - .early_setup = serial8250_console_early_setup, + .match = serial8250_console_match, .flags = CON_PRINTBUFFER | CON_ANYTIME, .index = -1, .data = &serial8250_reg,@@ -3361,19 +3406,6 @@ static int __init serial8250_console_init(void) }console_initcall (serial8250_console_init); -int serial8250_find_port (struct uart_port *p) -{ -int line; -struct uart_port *port; - -for (line =0 ; line < nr_uarts; line++) { - port = &serial8250_ports[line].port; -if (uart_match_port (p, port)) -return line; - } -return -ENODEV ; -} -#define SERIAL8250_CONSOLE &serial8250_console#else #define SERIAL8250_CONSOLE NULLdrivers/tty/serial/8250/8250_early.c +0
-23@@ -173,26 +173,3 @@ int __init setup_early_serial8250_console(char *cmdline)return setup_earlycon (cmdline, match, early_serial8250_setup); } - -int serial8250_find_port_for_earlycon (void ) -{ -struct earlycon_device *device = early_device; -struct uart_port *port = device ? &device->port :NULL ; -int line; -int ret; - -if (!port || (!port->membase && !port->iobase)) -return -ENODEV ; - - line =serial8250_find_port (port); -if (line <0 ) -return -ENODEV ; - - 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; -}include/linux/console.h +1
-2@@ -123,7 +123,7 @@ struct console {struct tty_driver *(*device)(struct console *,int *);void (*unblank)(void );int (*setup)(struct console *,char *); -int (*early_setup)(void ); +int (*match)(struct console *,char *name,int idx,char *options);short flags;short index;int cflag;@@ -141,7 +141,6 @@ extern int console_set_on_cmdline;extern struct console *early_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_8250.h +0
-2@@ -118,8 +118,6 @@ void serial8250_resume_port(int line);extern int early_serial_setup (struct uart_port *port); -extern int serial8250_find_port (struct uart_port *p); -extern int serial8250_find_port_for_earlycon (void );extern unsigned int serial8250_early_in (struct uart_port *port,int offset);extern void serial8250_early_out (struct uart_port *port,int offset,int value);extern int setup_early_serial8250_console (char *cmdline);kernel/printk/printk.c +0
-21@@ -2017,24 +2017,6 @@ int add_preferred_console(char *name, int idx, char *options)return __add_preferred_console (name, idx, options,NULL ); } -int update_console_cmdline (char *name,int idx,char *name_new,int idx_new,char *options) -{ -struct console_cmdline *c; -int i; - -for (i =0 , c = console_cmdline; - i <MAX_CMDLINECONSOLES && c->name[0 ]; - i++, c++) -if (strcmp (c->name, name) ==0 && c->index == idx) { -strlcpy (c->name, name_new,sizeof (c->name)); - c->options = options; - c->index = idx_new; -return i; - } -/* not found */ -return -1 ; -} -bool console_suspend_enabled = true;EXPORT_SYMBOL (console_suspend_enabled);@@ -2436,9 +2418,6 @@ void register_console(struct console *newcon)if (preferred_console <0 || bcon || !console_drivers) preferred_console = selected_console; -if (newcon->early_setup) - newcon->early_setup (); -/* * See if we want to use this console driver. If we * didn't select a console we take the first one
kernel/printk/printk.c void register_console(struct console *newcon) · line 2468
Quoted 5 lines
kernel/printk/printk.c +0
-2@@ -2464,20 +2443,25 @@ void register_console(struct console *newcon)for (i =0 , c = console_cmdline; i <MAX_CMDLINECONSOLES && c->name[0 ]; i++, c++) { -if (strcmp (c->name, newcon->name) !=0 ) -continue ;
Andrew,
I just discovered that struct console_cmdline::name[] and struct console::name[] are not the same size, which is a bug that should probably go into -stable.
I'll respin a v2 of this series on top of that bug fix, which I'll send shortly.
Regards,
Peter Hurley
Quoted 33 lines
kernel/printk/printk.c +17
-10-if (newcon->index >=0 && - newcon->index != c->index) -continue ; -if (newcon->index <0 ) - newcon->index = c->index; +if (!newcon->match || + newcon->match (newcon, c->name, c->index, c->options) !=0 ) { +/* default matching */ +if (strcmp (c->name, newcon->name) !=0 ) +continue ; +if (newcon->index >=0 && + newcon->index != c->index) +continue ; +if (newcon->index <0 ) + newcon->index = c->index; -if (_braille_register_console (newcon, c)) -return ; +if (_braille_register_console (newcon, c)) +return ; + +if (newcon->setup && + newcon->setup (newcon, c->options) !=0 ) +break ; + } -if (newcon->setup && - newcon->setup (newcon, console_cmdline[i].options) !=0 ) -break ; newcon->flags |=CON_ENABLED ;if (i == selected_console) { newcon->flags |=CON_CONSDEV ;
PATCH 4/13 serial: core: Fix kernel doc for uart_console_write()
In reply to Peter Hurley'/**' is required to start a kernel-doc comment block.
--- drivers/tty/serial/serial_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/serial_core.c +1 -1
@@ -1766,7 +1766,7 @@ static const struct file_operations uart_proc_fops = {#endif #if defined(CONFIG_SERIAL_CORE_CONSOLE ) || defined(CONFIG_CONSOLE_POLL ) -/* +/** * uart_console_write - write a console message to a serial port * @port: the port to write the message * @s: array of characters
Signature · 1 line
2.3.0
PATCH 5/13 serial: 8250_early: Remove early_device variable
In reply to Peter Hurleyearly_device was only required for serial8250_find_port_for_earlycon(), which was replaced by extensible console matching.
Fixup early_serial8250_write() to get the earlycon_device * from console->data (which is initialized by {of_}setup_earlycon()).
--- drivers/tty/serial/8250/8250_early.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/tty/serial/8250/8250_early.c +2 -4
@@ -36,8 +36,6 @@#include <asm/io.h> #include <asm/serial.h> -static struct earlycon_device *early_device; -unsigned int __weak __init serial8250_early_in (struct uart_port *port,int offset) {switch (port->iotype) {
@@ -90,7 +88,8 @@ static void __init serial_putc(struct uart_port *port, int c)static void __init early_serial8250_write (struct console *console,const char *s,unsigned int count) { -struct uart_port *port = &early_device->port; +struct earlycon_device *device = console->data; +struct uart_port *port = &device->port;unsigned int ier;/* Save the IER and disable interrupts preserving the UUE bit */
@@ -157,7 +156,6 @@ static int __init early_serial8250_setup(struct earlycon_device *device,init_port (device); - early_device = device; device->con->write = early_serial8250_write;return 0 ; }
Signature · 1 line
2.3.0
PATCH 6/13 serial: earlycon: Move ->uartclk initialize
In reply to Peter HurleyInitializing the ->uartclk field is not related to option parsing; relocate from parse_options() to setup_earlycon() (which mirrors the behavior of of_setup_earlycon()).
--- drivers/tty/serial/earlycon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/tty/serial/earlycon.c +1 -2
@@ -76,8 +76,6 @@ static int __init parse_options(struct earlycon_device *device, char *options)return -EINVAL ; } - port->uartclk =BASE_BAUD *16 ; -if (options) { device->baud =simple_strtoul (options,NULL ,0 ); length = min(strcspn(options, " ") + 1,
@@ -121,6 +119,7 @@ int __init setup_earlycon(char *buf, const char *match,if (!err) buf =NULL ; + port->uartclk =BASE_BAUD *16 ;if (port->mapbase) port->membase =earlycon_map (port->mapbase,64 );
Signature · 1 line
2.3.0
PATCH 7/13 serial: 8250_early: Assume uart already initialized if no baud option
In reply to Peter HurleyThe <baud><parity><bit> option string is not supplied if the earlycon is started via devicetree and OF_EARLYCON_DECLARE(). The option string is also not required if started via kernel command line parameters of the form:
earlycon=uart,mmio,<addr>
console=uart,mmio,<addr>
If earlycon_device->baud is 0, then an option string was not supplied. In this case, assume the uart has already been initialized by the bootloader or firmware.
--- drivers/tty/serial/8250/8250_early.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_early.c +8 -2
@@ -149,12 +149,18 @@ static int __init early_serial8250_setup(struct earlycon_device *device,return 0 ;if (!device->baud) { +struct uart_port *port = &device->port; +unsigned int ier; + device->baud =probe_baud (&device->port);snprintf (device->options,sizeof (device->options),"%u" , device->baud); - } -init_port (device); +/* assume the device was initialized, only mask interrupts */ + ier =serial8250_early_in (port,UART_IER ); +serial8250_early_out (port,UART_IER , ier &UART_IER_UUE ); + }else +init_port (device); device->con->write = early_serial8250_write;return 0 ;
Signature · 1 line
2.3.0
PATCH 8/13 serial: 8250_early: Fix setup() error code
In reply to Peter HurleyIf parsing failed to decode a valid uart addr, return -ENODEV instead of success. Although setup_earlycon() will detect the failure anyway (because the write() method has not been set), that behavior is not obvious and should not be relied on.
--- drivers/tty/serial/8250/8250_early.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/8250/8250_early.c +1 -1
@@ -146,7 +146,7 @@ static int __init early_serial8250_setup(struct earlycon_device *device, const char *options) {if (!(device->port.membase || device->port.iobase)) -return 0 ; +return -ENODEV ;if (!device->baud) {struct uart_port *port = &device->port;
Signature · 1 line
2.3.0
PATCH 9/13 serial: earlycon: Ignore parse_options() error code
In reply to Peter HurleyBecause setup_earlycon() continues to attempt console registration if an error occurred parsing the option string, the actual value of the error code from parse_options() is ignored.
--- drivers/tty/serial/earlycon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/tty/serial/earlycon.c +1 -2
@@ -114,9 +114,8 @@ int __init setup_earlycon(char *buf, const char *match, buf += len +1 ; - err =parse_options (&early_console_dev, buf);/* On parsing error, pass the options buf to the setup function */ -if (!err) +if (!parse_options (&early_console_dev, buf)) buf =NULL ; port->uartclk =BASE_BAUD *16 ;
Signature · 1 line
2.3.0
PATCH 10/13 serial: earlycon: Allow earlycon params with name only
In reply to Peter HurleyAllow earlycon param strings of the form
earlycon=<name>
--- drivers/tty/serial/earlycon.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/tty/serial/earlycon.c +7 -4
@@ -109,13 +109,16 @@ int __init setup_earlycon(char *buf, const char *match, len =strlen (match);if (strncmp (buf, match, len))return 0 ; -if (buf[len] && (buf[len] !=',' )) -return 0 ; - buf += len +1 ; +if (buf[len]) { +if (buf[len] !=',' ) +return 0 ; + buf += len +1 ; + }else + buf =NULL ;/* On parsing error, pass the options buf to the setup function */ -if (!parse_options (&early_console_dev, buf)) +if (buf && !parse_options (&early_console_dev, buf)) buf =NULL ; port->uartclk =BASE_BAUD *16 ;
Signature · 1 line
2.3.0
PATCH 11/13 serial: earlycon: Refactor earlycon registration
In reply to Peter HurleySeparate earlycon matching from registration; add register_earlycon which initializes and registers the matched earlycon.
--- drivers/tty/serial/earlycon.c | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-)
drivers/tty/serial/earlycon.c +25 -17
@@ -96,27 +96,13 @@ static int __init parse_options(struct earlycon_device *device, char *options)return 0 ; } -int __init setup_earlycon (char *buf,const char *match, -int (*setup)(struct earlycon_device *,const char *)) + +static int __init +register_earlycon (char *buf,int (*setup)(struct earlycon_device *,const char *)) {int err; -size_t len;struct uart_port *port = &early_console_dev.port; -if (!buf || !match || !setup) -return 0 ; - - len =strlen (match); -if (strncmp (buf, match, len)) -return 0 ; - -if (buf[len]) { -if (buf[len] !=',' ) -return 0 ; - buf += len +1 ; - }else - buf =NULL ; -/* On parsing error, pass the options buf to the setup function */ if (buf && !parse_options (&early_console_dev, buf)) buf =NULL ;
@@ -136,6 +122,28 @@ int __init setup_earlycon(char *buf, const char *match,return 0 ; } +int __init setup_earlycon (char *buf,const char *match, +int (*setup)(struct earlycon_device *,const char *)) +{ +size_t len; + +if (!buf || !match || !setup) +return 0 ; + + len =strlen (match); +if (strncmp (buf, match, len)) +return 0 ; + +if (buf[len]) { +if (buf[len] !=',' ) +return 0 ; + buf += len +1 ; + }else + buf =NULL ; + +return register_earlycon (buf, setup); +} +int __init of_setup_earlycon (unsigned long addr,int (*setup)(struct earlycon_device *,const char *)) {
Signature · 1 line
2.3.0
PATCH 12/13 serial: earlycon: Enable earlycon without command line param
In reply to Peter HurleyEarlycon matching can only be triggered if 'earlycon=...' has been specified on the kernel command line. To workaround this limitation requires tight coupling between arches and specific serial drivers in order to start an earlycon. Devicetree avoids this limitation with a link table that contains the required data to match earlycons.
Mirror this approach for earlycon match by name. Re-purpose EARLYCON_DECLARE to generate a table entry which associates name with setup() function. Re-purpose setup_earlycon() to scan this table for an earlycon match, which is registered if found.
Declare one "earlycon" early_param, which calls setup_earlycon().
This design allows setup_earlycon() to be called directly with a param string (as if 'earlycon=...' had been set on the command line). Re-registration (either directly or by early_param) is prevented.
--- drivers/tty/serial/8250/8250_early.c | 7 +-- drivers/tty/serial/earlycon.c | 92 ++++++++++++++++++++++++++++-------- include/asm-generic/vmlinux.lds.h | 9 ++++ include/linux/serial_core.h | 19 ++++---- 4 files changed, 94 insertions(+), 33 deletions(-)
drivers/tty/serial/8250/8250_early.c +1 -6
@@ -170,10 +170,5 @@ EARLYCON_DECLARE(uart, early_serial8250_setup);int __init setup_early_serial8250_console (char *cmdline) { -char match[] ="uart8250" ; - -if (cmdline && cmdline[4 ] ==',' ) - match[4 ] ='\0' ; - -return setup_earlycon (cmdline, match, early_serial8250_setup); +return setup_earlycon (cmdline); }
drivers/tty/serial/earlycon.c +73 -19
128 lines not on this page · raw message
include/asm-generic/vmlinux.lds.h +9 -0
@@ -150,6 +150,14 @@#define TRACE_SYSCALLS ()#endif +#ifdef CONFIG_SERIAL_EARLYCON +#define EARLYCON_TABLE () . = ALIGN(8); \ + VMLINUX_SYMBOL(__earlycon_table) = .; \ + *(__earlycon_table) \ + *(__earlycon_table_end) +#else +#define EARLYCON_TABLE () +#endif #define ___OF_TABLE (cfg, name) _OF_TABLE_##cfg(name)#define __OF_TABLE (cfg, name) ___OF_TABLE(cfg, name)
@@ -502,6 +510,7 @@ CPU_METHOD_OF_TABLES() \ KERNEL_DTB() \ IRQCHIP_OF_MATCH_TABLE() \ + EARLYCON_TABLE() \ EARLYCON_OF_TABLES()#define INIT_TEXT \
include/linux/serial_core.h +11 -8
@@ -336,18 +336,21 @@ struct earlycon_device {char options[16 ];/* e.g., 115200n8 */ unsigned int baud; }; -int setup_earlycon (char *buf,const char *match, -int (*setup)(struct earlycon_device *,const char *)); +struct earlycon_id { +char name[16 ]; +int (*setup)(struct earlycon_device *,const char *options); +}; + +extern int setup_earlycon (char *buf);extern int of_setup_earlycon (unsigned long addr,int (*setup)(struct earlycon_device *,const char *)); -#define EARLYCON_DECLARE (name, func) \ -static int __init name ## _setup_earlycon(char *buf) \ -{ \ - return setup_earlycon(buf, __stringify(name), func); \ -} \ -early_param("earlycon", name ## _setup_earlycon); +#define EARLYCON_DECLARE (_name, func) \ + static const struct earlycon_id __earlycon_##_name \ + __used __section(__earlycon_table) \ + = { .name = __stringify(_name), \ + .setup = func }#define OF_EARLYCON_DECLARE (name, compat, fn) \ _OF_DECLARE(earlycon, name, compat, fn, void *)
Signature · 1 line
2.3.0
PATCH 13/13 serial: 8250_early: Remove setup_early_serial8250_console()
In reply to Peter Hurleysetup_earlycon() will now match and register the desired earlycon from the param string (as if 'earlycon=...' had been set on the command line). Use setup_earlycon() from existing arch call sites which start an earlycon directly.
--- arch/mips/mti-malta/malta-init.c | 4 ++-- drivers/firmware/pcdp.c | 4 ++-- drivers/tty/serial/8250/8250_early.c | 5 ----- include/linux/serial_8250.h | 1 - 4 files changed, 4 insertions(+), 10 deletions(-)
arch/mips/mti-malta/malta-init.c +2 -2
@@ -14,7 +14,7 @@#include <linux/init.h> #include <linux/string.h> #include <linux/kernel.h> -#include <linux/serial_8250.h> +#include <linux/serial_core.h> #include <asm/cacheflush.h> #include <asm/smp-ops.h>
@@ -75,7 +75,7 @@ static void __init console_config(void)if ((strstr (fw_getcmdline (),"earlycon=" )) ==NULL ) {sprintf (console_string,"uart8250,io,0x3f8,%d%c%c" , baud, parity, bits); -setup_early_serial8250_console (console_string); +setup_earlycon (console_string); }if ((strstr (fw_getcmdline (),"console=" )) ==NULL ) {
drivers/firmware/pcdp.c +2 -2
@@ -15,7 +15,7 @@#include <linux/console.h> #include <linux/efi.h> #include <linux/serial.h> -#include <linux/serial_8250.h> +#include <linux/serial_core.h> #include <asm/vga.h> #include "pcdp.h"
@@ -43,7 +43,7 @@ setup_serial_console(struct pcdp_uart *uart) }add_preferred_console ("uart" ,8250 , &options[9 ]); -return setup_early_serial8250_console (options); +return setup_earlycon (options);#else return -ENODEV ;#endif
drivers/tty/serial/8250/8250_early.c +0 -5
@@ -167,8 +167,3 @@ static int __init early_serial8250_setup(struct earlycon_device *device, }EARLYCON_DECLARE (uart8250, early_serial8250_setup);EARLYCON_DECLARE (uart, early_serial8250_setup); - -int __init setup_early_serial8250_console (char *cmdline) -{ -return setup_earlycon (cmdline); -}
include/linux/serial_8250.h +0 -1
@@ -120,7 +120,6 @@ extern int early_serial_setup(struct uart_port *port);extern unsigned int serial8250_early_in (struct uart_port *port,int offset);extern void serial8250_early_out (struct uart_port *port,int offset,int value); -extern int setup_early_serial8250_console (char *cmdline);extern void serial8250_do_set_termios (struct uart_port *port,struct ktermios *termios,struct ktermios *old);extern int serial8250_do_startup (struct uart_port *port);
Signature · 1 line
2.3.0
Quoted 46 lines · Peter Hurley
Hi Greg & Andrew,
This patch series implements:
1. console-definable (aka extensible) matching
2. generic earlycon-to-console handoff via extensible matching
3.arch/promsupport for direct earlyconExtensible console matching
Extensible console matching enables the console itself to define the conditions for a "command line" match. This mimics the design of device matching in the driver model. Two important use-cases which this feature enables are generic earlycon-to-console handoff and support for driver migration.
Earlycon-to-console handoff was implemented in 2007. Console command lines of the form:
console=uart,io,0x3f8,115200n8start an earlycon and later allow the 8250 driver console to takeover. Unfortunately this implementation requires direct coupling between the earlycon and the console and is facilitated by ugly hacks like editing the console command line in-place.
Extensible console matching allows the 8250 driver to directly match that console command line instead, and enables other serial drivers to trivially support console handoff themselves.
In addition, extensible console matching allows a new driver to provide support for a different driver's console. This requirement stems from needing to minimize breakage when migrating serial drivers. Since many devices are based on the original 8250/16550 designs but sometimes have features incompatible with the existing 8250 driver support, the initial driver is often standalone. When/if the standalone driver is migrated to the 8250 driver, the problem of console names in the command line remains. Extensible console matching enables a simple migration path.
Direct earlycon
This feature enables arches and proms to start an earlycon directly, rather than requiring an "earlycon=" command line parameter. Devicetree can already do this via the 'linux,stdout-path' property, but arch and prom code requires direct coupling to the serial driver.
Quoted 4 lines
This support is implemented by judicious refactoring and the same construct that devicetree and
early_paramuse: a link table containing the necessary information (name andsetup()function) to find and bind the appropriate earlycon "driver".
I've skimmed thru this and it looks like a great improvement.
One problem we have currently with DT stdout-path and earlycon is a preferred console does not get registered, so the console will get switched to tty0 and you lose your console. The problem is DT does not know the console name to register a preferred console. It looks like this series may help this problem, but I'm not sure and wanted your thoughts.
Rob
Hi Rob,
Quoted 52 lines · Rob Herring
Quoted 46 lines · Peter Hurley
Hi Greg & Andrew,
This patch series implements:
1. console-definable (aka extensible) matching
2. generic earlycon-to-console handoff via extensible matching
3.arch/promsupport for direct earlyconExtensible console matching
Extensible console matching enables the console itself to define the conditions for a "command line" match. This mimics the design of device matching in the driver model. Two important use-cases which this feature enables are generic earlycon-to-console handoff and support for driver migration.
Earlycon-to-console handoff was implemented in 2007. Console command lines of the form:
console=uart,io,0x3f8,115200n8start an earlycon and later allow the 8250 driver console to takeover. Unfortunately this implementation requires direct coupling between the earlycon and the console and is facilitated by ugly hacks like editing the console command line in-place.
Extensible console matching allows the 8250 driver to directly match that console command line instead, and enables other serial drivers to trivially support console handoff themselves.
In addition, extensible console matching allows a new driver to provide support for a different driver's console. This requirement stems from needing to minimize breakage when migrating serial drivers. Since many devices are based on the original 8250/16550 designs but sometimes have features incompatible with the existing 8250 driver support, the initial driver is often standalone. When/if the standalone driver is migrated to the 8250 driver, the problem of console names in the command line remains. Extensible console matching enables a simple migration path.
Direct earlycon
This feature enables arches and proms to start an earlycon directly, rather than requiring an "earlycon=" command line parameter. Devicetree can already do this via the 'linux,stdout-path' property, but arch and prom code requires direct coupling to the serial driver.
Quoted 4 lines
This support is implemented by judicious refactoring and the same construct that devicetree and
early_paramuse: a link table containing the necessary information (name andsetup()function) to find and bind the appropriate earlycon "driver".
Quoted 8 lines
I've skimmed thru this and it looks like a great improvement.
One problem we have currently with DT stdout-path and earlycon is a preferred console does not get registered, so the console will get switched to tty0 and you lose your console. The problem is DT does not know the console name to register a preferred console. It looks like this series may help this problem, but I'm not sure and wanted your thoughts.
I thought that of_alias_scan() + of_console_check() caused DT stdout-path to add_preferred_console() the driver console @ port registration time via uart_add_one_port() -> of_console_check().
Is that not how that works?
Regards,
Peter Hurley
Quoted 64 lines · Peter Hurley
Hi Rob,
Quoted 52 lines · Rob Herring
Quoted 46 lines · Peter Hurley
Hi Greg & Andrew,
This patch series implements:
1. console-definable (aka extensible) matching
2. generic earlycon-to-console handoff via extensible matching
3.arch/promsupport for direct earlyconExtensible console matching
Extensible console matching enables the console itself to define the conditions for a "command line" match. This mimics the design of device matching in the driver model. Two important use-cases which this feature enables are generic earlycon-to-console handoff and support for driver migration.
Earlycon-to-console handoff was implemented in 2007. Console command lines of the form:
console=uart,io,0x3f8,115200n8start an earlycon and later allow the 8250 driver console to takeover. Unfortunately this implementation requires direct coupling between the earlycon and the console and is facilitated by ugly hacks like editing the console command line in-place.
Extensible console matching allows the 8250 driver to directly match that console command line instead, and enables other serial drivers to trivially support console handoff themselves.
In addition, extensible console matching allows a new driver to provide support for a different driver's console. This requirement stems from needing to minimize breakage when migrating serial drivers. Since many devices are based on the original 8250/16550 designs but sometimes have features incompatible with the existing 8250 driver support, the initial driver is often standalone. When/if the standalone driver is migrated to the 8250 driver, the problem of console names in the command line remains. Extensible console matching enables a simple migration path.
Direct earlycon
This feature enables arches and proms to start an earlycon directly, rather than requiring an "earlycon=" command line parameter. Devicetree can already do this via the 'linux,stdout-path' property, but arch and prom code requires direct coupling to the serial driver.
Quoted 4 lines
This support is implemented by judicious refactoring and the same construct that devicetree and
early_paramuse: a link table containing the necessary information (name andsetup()function) to find and bind the appropriate earlycon "driver".Quoted 8 lines
I've skimmed thru this and it looks like a great improvement.
One problem we have currently with DT stdout-path and earlycon is a preferred console does not get registered, so the console will get switched to tty0 and you lose your console. The problem is DT does not know the console name to register a preferred console. It looks like this series may help this problem, but I'm not sure and wanted your thoughts.
Quoted 5 lines
I thought that
of_alias_scan()+of_console_check()caused DT stdout-path toadd_preferred_console()the driver console @ port registration time viauart_add_one_port()->of_console_check().Is that not how that works?
Yes, I believe that is how it works with earlycon not enabled. This doesn't work when earlycon is enabled with just "earlycon" on the command line. The fix I have is here[1], but I don't like putting DT specifics into the console code.
Rob
Hi Rob,
Quoted 1 line · Rob Herring
On Tue, Feb 24, 2015 at 1:53 PM, Peter Hurley <[email protected]> wrote:
[...]
Quoted 25 lines
Quoted 25 lines
Quoted 12 lines
Quoted 11 lines
Direct earlycon
This feature enables arches and proms to start an earlycon directly, rather than requiring an "earlycon=" command line parameter. Devicetree can already do this via the 'linux,stdout-path' property, but arch and prom code requires direct coupling to the serial driver.
This support is implemented by judicious refactoring and the same construct that devicetree and
early_paramuse: a link table containing the necessary information (name andsetup()function) to find and bind the appropriate earlycon "driver".Quoted 8 lines
I've skimmed thru this and it looks like a great improvement.
One problem we have currently with DT stdout-path and earlycon is a preferred console does not get registered, so the console will get switched to tty0 and you lose your console. The problem is DT does not know the console name to register a preferred console. It looks like this series may help this problem, but I'm not sure and wanted your thoughts.
I thought that
of_alias_scan()+of_console_check()caused DT stdout-path toadd_preferred_console()the driver console @ port registration time viauart_add_one_port()->of_console_check().
Quoted 6 lines
Quoted 1 line
Is that not how that works?
Yes, I believe that is how it works with earlycon not enabled. This doesn't work when earlycon is enabled with just "earlycon" on the command line. The fix I have is here[1], but I don't like putting DT specifics into the console code.
After much gnashing of teeth and pulling of hair yesterday, I managed to mock up the situation you describe, but I need to study it in more detail. Some things I did learn:
1. The serial console _does_ come back up when using stdout-path but the line settings don't match, because the serial core sets them to the default of 9600n8 if unspecified.
2. The line settings can now be set with stdout-path like,
stdout-path = "serial0:115200n8"
but this breaks DT earlycon (as I wrote in the other email you were cc'd on).
3. omap doesn't support ioremap() at early param parsing :(
4. the ARM arch doesn't support fixmap hacking at early param parsing :(
Regards,
Peter Hurley
Quoted 39 lines · Peter Hurley
Hi Rob,
Quoted 1 line · Rob Herring
On Tue, Feb 24, 2015 at 1:53 PM, Peter Hurley <[email protected]> wrote:
[...]
Quoted 25 lines
Quoted 25 lines
Quoted 12 lines
Quoted 11 lines
Direct earlycon
This feature enables arches and proms to start an earlycon directly, rather than requiring an "earlycon=" command line parameter. Devicetree can already do this via the 'linux,stdout-path' property, but arch and prom code requires direct coupling to the serial driver.
This support is implemented by judicious refactoring and the same construct that devicetree and
early_paramuse: a link table containing the necessary information (name andsetup()function) to find and bind the appropriate earlycon "driver".Quoted 8 lines
I've skimmed thru this and it looks like a great improvement.
One problem we have currently with DT stdout-path and earlycon is a preferred console does not get registered, so the console will get switched to tty0 and you lose your console. The problem is DT does not know the console name to register a preferred console. It looks like this series may help this problem, but I'm not sure and wanted your thoughts.
I thought that
of_alias_scan()+of_console_check()caused DT stdout-path toadd_preferred_console()the driver console @ port registration time viauart_add_one_port()->of_console_check().Quoted 6 lines
Quoted 1 line
Is that not how that works?
Yes, I believe that is how it works with earlycon not enabled. This doesn't work when earlycon is enabled with just "earlycon" on the command line. The fix I have is here[1], but I don't like putting DT specifics into the console code.
Quoted 7 lines
After much gnashing of teeth and pulling of hair yesterday, I managed to mock up the situation you describe, but I need to study it in more detail. Some things I did learn:
1. The serial console _does_ come back up when using stdout-path but the line settings don't match, because the serial core sets them to the default of 9600n8 if unspecified.
That may have been what I saw as I tested on QEMU which ignores the baud rate. But it does stop between the time tty0 is enabled and the "real" serial console which is a time period we really want the console.
Quoted 4 lines
2. The line settings can now be set with stdout-path like,
stdout-path = "serial0:115200n8"but this breaks DT earlycon (as I wrote in the other email you were cc'd on).
Right. We should fix libfdt.
Quoted 1 line
3. omap doesn't support
ioremap()at early param parsing :(
ARM in general does not.
Quoted 1 line
4. the ARM arch doesn't support fixmap hacking at early param parsing :(
There's a patch on the list to enable it. It's been slow as fixmap has been a moving target.
Rob
Quoted 44 lines · Rob Herring
Quoted 43 lines · Peter Hurley
Hi Rob,
Quoted 1 line · Rob Herring
On Tue, Feb 24, 2015 at 1:53 PM, Peter Hurley <[email protected]> wrote:
[...]
Quoted 25 lines
Quoted 25 lines
Quoted 12 lines
Quoted 11 lines
Direct earlycon
This feature enables arches and proms to start an earlycon directly, rather than requiring an "earlycon=" command line parameter. Devicetree can already do this via the 'linux,stdout-path' property, but arch and prom code requires direct coupling to the serial driver.
This support is implemented by judicious refactoring and the same construct that devicetree and
early_paramuse: a link table containing the necessary information (name andsetup()function) to find and bind the appropriate earlycon "driver".Quoted 8 lines
I've skimmed thru this and it looks like a great improvement.
One problem we have currently with DT stdout-path and earlycon is a preferred console does not get registered, so the console will get switched to tty0 and you lose your console. The problem is DT does not know the console name to register a preferred console. It looks like this series may help this problem, but I'm not sure and wanted your thoughts.
I thought that
of_alias_scan()+of_console_check()caused DT stdout-path toadd_preferred_console()the driver console @ port registration time viauart_add_one_port()->of_console_check().Quoted 6 lines
Quoted 1 line
Is that not how that works?
Yes, I believe that is how it works with earlycon not enabled. This doesn't work when earlycon is enabled with just "earlycon" on the command line. The fix I have is here[1], but I don't like putting DT specifics into the console code.
After much gnashing of teeth and pulling of hair yesterday, I managed to mock up the situation you describe, but I need to study it in more detail. Some things I did learn:
Quoted 8 lines
Quoted 3 lines
1. The serial console _does_ come back up when using stdout-path but the line settings don't match, because the serial core sets them to the default of 9600n8 if unspecified.
That may have been what I saw as I tested on QEMU which ignores the baud rate. But it does stop between the time tty0 is enabled and the "real" serial console which is a time period we really want the console.
Yeah, that's what my mock-up showed as well:
[ 0.000000] Machine model: TI AM335x BeagleBone Black [ 0.000000] earlycon:serial0 options:115200 [ 0.000000] early_omap8250_setup: uart @ 44e09000 [ 0.000000] bootconsole [uart0] enabled .... [ 0.000349] Console: colour dummy device 80x30 [ 0.000367] console [tty0] enabled [ 0.000395] bootconsole [uart0] disabled [ 0.000441] Calibrating delay loop... 995.32 BogoMIPS (lpj=1990656) .... [ 1.097762] Serial: 8250/16550 driver, 32 ports, IRQ sharing disabled [ 1.107659] 44e09000.serial: ttyS0 at MMIO 0x44e09000 (irq = 154, base_baud = 3000000) is a 8250 [ 1.888536] console [ttyS0] enabled [ 1.893036] 481a8000.serial: ttyS4 at MMIO 0x481a8000 (irq = 155, base_baud = 3000000) is a 8250 [ 1.902810] 481aa000.serial: ttyS5 at MMIO 0x481aa000 (irq = 156, base_baud = 3000000) is a 8250
Quoted 10 lines
Quoted 4 lines
2. The line settings can now be set with stdout-path like,
stdout-path = "serial0:115200n8"but this breaks DT earlycon (as I wrote in the other email you were cc'd on).
Right. We should fix libfdt.
Quoted 1 line
3. omap doesn't support
ioremap()at early param parsing :(ARM in general does not.
I was looking at mach-bcm to see how it was that the iotable_init() didn't blow up, but maybe it does?
Quoted 4 lines
Quoted 1 line
4. the ARM arch doesn't support fixmap hacking at early param parsing :(
There's a patch on the list to enable it. It's been slow as fixmap has been a moving target.
Thanks. That's similar to what I cribbed from ARM64 arch last night.
Regards,
Peter Hurley
Quoted 6 lines · Peter Hurley
Quoted 5 lines · Rob Herring
Quoted 4 lines · Peter Hurley
Hi Rob,
Quoted 1 line · Rob Herring
On Tue, Feb 24, 2015 at 1:53 PM, Peter Hurley <[email protected]> wrote:
[...]
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
3. omap doesn't support
ioremap()at early param parsing :(ARM in general does not.
I was looking at mach-bcm to see how it was that the
iotable_init()didn't blow up, but maybe it does?
iotable_init is basically just a list of page table entries to create and uses the early page table setup code.
Rob
[ +cc devicetree, Mark Rutland, Grant Likely ]
Quoted 44 lines · Rob Herring
Quoted 43 lines · Peter Hurley
Hi Rob,
Quoted 1 line · Rob Herring
On Tue, Feb 24, 2015 at 1:53 PM, Peter Hurley <[email protected]> wrote:
[...]
Quoted 25 lines
Quoted 25 lines
Quoted 12 lines
Quoted 11 lines
Direct earlycon
This feature enables arches and proms to start an earlycon directly, rather than requiring an "earlycon=" command line parameter. Devicetree can already do this via the 'linux,stdout-path' property, but arch and prom code requires direct coupling to the serial driver.
This support is implemented by judicious refactoring and the same construct that devicetree and
early_paramuse: a link table containing the necessary information (name andsetup()function) to find and bind the appropriate earlycon "driver".Quoted 8 lines
I've skimmed thru this and it looks like a great improvement.
One problem we have currently with DT stdout-path and earlycon is a preferred console does not get registered, so the console will get switched to tty0 and you lose your console. The problem is DT does not know the console name to register a preferred console. It looks like this series may help this problem, but I'm not sure and wanted your thoughts.
I thought that
of_alias_scan()+of_console_check()caused DT stdout-path toadd_preferred_console()the driver console @ port registration time viauart_add_one_port()->of_console_check().Quoted 6 lines
Quoted 1 line
Is that not how that works?
Yes, I believe that is how it works with earlycon not enabled. This doesn't work when earlycon is enabled with just "earlycon" on the command line. The fix I have is here[1], but I don't like putting DT specifics into the console code.
After much gnashing of teeth and pulling of hair yesterday, I managed to mock up the situation you describe, but I need to study it in more detail. Some things I did learn:
Quoted 8 lines
Quoted 3 lines
1. The serial console _does_ come back up when using stdout-path but the line settings don't match, because the serial core sets them to the default of 9600n8 if unspecified.
That may have been what I saw as I tested on QEMU which ignores the baud rate. But it does stop between the time tty0 is enabled and the "real" serial console which is a time period we really want the console.
The bug is that of_alias_scan() does not emit a preferred console, but rather defers it until of_console_check().
In many setups, this means there is no preferred console. So when the dummy vt console loads (which happens via console_init()), all the boot consoles are disabled.
The trivial fix is to emit a preferred console from of_alias_scan(), even if that console is never matched. I've sent you a patch to do just that.
Quoted 6 lines
Quoted 4 lines
2. The line settings can now be set with stdout-path like,
stdout-path = "serial0:115200n8"but this breaks DT earlycon (as I wrote in the other email you were cc'd on).
Right. We should fix libfdt.
Ok.
Regards,
Peter Hurley