Skip to contentSkip to conversation

bcm63xx_uart and of-serial updates

PATCH In review Kevin Cernekee 3 participants 17 messages Oct 21, 2014 – Nov 6, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v3 cover bcm63xx_uart and of-serial updates

V2->V3:

Change DT clock node based on review feedback (thanks Arnd!)

Rebase on Linus' master branch

Kevin Cernekee (10):
tty: serial: bcm63xx: Allow bcm63xx_uart to be built on other
platforms
tty: serial: bcm63xx: Add support for unnamed clock outputs from DT
tty: serial: bcm63xx: Update the Kconfig help text
tty: serial: bcm63xx: Fix typo in MODULE_DESCRIPTION
Documentation: DT: Add entries for bcm63xx UART
tty: serial: bcm63xx: Enable DT earlycon support
tty: serial: bcm63xx: Eliminate unnecessary request/release functions
tty: serial: of-serial: Suppress warnings if OF earlycon is invoked
twice
tty: serial: of-serial: Allow OF earlycon to default to "on"
MAINTAINERS: Add entry for rp2 (Rocketport Express/Infinity) driver

 .../devicetree/bindings/serial/bcm63xx-uart.txt    | 30 ++++++++++++
 MAINTAINERS                                        |  6 +++
 drivers/of/fdt.c                                   | 17 +++++--
 drivers/tty/serial/Kconfig                         | 30 ++++++++----
 drivers/tty/serial/bcm63xx_uart.c                  | 55 +++++++++++++---------
 include/linux/serial_bcm63xx.h                     |  2 -
 6 files changed, 104 insertions(+), 36 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/serial/bcm63xx-uart.txt
Signature · 1 line
2.1.1
#1 lore raw

PATCH v3 1/10 tty: serial: bcm63xx: Allow bcm63xx_uart to be built on other platforms

This device was originally supported on bcm63xx only, but it shows up on a wide variety of MIPS and ARM chipsets spanning multiple product lines. Now that the driver has eliminated dependencies on bcm63xx-specific header files, we can build it on any non-bcm63xx kernel.

Compile-tested on x86, both statically and as a module. Tested for functionality on bcm3384 (a new MIPS platform under active development).

---
 drivers/tty/serial/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/Kconfig +1 -1
index 649b784..4a5c0c8 100644
@@ -1283,7 +1283,7 @@ config SERIAL_TIMBERDALE
 config SERIAL_BCM63XX
 	tristate "bcm63xx serial port support"
 	select SERIAL_CORE
-	depends on BCM63XX
+	depends on MIPS || ARM || COMPILE_TEST
 	help
 	  If you have a bcm63xx CPU, you can enable its onboard
 	  serial port by enabling this options.
Signature · 1 line
2.1.1
#2 lore raw

PATCH v3 2/10 tty: serial: bcm63xx: Add support for unnamed clock outputs from DT

In reply to Kevin Cernekee

The original non-DT bcm63xx clk code ignores the struct device argument and looks up a global clock name. DT platforms, by contrast, often just use a phandle to reference a clock node with no "clock-output-names" property. Modify the UART driver to support both schemes.

---
 drivers/tty/serial/bcm63xx_uart.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/serial/bcm63xx_uart.c +2 -1
index 2315190..de95573 100644
@@ -824,7 +824,8 @@ static int bcm_uart_probe(struct platform_device *pdev)
 	if (!res_irq)
 		return -ENODEV;
 
-	clk = clk_get(&pdev->dev, "periph");
+	clk = pdev->dev.of_node ? of_clk_get(pdev->dev.of_node, 0) :
+				  clk_get(&pdev->dev, "periph");
 	if (IS_ERR(clk))
 		return -ENODEV;
 
Signature · 1 line
2.1.1
#3 lore raw

PATCH v3 3/10 tty: serial: bcm63xx: Update the Kconfig help text

In reply to Kevin Cernekee

Remove incorrect "bcm963xx_uart" module name; add a list of known users; tweak grammar/indentation/capitalization.

---
 drivers/tty/serial/Kconfig | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/tty/serial/Kconfig +9 -7
index 4a5c0c8..815b652 100644
@@ -1281,22 +1281,24 @@ config SERIAL_TIMBERDALE
 	Add support for UART controller on timberdale.
 
 config SERIAL_BCM63XX
-	tristate "bcm63xx serial port support"
+	tristate "Broadcom BCM63xx/BCM33xx UART support"
 	select SERIAL_CORE
 	depends on MIPS || ARM || COMPILE_TEST
 	help
-	  If you have a bcm63xx CPU, you can enable its onboard
-	  serial port by enabling this options.
+	  This enables the driver for the onchip UART core found on
+	  the following chipsets:
 
-          To compile this driver as a module, choose M here: the
-          module will be called bcm963xx_uart.
+	    BCM33xx (cable modem)
+	    BCM63xx/BCM63xxx (DSL)
+	    BCM68xx (PON)
+	    BCM7xxx (STB) - DOCSIS console
 
 config SERIAL_BCM63XX_CONSOLE
-	bool "Console on bcm63xx serial port"
+	bool "Console on BCM63xx serial port"
 	depends on SERIAL_BCM63XX=y
 	select SERIAL_CORE_CONSOLE
 	help
-	  If you have enabled the serial port on the bcm63xx CPU
+	  If you have enabled the serial port on the BCM63xx CPU
 	  you can make it the console by answering Y to this option.
 
 config SERIAL_GRLIB_GAISLER_APBUART
Signature · 1 line
2.1.1
#4 lore raw

PATCH v3 4/10 tty: serial: bcm63xx: Fix typo in MODULE_DESCRIPTION

In reply to Kevin Cernekee

Remove the extra '<' character.

---
 drivers/tty/serial/bcm63xx_uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/bcm63xx_uart.c +1 -1
index de95573..b615af2 100644
@@ -906,5 +906,5 @@ module_init(bcm_uart_init);
 module_exit(bcm_uart_exit);
 
 MODULE_AUTHOR("Maxime Bizon <[email protected]>");
-MODULE_DESCRIPTION("Broadcom 63<xx integrated uart driver");
+MODULE_DESCRIPTION("Broadcom 63xx integrated uart driver");
 MODULE_LICENSE("GPL");
Signature · 1 line
2.1.1
#5 lore raw

PATCH v3 5/10 Documentation: DT: Add entries for bcm63xx UART

In reply to Kevin Cernekee

This squashes a checkpatch warning on my new bcm3384 dts submission.

---
 .../devicetree/bindings/serial/bcm63xx-uart.txt    | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/serial/bcm63xx-uart.txt
Documentation/devicetree/bindings/serial/bcm63xx-uart.txt new file +30 -0
new file mode 100644
index 0000000..5c52e5e
@@ -0,0 +1,30 @@
+* BCM63xx UART
+
+Required properties:
+
+- compatible: "brcm,bcm6345-uart"
+
+- reg: The base address of the UART register bank.
+
+- interrupts: A single interrupt specifier.
+
+- clocks: Clock driving the hardware; used to figure out the baud rate
+  divisor.
+
+Example:
+
+	uart0: serial@14e00520 {
+		compatible = "brcm,bcm6345-uart";
+		reg = <0x14e00520 0x18>;
+		interrupt-parent = <&periph_intc>;
+		interrupts = <2>;
+		clocks = <&periph_clk>;
+	};
+
+	clocks {
+		periph_clk: periph_clk@0 {
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <54000000>;
+		};
+	};
Signature · 1 line
2.1.1
#6 lore raw

PATCH v3 6/10 tty: serial: bcm63xx: Enable DT earlycon support

In reply to Kevin Cernekee

This enables early console output if there is a chosen/stdout-path property referencing a UART node with the "brcm,bcm6345-uart" compatible string. The bootloader sets up the pinmux and baud/parity/etc. Tested on bcm3384 (MIPS, DT).

---
 drivers/tty/serial/Kconfig        |  1 +
 drivers/tty/serial/bcm63xx_uart.c | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)
drivers/tty/serial/Kconfig +1 -0
index 815b652..fdd851e 100644
@@ -1297,6 +1297,7 @@ config SERIAL_BCM63XX_CONSOLE
 	bool "Console on BCM63xx serial port"
 	depends on SERIAL_BCM63XX=y
 	select SERIAL_CORE_CONSOLE
+	select SERIAL_EARLYCON
 	help
 	  If you have enabled the serial port on the BCM63xx CPU
 	  you can make it the console by answering Y to this option.
drivers/tty/serial/bcm63xx_uart.c +20 -0
index b615af2..109dea7 100644
@@ -782,6 +782,26 @@ static int __init bcm63xx_console_init(void)
 
 console_initcall(bcm63xx_console_init);
 
+static void bcm_early_write(struct console *con, const char *s, unsigned n)
+{
+	struct earlycon_device *dev = con->data;
+
+	uart_console_write(&dev->port, s, n, bcm_console_putchar);
+	wait_for_xmitr(&dev->port);
+}
+
+static int __init bcm_early_console_setup(struct earlycon_device *device,
+					  const char *opt)
+{
+	if (!device->port.membase)
+		return -ENODEV;
+
+	device->con->write = bcm_early_write;
+	return 0;
+}
+
+OF_EARLYCON_DECLARE(bcm63xx_uart, "brcm,bcm6345-uart", bcm_early_console_setup);
+
 #define BCM63XX_CONSOLE	(&bcm63xx_console)
 #else
 #define BCM63XX_CONSOLE	NULL
Signature · 1 line
2.1.1
#7 lore raw

PATCH v3 7/10 tty: serial: bcm63xx: Eliminate unnecessary request/release functions

In reply to Kevin Cernekee

We don't really need to perform the ioremap "on demand" so it's simpler just to do it from the probe function. This also lets us eliminate the UART_REG_SIZE constant and rely on the resource information passed in from the DT or platform code.

---
 drivers/tty/serial/bcm63xx_uart.c | 30 ++++++++++--------------------
 include/linux/serial_bcm63xx.h    |  2 --
 2 files changed, 10 insertions(+), 22 deletions(-)
drivers/tty/serial/bcm63xx_uart.c +10 -20
index 109dea7..e04e580 100644
@@ -588,20 +588,7 @@ static void bcm_uart_set_termios(struct uart_port *port,
  */
 static int bcm_uart_request_port(struct uart_port *port)
 {
-	unsigned int size;
-
-	size = UART_REG_SIZE;
-	if (!request_mem_region(port->mapbase, size, "bcm63xx")) {
-		dev_err(port->dev, "Memory region busy\n");
-		return -EBUSY;
-	}
-
-	port->membase = ioremap(port->mapbase, size);
-	if (!port->membase) {
-		dev_err(port->dev, "Unable to map registers\n");
-		release_mem_region(port->mapbase, size);
-		return -EBUSY;
-	}
+	/* UARTs always present */
 	return 0;
 }
 
@@ -610,8 +597,7 @@ static int bcm_uart_request_port(struct uart_port *port)
  */
 static void bcm_uart_release_port(struct uart_port *port)
 {
-	release_mem_region(port->mapbase, UART_REG_SIZE);
-	iounmap(port->membase);
+	/* Nothing to release ... */
 }
 
 /*
@@ -833,13 +819,20 @@ static int bcm_uart_probe(struct platform_device *pdev)
 	if (pdev->id < 0 || pdev->id >= BCM63XX_NR_UARTS)
 		return -EINVAL;
 
-	if (ports[pdev->id].membase)
+	port = &ports[pdev->id];
+	if (port->membase)
 		return -EBUSY;
+	memset(port, 0, sizeof(*port));
 
 	res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res_mem)
 		return -ENODEV;
 
+	port->mapbase = res_mem->start;
+	port->membase = devm_ioremap_resource(&pdev->dev, res_mem);
+	if (IS_ERR(port->membase))
+		return PTR_ERR(port->membase);
+
 	res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (!res_irq)
 		return -ENODEV;
@@ -849,10 +842,7 @@ static int bcm_uart_probe(struct platform_device *pdev)
 	if (IS_ERR(clk))
 		return -ENODEV;
 
-	port = &ports[pdev->id];
-	memset(port, 0, sizeof(*port));
 	port->iotype = UPIO_MEM;
-	port->mapbase = res_mem->start;
 	port->irq = res_irq->start;
 	port->ops = &bcm_uart_ops;
 	port->flags = UPF_BOOT_AUTOCONF;
include/linux/serial_bcm63xx.h +0 -2
index a80aa1a..570e964 100644
@@ -116,6 +116,4 @@
 					UART_FIFO_PARERR_MASK |		\
 					UART_FIFO_BRKDET_MASK)
 
-#define UART_REG_SIZE			24
-
 #endif /* _LINUX_SERIAL_BCM63XX_H */
Signature · 1 line
2.1.1
#8 lore raw

PATCH v3 8/10 tty: serial: of-serial: Suppress warnings if OF earlycon is invoked twice

In reply to Kevin Cernekee

Specifying "earlycon earlycon" on the kernel command line yields this warning:

    bootconsole [uart0] enabled
    ------------[ cut here ]------------
    WARNING: CPU: 0 PID: 0 at kernel/printk/printk.c:2391 register_console+0x244/0x3fc()
    console 'uart0' already registered
    CPU: 0 PID: 0 Comm: swapper Not tainted 3.18.0-rc1+ #2
    Stack : 00000000 00000004 80af0000 80af0000 00000000 00000000 00000000 00000000
              80ad4e12 00000036 00000000 00000000 00010000 805abe88 805606b4 805abae7
              00000000 00000000 80ad38d8 805abe88 8055f304 43d42d03 9988c6a1 804e2710
              805b0000 80032854 00000000 00000000 8056492c 80599c84 80599c84 805606b4
              00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
              ...
    Call Trace:
    [<8001a22c>] show_stack+0x64/0x7c
    [<804e47d8>] dump_stack+0xc8/0xfc
    [<80032aa8>] warn_slowpath_common+0x7c/0xac
    [<80032b38>] warn_slowpath_fmt+0x2c/0x38
    [<80076524>] register_console+0x244/0x3fc
    [<805d8314>] of_setup_earlycon+0x74/0x98
    [<805daa40>] early_init_dt_scan_chosen_serial+0x104/0x134
    [<805c51a0>] do_early_param+0xc4/0x13c
    [<8004efa0>] parse_args+0x284/0x444
    [<805c56cc>] parse_early_options+0x34/0x40
    [<805c5714>] parse_early_param+0x3c/0x58
    [<805c87a4>] setup_arch+0xec/0x6e4
    [<805c57d4>] start_kernel+0x94/0x458

    ---[ end trace dc8fa200cb88537f ]---

In this case the duplicate "earlycon" was entered directly, but there are other cases where this could happen inadvertently:

- Some platforms allow user bootargs to be concatenated with builtin bootargs, e.g. CONFIG_CMDLINE_EXTEND.

- Other platforms may want to hardwire earlycon to ON, so it isn't nice if a user manually specifying "earlycon" on the command line sees a big scary warning.

So, we will treat "earlycon" as a flag, and if happens to be requested multiple times the kernel will not print any warnings.

---
 drivers/of/fdt.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/of/fdt.c +8 -4
index d1ffca8..20193cc 100644
@@ -755,6 +755,11 @@ int __init early_init_dt_scan_chosen_serial(void)
 	int l;
 	const struct of_device_id *match = __earlycon_of_table;
 	const void *fdt = initial_boot_params;
+	static int done;
+
+	if (done)
+		return -EBUSY;
+	done = 1;
 
 	offset = fdt_path_offset(fdt, "/chosen");
 	if (offset < 0)
@@ -792,10 +797,9 @@ int __init early_init_dt_scan_chosen_serial(void)
 
 static int __init setup_of_earlycon(char *buf)
 {
-	if (buf)
-		return 0;
-
-	return early_init_dt_scan_chosen_serial();
+	if (!buf)
+		early_init_dt_scan_chosen_serial();
+	return 0;
 }
 early_param("earlycon", setup_of_earlycon);
 #endif
Signature · 1 line
2.1.1
#9 lore raw

PATCH v3 9/10 tty: serial: of-serial: Allow OF earlycon to default to "on"

In reply to Kevin Cernekee

On many development systems it is very common to see failures during the early stages of the boot process, e.g. SMP boot or PCIe initialization. This is one likely reason why some existing earlyprintk implementations, such as arch/mips/kernel/early_printk.c, are enabled unconditionally at compile time.

Now that earlycon's operating parameters can be passed into the kernel via DT, it is helpful to be able to configure the kernel to turn it on automatically. Introduce a new CONFIG_SERIAL_EARLYCON_FORCE option for this purpose.

---
 drivers/of/fdt.c           |  5 +++++
 drivers/tty/serial/Kconfig | 11 +++++++++++
 2 files changed, 16 insertions(+)
drivers/of/fdt.c +5 -0
index 20193cc..3e2ea1e 100644
@@ -1013,6 +1013,11 @@ bool __init early_init_dt_verify(void *params)
 
 void __init early_init_dt_scan_nodes(void)
 {
+#ifdef CONFIG_SERIAL_EARLYCON_FORCE
+	if (early_init_dt_scan_chosen_serial() < 0)
+		pr_warn("Unable to set up earlycon from stdout-path\n");
+#endif
+
 	/* Retrieve various information from the /chosen node */
 	of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line);
 
drivers/tty/serial/Kconfig +11 -0
index fdd851e..bc4ebcc 100644
@@ -14,6 +14,17 @@ config SERIAL_EARLYCON
 	  the console before standard serial driver is probed. The console is
 	  enabled when early_param is processed.
 
+config SERIAL_EARLYCON_FORCE
+	bool "Always enable early console"
+	depends on SERIAL_EARLYCON
+	help
+	  Traditionally, enabling the early console has required passing in
+	  the "earlycon" parameter on the kernel command line.  On systems
+	  under development it may be desirable to enable earlycon
+	  unconditionally rather than to force the user to manually add it
+	  to the boot argument string, as boot failures often occur before
+	  the standard serial driver is probed.
+
 source "drivers/tty/serial/8250/Kconfig"
 
 comment "Non-8250 serial port support"
Signature · 1 line
2.1.1
maintainer
#10 lore raw

Re: [PATCH V3 09/10] tty: serial: of-serial: Allow OF earlycon to default to "on"

Quoted 10 lines · Kevin Cernekee

On many development systems it is very common to see failures during the early stages of the boot process, e.g. SMP boot or PCIe initialization. This is one likely reason why some existing earlyprintk implementations, such as arch/mips/kernel/early_printk.c, are enabled unconditionally at compile time.

Now that earlycon's operating parameters can be passed into the kernel via DT, it is helpful to be able to configure the kernel to turn it on automatically. Introduce a new CONFIG_SERIAL_EARLYCON_FORCE option for this purpose.

You can already force this using the CMDLINE_EXTEND option. I'm not sure we need more options.

Quoted 12 lines
---
 drivers/of/fdt.c           |  5 +++++
 drivers/tty/serial/Kconfig | 11 +++++++++++
 2 files changed, 16 insertions(+)
drivers/of/fdt.c +0 -0
index 20193cc..3e2ea1e 100644

drivers/of/fdt.c bool __init early_init_dt_verify(void *params) · line 1019

Quoted 7 lines
drivers/of/fdt.c +4 -0
@@ -1013,6 +1013,11 @@ bool __init early_init_dt_verify(void *params)
 
 void __init early_init_dt_scan_nodes(void)
 {
+#ifdef CONFIG_SERIAL_EARLYCON_FORCE
+       if (early_init_dt_scan_chosen_serial() < 0)
+               pr_warn("Unable to set up earlycon from stdout-path\n");
+#endif

Doesn't this make the earlycon get scanned and setup twice? Hopefully that is safe...

This also introduces the scanning at another point in time during boot which may not work depending on the arch.

Rob

Quoted 29 lines
drivers/of/fdt.c +1 -0
+
        /* Retrieve various information from the /chosen node */
        of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line);
 
drivers/tty/serial/Kconfig +11 -1
index fdd851e..bc4ebcc 100644
@@ -14,6 +14,17 @@ config SERIAL_EARLYCON
          the console before standard serial driver is probed. The console is
          enabled when early_param is processed.
 
+config SERIAL_EARLYCON_FORCE
+       bool "Always enable early console"
+       depends on SERIAL_EARLYCON
+       help
+         Traditionally, enabling the early console has required passing in
+         the "earlycon" parameter on the kernel command line.  On systems
+         under development it may be desirable to enable earlycon
+         unconditionally rather than to force the user to manually add it
+         to the boot argument string, as boot failures often occur before
+         the standard serial driver is probed.
+
 source "drivers/tty/serial/8250/Kconfig"
 
 comment "Non-8250 serial port support"
--

2.1.1

#11 lore raw

Re: [PATCH V3 09/10] tty: serial: of-serial: Allow OF earlycon to default to "on"

Quoted 7 lines · Rob Herring
Quoted 6 lines · Kevin Cernekee

On many development systems it is very common to see failures during the early stages of the boot process, e.g. SMP boot or PCIe initialization. This is one likely reason why some existing earlyprintk implementations, such as arch/mips/kernel/early_printk.c, are enabled unconditionally at compile time.

Quoted 7 lines
Quoted 4 lines

Now that earlycon's operating parameters can be passed into the kernel via DT, it is helpful to be able to configure the kernel to turn it on automatically. Introduce a new CONFIG_SERIAL_EARLYCON_FORCE option for this purpose.

You can already force this using the CMDLINE_EXTEND option. I'm not sure we need more options.

Hi Rob,

Now that earlycon can get all of its parameters from DT, do you think it might make sense to drop the command line option entirely from fdt.c and enable it all of the time if stdout-path is set correctly?

Quoted 1 line

From the user's standpoint, how important is it to be able to run

without earlycon?

Quoted 9 lines

drivers/of/fdt.c bool __init early_init_dt_verify(void *params) · line 1019

Quoted 6 lines

void __init early_init_dt_scan_nodes(void)
{

drivers/of/fdt.c +4 -0
+#ifdef CONFIG_SERIAL_EARLYCON_FORCE
+       if (early_init_dt_scan_chosen_serial() < 0)
+               pr_warn("Unable to set up earlycon from stdout-path\n");
+#endif

Doesn't this make the earlycon get scanned and setup twice? Hopefully that is safe...

Patch 08/10 makes it safe. Without Patch 08/10, specifying "earlycon earlycon" also generates a backtrace.

Quoted 2 lines

This also introduces the scanning at another point in time during boot which may not work depending on the arch.

Currently the sequence looks like:

- arch code calls early_init_dt_scan() to populate boot_command_line
and memory ranges

- arch code might do some other stuff, possibly setting up page
tables, register mappings, etc.

- arch code calls parse_early_param() to look at the final command line

- parse_early_param() might call early_init_dt_scan_chosen_serial()

So we're assuming that the arch code knows not to call parse_early_param() until the mappings are configured. But this is an implicit requirement, and might not be totally obvious. Since SERIAL_EARLYCON is enabled by the UART driver, not the arch code, it is possible that some platforms have ordering issues here that won't be discovered until somebody tries to use earlycon.

Would it be more straightforward to have the arch code explicitly call early_init_dt_scan_chosen_serial() to indicate that it is ready for the early UART driver to run?

maintainer
#12 lore raw

Re: [PATCH V3 09/10] tty: serial: of-serial: Allow OF earlycon to default to "on"

Quoted 16 lines · Kevin Cernekee
Quoted 7 lines · Rob Herring
Quoted 6 lines · Kevin Cernekee

On many development systems it is very common to see failures during the early stages of the boot process, e.g. SMP boot or PCIe initialization. This is one likely reason why some existing earlyprintk implementations, such as arch/mips/kernel/early_printk.c, are enabled unconditionally at compile time.

Quoted 7 lines
Quoted 4 lines

Now that earlycon's operating parameters can be passed into the kernel via DT, it is helpful to be able to configure the kernel to turn it on automatically. Introduce a new CONFIG_SERIAL_EARLYCON_FORCE option for this purpose.

You can already force this using the CMDLINE_EXTEND option. I'm not sure we need more options.

Quoted 8 lines

Hi Rob,

Now that earlycon can get all of its parameters from DT, do you think it might make sense to drop the command line option entirely from fdt.c and enable it all of the time if stdout-path is set correctly?

From the user's standpoint, how important is it to be able to run without earlycon?

It may affect boot time for one although if you care you probably disable console altogether.

I think we'd just have to add a noearlycon option instead if we made it the default. It's never been the default before, so I don't think we should change now. There's also an implicit requirement that the bootloader has configured the uart already. You could easily hang if the uart has not been setup.

Quoted 16 lines
Quoted 9 lines

drivers/of/fdt.c bool __init early_init_dt_verify(void *params) · line 1019

Quoted 6 lines

void __init early_init_dt_scan_nodes(void)
{

drivers/of/fdt.c +4 -0
+#ifdef CONFIG_SERIAL_EARLYCON_FORCE
+       if (early_init_dt_scan_chosen_serial() < 0)
+               pr_warn("Unable to set up earlycon from stdout-path\n");
+#endif

Doesn't this make the earlycon get scanned and setup twice? Hopefully that is safe...

Patch 08/10 makes it safe. Without Patch 08/10, specifying "earlycon earlycon" also generates a backtrace.

Quoted 2 lines

This also introduces the scanning at another point in time during boot which may not work depending on the arch.

Quoted 7 lines

Currently the sequence looks like:

- arch code calls early_init_dt_scan() to populate boot_command_line
and memory ranges

- arch code might do some other stuff, possibly setting up page
tables, register mappings, etc.

Yes, like the page table needed to map your earlycon uart.

Quoted 10 lines

- arch code calls parse_early_param() to look at the final command line

- parse_early_param() might call early_init_dt_scan_chosen_serial()

So we're assuming that the arch code knows not to call parse_early_param() until the mappings are configured. But this is an implicit requirement, and might not be totally obvious. Since SERIAL_EARLYCON is enabled by the UART driver, not the arch code, it is possible that some platforms have ordering issues here that won't be discovered until somebody tries to use earlycon.

Right, if you enable earlycon and the architecture doesn't support it, you will crash. This is not really new. Doing "earlycon=uart8250..." on ARM will crash as long as the 8250 driver has supported that option.

Quoted 3 lines

Would it be more straightforward to have the arch code explicitly call early_init_dt_scan_chosen_serial() to indicate that it is ready for the early UART driver to run?

Yes, but then when do you handle earlycon command line option for non-DT case? Having these at different points in time is asking for problems.

Also, I've been trying to reduce the number of DT hooks into the arch code, so adding that would be moving in the wrong direction.

Rob

#13 lore raw

Re: [PATCH V3 09/10] tty: serial: of-serial: Allow OF earlycon to default to "on"

Quoted 7 lines · Rob Herring
Quoted 6 lines

Now that earlycon can get all of its parameters from DT, do you think it might make sense to drop the command line option entirely from fdt.c and enable it all of the time if stdout-path is set correctly?

From the user's standpoint, how important is it to be able to run without earlycon?

Quoted 8 lines

It may affect boot time for one although if you care you probably disable console altogether.

I think we'd just have to add a noearlycon option instead if we made it the default. It's never been the default before, so I don't think we should change now. There's also an implicit requirement that the bootloader has configured the uart already. You could easily hang if the uart has not been setup.

EARLY_PRINTK is enabled by default on MIPS platforms that support it. I have been using this for years and found it very helpful in debugging failures in the kernel boot process (especially intermittent ones).

But for a new platform it is better to use earlycon as earlycon provides a clean way of reading the UART information out of DT. My original bcm3384 (MIPS) port used EARLY_PRINTK but I recently converted it to earlycon. The last remaining goal is to get it enabled by default again.

Quoted 7 lines
Quoted 3 lines

Would it be more straightforward to have the arch code explicitly call early_init_dt_scan_chosen_serial() to indicate that it is ready for the early UART driver to run?

Yes, but then when do you handle earlycon command line option for non-DT case? Having these at different points in time is asking for problems.

Is it important for the non-DT "earlycon" option to be handled from parse_early_param() just because parse_early_param() runs at the right point in the boot sequence (not because we actually wanted it to be a command line option)?

One other option might be to invoke early_init_dt_scan_chosen_serial() from parse_early_param(). But it is somewhat clunky to put a special case in there...

#14 lore raw

Re: [PATCH V3 09/10] tty: serial: of-serial: Allow OF earlycon to default to "on"

Quoted 11 lines · Kevin Cernekee
Quoted 5 lines

I think we'd just have to add a noearlycon option instead if we made it the default. It's never been the default before, so I don't think we should change now. There's also an implicit requirement that the bootloader has configured the uart already. You could easily hang if the uart has not been setup.

EARLY_PRINTK is enabled by default on MIPS platforms that support it. I have been using this for years and found it very helpful in debugging failures in the kernel boot process (especially intermittent ones).

Quoted 5 lines

But for a new platform it is better to use earlycon as earlycon provides a clean way of reading the UART information out of DT. My original bcm3384 (MIPS) port used EARLY_PRINTK but I recently converted it to earlycon. The last remaining goal is to get it enabled by default again.

Hi Rob,

Do you think we should just drop this patch for now, and use these options to append "earlycon" to the bootloader-supplied command line:

CONFIG_CMDLINE_BOOL=y
CONFIG_CMDLINE="earlycon"
CONFIG_CMDLINE_OVERRIDE=n

If you have other suggestions on how to enable earlycon by default, I would be happy to help implement them.

Thanks!

#15 lore raw

PATCH v3 10/10 MAINTAINERS: Add entry for rp2 (Rocketport Express/Infinity) driver

In reply to Kevin Cernekee

I wrote this driver and use it daily on several machines for work, so why not.

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
index a20df9b..d483627 100644
@@ -7787,6 +7787,12 @@ S:	Maintained
 F:	Documentation/serial/rocket.txt
 F:	drivers/tty/rocket*
 
+ROCKETPORT EXPRESS/INFINITY DRIVER
+M:	Kevin Cernekee <[email protected]>
+L:	[email protected]
+S:	Odd Fixes
+F:	drivers/tty/serial/rp2.*
+
 ROSE NETWORK LAYER
 M:	Ralf Baechle <[email protected]>
 L:	[email protected]
Signature · 1 line
2.1.1
maintainer
#16 lore raw
In reply to Kevin Cernekee
Quoted 21 lines · Kevin Cernekee

V2->V3:

Change DT clock node based on review feedback (thanks Arnd!)

Rebase on Linus' master branch

Kevin Cernekee (10):
tty: serial: bcm63xx: Allow bcm63xx_uart to be built on other
platforms
tty: serial: bcm63xx: Add support for unnamed clock outputs from DT
tty: serial: bcm63xx: Update the Kconfig help text
tty: serial: bcm63xx: Fix typo in MODULE_DESCRIPTION
Documentation: DT: Add entries for bcm63xx UART
tty: serial: bcm63xx: Enable DT earlycon support
tty: serial: bcm63xx: Eliminate unnecessary request/release functions
tty: serial: of-serial: Suppress warnings if OF earlycon is invoked
twice
tty: serial: of-serial: Allow OF earlycon to default to "on"
MAINTAINERS: Add entry for rp2 (Rocketport Express/Infinity) driver

Quoted 8 lines
 .../devicetree/bindings/serial/bcm63xx-uart.txt    | 30 ++++++++++++
 MAINTAINERS                                        |  6 +++
 drivers/of/fdt.c                                   | 17 +++++--
 drivers/tty/serial/Kconfig                         | 30 ++++++++----
 drivers/tty/serial/bcm63xx_uart.c                  | 55 +++++++++++++---------
 include/linux/serial_bcm63xx.h                     |  2 -
 6 files changed, 104 insertions(+), 36 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/serial/bcm63xx-uart.txt

I've applied 8 of these patches, not patches 08 or 09 at this time.

thanks,

greg k-h