Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753350AbdDJLj3 (ORCPT ); Mon, 10 Apr 2017 07:39:29 -0400 Received: from mail1.bemta12.messagelabs.com ([216.82.251.8]:33137 "EHLO mail1.bemta12.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753168AbdDJLjY (ORCPT ); Mon, 10 Apr 2017 07:39:24 -0400 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHKsWRWlGSWpSXmKPExsVy+LrFKt3Hea8 jDN6v5bVo3lRs0bx4PZvF0ruf2Cw+/97FarHp8TVWi8u75rBZnFncy25x+zKvxY+H05ksuvoW sVkcu/SP0eL/nh3sFgc/PGG1aHk6g9Hi0NZHLBZ7731mdBDwWDNvDaNHS3MPm8fVXyfZPfrXf Wb1WPFnPZvHplWdbB77565h99i8pN7jzelT7B4npn9n8Tiz4AhQ6HS1x5b9nxk9Pm+SC+CLYs 3MS8qvSGDNuHtrP2PBy7SK9e+PsTcw7ovsYuTiEBJYxijx7/pTli5GTg5hgWCJ76daWEFsNgE TiZv3z7GAFIkIdDFKbOprBytiFuhhkVg2kQvEFhJwlth0tYMdxOYFsj/t3MMEYrMIqEpM+XqL DcQWFUiQuPhnCitEjaDEyZlPwOZwCrhIrJoMUc8soC/RtHUOM4QtL7H9LYQtJKAt8X7jYrBeC QEFiamTW5knMPLPQjJqFpL2WUjaFzAyr2LUKE4tKkst0jW00EsqykzPKMlNzMzRNTQ00stNLS 5OTE/NSUwq1kvOz93ECIzLegYGxh2Mkxq9DjFKcjApifKmW76OEOJLyk+pzEgszogvKs1JLT7 EKMPBoSTBW5QDlBMsSk1PrUjLzAEmCJi0BAePkgivSy5Qmre4IDG3ODMdInWKUZejr+PjeyYh lrz8vFQpcV5/kCIBkKKM0jy4EbBkdYlRVkqYl5GBgUGIpyC1KDezBFX+FaM4B6OSMG8MyBSez LwSuE2vgI5gAjrizK6XIEeUJCKkpBoYGaZdFYr9JcF44dY++1cvxdoY7k7sqvHiUZB4/L3j7O UlxXfcbhd+W+L0rXzbck/lFRMy/n22UA3dH+zzfXK0XPEE32kfU2z47D0eBEw6GjGr5eIZr50 +InlOlsk/3mefjPv4eA6L/hO9Cv0XBqwGodbP/lvn/7/zVPNtqdPrz9L3ktfuffHhoRJLcUai oRZzUXEiAMjeiSlRAwAA X-Env-Sender: Marc_Gonzalez@sigmadesigns.com X-Msg-Ref: server-3.tower-219.messagelabs.com!1491824353!157639739!1 X-Originating-IP: [195.215.56.170] X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Subject: Re: [PATCH v2] serial: 8250_early: Add earlycon support for Palmchip UART From: Marc Gonzalez To: linux-serial , Peter Hurley , Greg Kroah-Hartman CC: Russell King , Andreas Farber , Jean Delvare , Rob Herring , Mans Rullgard , Jiri Slaby , Masahiro Yamada , Vineet Gupta , Scott Wood , Robin Murphy , Thibaud Cornic , Mason , Linux ARM , LKML References: <7a016ff6-08fc-2811-92e0-7c4603fa8586@sigmadesigns.com> Message-ID: Date: Mon, 10 Apr 2017 13:39:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0 SeaMonkey/2.48 MIME-Version: 1.0 In-Reply-To: <7a016ff6-08fc-2811-92e0-7c4603fa8586@sigmadesigns.com> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: 7bit X-Originating-IP: [172.27.0.114] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 13161 Lines: 204 On 10/04/2017 11:47, Marc Gonzalez wrote: > Define an OF early console for Palmchip UART, which can be enabled > by passing "earlycon" on the boot command line. > > Signed-off-by: Marc Gonzalez > --- > drivers/tty/serial/8250/8250_early.c | 24 ++++++++++++++++++++++++ > drivers/tty/serial/8250/8250_port.c | 4 ++-- > 2 files changed, 26 insertions(+), 2 deletions(-) As pointed out by Andreas, Russell, and Robin, specifying the console on the command line is still required. In other words, the stdout-path method is not 100% functional. Testing different boot command-lines, with a kernel that artificially panics in the early stages: "mem=256M" "mem=256M console=ttyS0,115200" prints nothing, as expected. "mem=256M earlycon" does not show the panic message. Hangs after printing: [ 0.014146] Console: colour dummy device 80x30 [ 0.018615] console [tty0] enabled [ 0.022038] bootconsole [palmchip0] disabled "mem=256M console=ttyS0,115200 earlycon" "mem=256M console=ttyS0 earlycon" the panic message does appear, as expected. When I remove the panic, "mem=256M console=ttyS0 earlycon" stops printing kernel messages when the kernel switches the early console off. [ 0.750562] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled [ 0.758976] console [ttyS0] disabled [ 0.762664] 10700.serial: ttyS0 at MMIO 0x10700 (irq = 20, base_baud = 460800) is a Palmchip BK-3103 Therefore, the only 100% functional combination for me is "mem=256M console=ttyS0,115200 earlycon" For completeness, this method shows some "stuttering" in the console handling code: [ 0.000000] earlycon: palmchip0 at MMIO 0x00010700 (options '115200n8') [ 0.000000] bootconsole [palmchip0] enabled [ 0.000000] Kernel command line: mem=256M console=ttyS0,115200 earlycon [ 0.014149] Console: colour dummy device 80x30 [ 0.754670] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled [ 0.763045] console [ttyS0] disabled [ 0.766733] 10700.serial: ttyS0 at MMIO 0x10700 (irq = 20, base_baud = 460800) is a Palmchip BK-3103 [ 0.775969] console [ttyS0] enabled [ 0.775969] console [ttyS0] enabled [ 0.782979] bootconsole [palmchip0] disabled [ 0.782979] bootconsole [palmchip0] disabled This stuttering is likely related to this comment: /* * By unregistering the bootconsoles after we enable the real console * we get the "console xxx enabled" message on all the consoles - * boot consoles, real consoles, etc - this is to ensure that end * users know there might be something in the kernel's log buffer that * went to the bootconsole (that they do not see on the real console) */ In fact, if I add dump_stack() before pr_info("%sconsole [%s%d] enabled\n", pr_info("%sconsole [%s%d] disabled\n", then I get the following output: [ 0.000000] earlycon: palmchip0 at MMIO 0x00010700 (options '115200n8') [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.9.20-1-rc3 #18 [ 0.000000] Hardware name: Sigma Tango DT [ 0.000000] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 0.000000] [] (show_stack) from [] (dump_stack+0x84/0x98) [ 0.000000] [] (dump_stack) from [] (register_console+0x224/0x3c8) [ 0.000000] [] (register_console) from [] (of_setup_earlycon+0x1cc/0x1e0) [ 0.000000] [] (of_setup_earlycon) from [] (early_init_dt_scan_chosen_stdout+0x144/0x158) [ 0.000000] [] (early_init_dt_scan_chosen_stdout) from [] (do_early_param+0x78/0xbc) [ 0.000000] [] (do_early_param) from [] (parse_args+0x284/0x3d8) [ 0.000000] [] (parse_args) from [] (parse_early_options+0x3c/0x44) [ 0.000000] [] (parse_early_options) from [] (parse_early_param+0x30/0x44) [ 0.000000] [] (parse_early_param) from [] (setup_arch+0x5b8/0xa48) [ 0.000000] [] (setup_arch) from [] (start_kernel+0x5c/0x380) [ 0.000000] [] (start_kernel) from [<8000807c>] (0x8000807c) [ 0.000000] bootconsole [palmchip0] enabled (Lines 2 and 3 are a strange relic of the very first lines output.) [ 0.750471] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled [ 0.758744] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.9.20-1-rc3 #18 [ 0.765317] Hardware name: Sigma Tango DT [ 0.769376] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 0.777162] [] (show_stack) from [] (dump_stack+0x84/0x98) [ 0.784430] [] (dump_stack) from [] (unregister_console+0xc/0x144) [ 0.792395] [] (unregister_console) from [] (uart_remove_one_port+0x1d0/0x1fc) [ 0.801404] [] (uart_remove_one_port) from [] (serial8250_register_8250_port+0x94/0x380) [ 0.811291] [] (serial8250_register_8250_port) from [] (of_platform_serial_probe+0x3f0/0x4ac) [ 0.821614] [] (of_platform_serial_probe) from [] (platform_drv_probe+0x34/0x7c) [ 0.830796] [] (platform_drv_probe) from [] (really_probe+0x1c4/0x254) [ 0.839103] [] (really_probe) from [] (__driver_attach+0xc4/0xc8) [ 0.846972] [] (__driver_attach) from [] (bus_for_each_dev+0x68/0x9c) [ 0.855192] [] (bus_for_each_dev) from [] (bus_add_driver+0x1a0/0x218) [ 0.863498] [] (bus_add_driver) from [] (driver_register+0x78/0xf8) [ 0.871542] [] (driver_register) from [] (do_one_initcall+0x44/0x174) [ 0.879770] [] (do_one_initcall) from [] (kernel_init_freeable+0x154/0x1e4) [ 0.888516] [] (kernel_init_freeable) from [] (kernel_init+0x8/0x10c) [ 0.896736] [] (kernel_init) from [] (ret_from_fork+0x14/0x3c) [ 0.904409] console [ttyS0] disabled [ 0.908072] 10700.serial: ttyS0 at MMIO 0x10700 (irq = 20, base_baud = 460800) is a Palmchip BK-3103 [ 0.917316] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.9.20-1-rc3 #18 [ 0.917316] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.9.20-1-rc3 #18 [ 0.930425] Hardware name: Sigma Tango DT [ 0.930425] Hardware name: Sigma Tango DT [ 0.938477] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 0.938477] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 0.954036] [] (show_stack) from [] (dump_stack+0x84/0x98) [ 0.954036] [] (show_stack) from [] (dump_stack+0x84/0x98) [ 0.968548] [] (dump_stack) from [] (register_console+0x224/0x3c8) [ 0.968548] [] (dump_stack) from [] (register_console+0x224/0x3c8) [ 0.984458] [] (register_console) from [] (uart_add_one_port+0x424/0x4dc) [ 0.984458] [] (register_console) from [] (uart_add_one_port+0x424/0x4dc) [ 1.001590] [] (uart_add_one_port) from [] (serial8250_register_8250_port+0x268/0x380) [ 1.001590] [] (uart_add_one_port) from [] (serial8250_register_8250_port+0x268/0x380) [ 1.020995] [] (serial8250_register_8250_port) from [] (of_platform_serial_probe+0x3f0/0x4ac) [ 1.020995] [] (serial8250_register_8250_port) from [] (of_platform_serial_probe+0x3f0/0x4ac) [ 1.041621] [] (of_platform_serial_probe) from [] (platform_drv_probe+0x34/0x7c) [ 1.041621] [] (of_platform_serial_probe) from [] (platform_drv_probe+0x34/0x7c) [ 1.059975] [] (platform_drv_probe) from [] (really_probe+0x1c4/0x254) [ 1.059975] [] (platform_drv_probe) from [] (really_probe+0x1c4/0x254) [ 1.076580] [] (really_probe) from [] (__driver_attach+0xc4/0xc8) [ 1.076580] [] (really_probe) from [] (__driver_attach+0xc4/0xc8) [ 1.092311] [] (__driver_attach) from [] (bus_for_each_dev+0x68/0x9c) [ 1.092311] [] (__driver_attach) from [] (bus_for_each_dev+0x68/0x9c) [ 1.108742] [] (bus_for_each_dev) from [] (bus_add_driver+0x1a0/0x218) [ 1.108742] [] (bus_for_each_dev) from [] (bus_add_driver+0x1a0/0x218) [ 1.125347] [] (bus_add_driver) from [] (driver_register+0x78/0xf8) [ 1.125347] [] (bus_add_driver) from [] (driver_register+0x78/0xf8) [ 1.141429] [] (driver_register) from [] (do_one_initcall+0x44/0x174) [ 1.141429] [] (driver_register) from [] (do_one_initcall+0x44/0x174) [ 1.157862] [] (do_one_initcall) from [] (kernel_init_freeable+0x154/0x1e4) [ 1.157862] [] (do_one_initcall) from [] (kernel_init_freeable+0x154/0x1e4) [ 1.175342] [] (kernel_init_freeable) from [] (kernel_init+0x8/0x10c) [ 1.175342] [] (kernel_init_freeable) from [] (kernel_init+0x8/0x10c) [ 1.191773] [] (kernel_init) from [] (ret_from_fork+0x14/0x3c) [ 1.191773] [] (kernel_init) from [] (ret_from_fork+0x14/0x3c) [ 1.207013] console [ttyS0] enabled [ 1.207013] console [ttyS0] enabled [ 1.214019] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.9.20-1-rc3 #18 [ 1.214019] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.9.20-1-rc3 #18 [ 1.227126] Hardware name: Sigma Tango DT [ 1.227126] Hardware name: Sigma Tango DT [ 1.235175] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 1.235175] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 1.250732] [] (show_stack) from [] (dump_stack+0x84/0x98) [ 1.250732] [] (show_stack) from [] (dump_stack+0x84/0x98) [ 1.265242] [] (dump_stack) from [] (unregister_console+0xc/0x144) [ 1.265242] [] (dump_stack) from [] (unregister_console+0xc/0x144) [ 1.281149] [] (unregister_console) from [] (register_console+0x2b0/0x3c8) [ 1.281149] [] (unregister_console) from [] (register_console+0x2b0/0x3c8) [ 1.298455] [] (register_console) from [] (uart_add_one_port+0x424/0x4dc) [ 1.298455] [] (register_console) from [] (uart_add_one_port+0x424/0x4dc) [ 1.315586] [] (uart_add_one_port) from [] (serial8250_register_8250_port+0x268/0x380) [ 1.315586] [] (uart_add_one_port) from [] (serial8250_register_8250_port+0x268/0x380) [ 1.334989] [] (serial8250_register_8250_port) from [] (of_platform_serial_probe+0x3f0/0x4ac) [ 1.334989] [] (serial8250_register_8250_port) from [] (of_platform_serial_probe+0x3f0/0x4ac) [ 1.355614] [] (of_platform_serial_probe) from [] (platform_drv_probe+0x34/0x7c) [ 1.355614] [] (of_platform_serial_probe) from [] (platform_drv_probe+0x34/0x7c) [ 1.373968] [] (platform_drv_probe) from [] (really_probe+0x1c4/0x254) [ 1.373968] [] (platform_drv_probe) from [] (really_probe+0x1c4/0x254) [ 1.390574] [] (really_probe) from [] (__driver_attach+0xc4/0xc8) [ 1.390574] [] (really_probe) from [] (__driver_attach+0xc4/0xc8) [ 1.406305] [] (__driver_attach) from [] (bus_for_each_dev+0x68/0x9c) [ 1.406305] [] (__driver_attach) from [] (bus_for_each_dev+0x68/0x9c) [ 1.422735] [] (bus_for_each_dev) from [] (bus_add_driver+0x1a0/0x218) [ 1.422735] [] (bus_for_each_dev) from [] (bus_add_driver+0x1a0/0x218) [ 1.439339] [] (bus_add_driver) from [] (driver_register+0x78/0xf8) [ 1.439339] [] (bus_add_driver) from [] (driver_register+0x78/0xf8) [ 1.455421] [] (driver_register) from [] (do_one_initcall+0x44/0x174) [ 1.455421] [] (driver_register) from [] (do_one_initcall+0x44/0x174) [ 1.471854] [] (do_one_initcall) from [] (kernel_init_freeable+0x154/0x1e4) [ 1.471854] [] (do_one_initcall) from [] (kernel_init_freeable+0x154/0x1e4) [ 1.489332] [] (kernel_init_freeable) from [] (kernel_init+0x8/0x10c) [ 1.489332] [] (kernel_init_freeable) from [] (kernel_init+0x8/0x10c) [ 1.505763] [] (kernel_init) from [] (ret_from_fork+0x14/0x3c) [ 1.505763] [] (kernel_init) from [] (ret_from_fork+0x14/0x3c) [ 1.521038] bootconsole [palmchip0] disabled [ 1.521038] bootconsole [palmchip0] disabled Maybe it's possible to detect when console and earlycon are the same, and avoid a pair of unregister/register calls. Regards.