From: Alper Nebi Yasak <alpernebiyasak@gmail.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jslaby@suse.com>, Petr Mladek <pmladek@suse.com>, Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Cc: linux-serial@vger.kernel.org, Steven Rostedt <rostedt@goodmis.org>, Alper Nebi Yasak <alpernebiyasak@gmail.com>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Vetter <daniel.vetter@ffwll.ch>, Eric Biggers <ebiggers@google.com>, Grzegorz Halat <ghalat@redhat.com>, Lukas Wunner <lukas@wunner.de>, Nicolas Pitre <nico@fluxnic.net>, Sam Ravnborg <sam@ravnborg.org> Subject: [RFC PATCH v2 2/3] vt: Set as preferred console when a non-dummy backend is bound Date: Thu, 30 Apr 2020 19:14:36 +0300 [thread overview] Message-ID: <20200430161438.17640-3-alpernebiyasak@gmail.com> (raw) In-Reply-To: <20200430161438.17640-1-alpernebiyasak@gmail.com> When a machine's device-tree has a "chosen" node with a "stdout-path" property that specified console is added as the preferred console by of_console_check via an add_preferred_console call. The property is quite common in kernel device-tree definitions. As far as I can tell, it is set to provide a reasonable default value for earlycon, and the (usually serial) console is set as preferred to avoid output going to VT's dummy backend instead of a working console. However, a chosen stdout-path property is included even in device-trees of systems that are designed to be used with a built-in display, e.g. several ARM Chromebooks. In these cases where CONFIG_VT_CONSOLE is enabled and no console argument is given on the kernel commandline, tty0 is still registered (presumably based on the order of of_console_check and vt's register_console calls) but ends up not being the preferred console. As a result, it is possible for early userspace prompts (encryption passphrase requests, emergency shells) to end up in a console that the user doesn't expect or even have access to. This patch tries to set tty0 as the /dev/console whenever a non-dummy backend tries to register as its default, unless the preferred console was set from the kernel commandline arguments. On a Samsung Chromebook Plus (Google Kevin, rk3399-gru-kevin.dts), boot messages are still visible on the framebuffer without this patch, but it isn't the preferred console due to the device-tree having a stdout-path property (from rk3399-gru.dtsi): # Without earlycon: $ sudo dmesg | grep -i "console\|printk\|tty[0-9a-z]" | grep -v systemd [ 0.001447] Console: colour dummy device 80x25 [ 0.001820] printk: console [tty0] enabled [ 3.012303] ff1a0000.serial: ttyS2 at MMIO 0xff1a0000 (irq = 39, base_baud = 1500000) is a 16550A [ 4.326549] printk: console [ttyS2] enabled [ 5.521780] dw-apb-uart ff1a0000.serial: forbid DMA for kernel console [ 6.359706] Console: switching to colour frame buffer device 300x100 $ cat /proc/consoles ttyS2 -W- (EC p a) 4:66 tty0 -WU (E p ) 4:7 # With earlycon: $ sudo dmesg | grep -i "console\|printk\|tty[0-9a-z]" | grep -v systemd [ 0.000000] printk: bootconsole [uart0] enabled [ 0.010257] Console: colour dummy device 80x25 [ 0.015131] printk: console [tty0] enabled [ 0.019625] printk: bootconsole [uart0] disabled [ 3.034305] ff1a0000.serial: ttyS2 at MMIO 0xff1a0000 (irq = 39, base_baud = 1500000) is a 16550A [ 4.367601] printk: console [ttyS2] enabled [ 5.576519] dw-apb-uart ff1a0000.serial: forbid DMA for kernel console [ 6.435612] Console: switching to colour frame buffer device 300x100 $ cat /proc/consoles ttyS2 -W- (EC p a) 4:66 tty0 -WU (E ) 4:7 And on the same machine, with this patch: # Without earlycon: $ sudo dmesg | grep -i "console\|printk\|tty[0-9a-z]" | grep -v systemd [ 0.001451] Console: colour dummy device 80x25 [ 0.001821] printk: console [tty0] enabled [ 3.013821] ff1a0000.serial: ttyS2 at MMIO 0xff1a0000 (irq = 39, base_baud = 1500000) is a 16550A [ 4.328053] printk: console [ttyS2] enabled [ 5.509658] dw-apb-uart ff1a0000.serial: forbid DMA for kernel console [ 6.309330] Console: switching to colour frame buffer device 300x100 [ 6.378862] printk: switching to console [tty0] $ cat /proc/consoles tty0 -WU (EC p ) 4:7 ttyS2 -W- (E p a) 4:66 # With earlycon: $ sudo dmesg | grep -i "console\|printk\|tty[0-9a-z]" | grep -v systemd [ 0.000000] printk: bootconsole [uart0] enabled [ 0.010259] Console: colour dummy device 80x25 [ 0.015135] printk: console [tty0] enabled [ 0.019628] printk: bootconsole [uart0] disabled [ 3.037677] ff1a0000.serial: ttyS2 at MMIO 0xff1a0000 (irq = 39, base_baud = 1500000) is a 16550A [ 4.370985] printk: console [ttyS2] enabled [ 5.549226] dw-apb-uart ff1a0000.serial: forbid DMA for kernel console [ 6.364818] Console: switching to colour frame buffer device 300x100 [ 6.417589] printk: switching to console [tty0] $ cat /proc/consoles tty0 -WU (EC ) 4:7 ttyS2 -W- (E p a) 4:66 Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> --- Changes in v2: - Refresh dmesg outputs with/without earlycon for next-20200430 drivers/tty/vt/vt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index e5ffed795e4c..218171dca711 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -3588,6 +3588,13 @@ static int do_bind_con_driver(const struct consw *csw, int first, int last, pr_cont("to %s\n", desc); } +#ifdef CONFIG_VT_CONSOLE + if (!console_set_on_cmdline && deflt && conswitchp != &dummy_con) { + add_preferred_console("tty", 0, NULL); + update_console_to_preferred(); + } +#endif + retval = 0; err: module_put(owner); -- 2.26.2
next prev parent reply other threads:[~2020-04-30 16:16 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-30 16:14 [RFC PATCH v2 0/3] Prefer working VT console over SPCR and device-tree chosen stdout-path Alper Nebi Yasak 2020-04-30 16:14 ` [RFC PATCH v2 1/3] printk: Add function to set console to preferred console's driver Alper Nebi Yasak 2020-04-30 16:46 ` Andy Shevchenko 2020-05-01 1:44 ` Sergey Senozhatsky 2020-05-01 11:48 ` Alper Nebi Yasak 2020-05-13 5:35 ` Sergey Senozhatsky 2020-05-24 10:01 ` Daniel Vetter 2020-04-30 16:14 ` Alper Nebi Yasak [this message] 2020-04-30 16:14 ` [RFC PATCH v2 3/3] printk: Preset tty0 as a pseudo-preferred console Alper Nebi Yasak 2020-04-30 16:44 ` [RFC PATCH v2 0/3] Prefer working VT console over SPCR and device-tree chosen stdout-path Andy Shevchenko 2020-04-30 19:32 ` Alper Nebi Yasak 2020-05-01 1:30 ` Sergey Senozhatsky 2020-05-01 11:08 ` Alper Nebi Yasak 2020-05-01 13:16 ` Andy Shevchenko 2020-05-01 15:07 ` Alper Nebi Yasak 2020-05-13 14:37 ` Petr Mladek 2020-05-13 22:22 ` Benjamin Herrenschmidt 2020-05-15 19:27 ` Alper Nebi Yasak 2020-05-25 13:04 ` Petr Mladek
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200430161438.17640-3-alpernebiyasak@gmail.com \ --to=alpernebiyasak@gmail.com \ --cc=daniel.vetter@ffwll.ch \ --cc=ebiggers@google.com \ --cc=ghalat@redhat.com \ --cc=gregkh@linuxfoundation.org \ --cc=jslaby@suse.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-serial@vger.kernel.org \ --cc=lukas@wunner.de \ --cc=nico@fluxnic.net \ --cc=pmladek@suse.com \ --cc=rostedt@goodmis.org \ --cc=sam@ravnborg.org \ --cc=sergey.senozhatsky@gmail.com \ --subject='Re: [RFC PATCH v2 2/3] vt: Set as preferred console when a non-dummy backend is bound' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).