From: Paul Burton <paul.burton@imgtec.com>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: Andreas Schwab <schwab@linux-m68k.org>,
Andrew Morton <akpm@linux-foundation.org>,
Borislav Petkov <bp@suse.de>,
Larry Finger <Larry.Finger@lwfinger.net>,
Petr Mladek <pmladek@suse.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Tejun Heo <tj@kernel.org>, <linux-kernel@vger.kernel.org>,
<linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH v2] console: use first console if stdout-path device doesn't appear
Date: Mon, 31 Oct 2016 15:50:56 +0000 [thread overview]
Message-ID: <1593250.MZpe3pfUW6@np-p-burton> (raw)
In-Reply-To: <20161031121455.23280-1-paul.burton@imgtec.com>
[-- Attachment #1: Type: text/plain, Size: 5759 bytes --]
On Monday, 31 October 2016 12:14:55 GMT Paul Burton wrote:
> If a device tree specified a preferred device for kernel console output
> via the stdout-path or linux,stdout-path chosen node properties there's
> no guarantee that it will have specified a device for which we have a
> driver. It may also be the case that we do have a driver but it doesn't
> call of_console_check() to register as a preferred console (eg. offb
> driver as used on powermac systems). In these cases try to ensure that
> we provide some console output by enabling the first usable registered
> console, which we keep track of with the of_fallback_console variable.
>
> Tested in QEMU with a PowerPC pseries_defconfig kernel.
Actually whilst this fixes the output in QEMU it has other problems. I'm still
digging...
Thanks,
Paul
>
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
> Fixes: 05fd007e4629 ("console: don't prefer first registered if DT specifies
> stdout-path") Reported-by: Andreas Schwab <schwab@linux-m68k.org>
> Reported-by: Larry Finger <Larry.Finger@lwfinger.net>
> Reported-by: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Andreas Schwab <schwab@linux-m68k.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Larry Finger <Larry.Finger@lwfinger.net>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Petr Mladek <pmladek@suse.com>
> Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: linux-kernel@vger.kernel.org
> Cc: linuxppc-dev@lists.ozlabs.org
>
> ---
>
> Changes in v2:
> - Split enable_console() out of register_console() & call in the fallback
> case. - Track the console we would have enabled as of_fallback_console.
>
> kernel/printk/printk.c | 60
> +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 55
> insertions(+), 5 deletions(-)
>
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index de08fc9..b02c00a 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -264,6 +264,13 @@ void console_set_by_of(void)
> # define of_specified_console false
> #endif
>
> +/*
> + * The first usable console, which we'll fall back to using if the system
> + * uses a device tree which indicates a stdout-path device for which we
> + * have no driver, or for which our driver doesn't call of_console_check().
> + */
> +static struct console *of_fallback_console;
> +
> /* Flag: console code may call schedule() */
> static int console_may_schedule;
>
> @@ -2598,6 +2605,8 @@ static int __init keep_bootcon_setup(char *str)
>
> early_param("keep_bootcon", keep_bootcon_setup);
>
> +static void enable_console(struct console *newcon);
> +
> /*
> * The console driver calls this routine during kernel initialization
> * to register the console printing procedure with printk() and to
> @@ -2620,7 +2629,6 @@ early_param("keep_bootcon", keep_bootcon_setup);
> void register_console(struct console *newcon)
> {
> int i;
> - unsigned long flags;
> struct console *bcon = NULL;
> struct console_cmdline *c;
>
> @@ -2657,7 +2665,9 @@ void register_console(struct console *newcon)
> * didn't select a console we take the first one
> * that registers here.
> */
> - if (preferred_console < 0 && !of_specified_console) {
> + if (preferred_console < 0 && of_specified_console) {
> + of_fallback_console = of_fallback_console ?: newcon;
> + } else if (preferred_console < 0) {
> if (newcon->index < 0)
> newcon->index = 0;
> if (newcon->setup == NULL ||
> @@ -2705,8 +2715,18 @@ void register_console(struct console *newcon)
> break;
> }
>
> - if (!(newcon->flags & CON_ENABLED))
> - return;
> + if (newcon->flags & CON_ENABLED)
> + enable_console(newcon);
> +}
> +EXPORT_SYMBOL(register_console);
> +
> +static void enable_console(struct console *newcon)
> +{
> + struct console *bcon = NULL;
> + unsigned long flags;
> +
> + if (console_drivers && console_drivers->flags & CON_BOOT)
> + bcon = console_drivers;
>
> /*
> * If we have a bootconsole, and are switching to a real console,
> @@ -2777,7 +2797,6 @@ void register_console(struct console *newcon)
> unregister_console(bcon);
> }
> }
> -EXPORT_SYMBOL(register_console);
>
> int unregister_console(struct console *console)
> {
> @@ -2839,10 +2858,41 @@ EXPORT_SYMBOL(unregister_console);
> * intersects with the init section. Note that code exists elsewhere to get
> * rid of the boot console as soon as the proper console shows up, so there
> * won't be side-effects from postponing the removal.
> + *
> + * Additionally we may be using a device tree which specifies valid
> + * stdout-path referencing a device for which we don't have a driver, or
> for + * which we have a driver that doesn't register itself as preferred
> console + * using of_console_check(). In these cases we attempt here to
> enable the + * first usable registered console, which we assigned to
> of_fallback_console. */
> static int __init printk_late_init(void)
> {
> struct console *con;
> + bool any_enabled = false;
> +
> + for_each_console(con) {
> + if (!(con->flags & CON_ENABLED))
> + continue;
> +
> + any_enabled = true;
> + break;
> + }
> +
> + if (!any_enabled && of_fallback_console) {
> + if (of_fallback_console->index < 0)
> + of_fallback_console->index = 0;
> +
> + if (!of_fallback_console->setup ||
> + !of_fallback_console->setup(of_fallback_console, NULL)) {
> + of_fallback_console->flags |= CON_ENABLED;
> + if (of_fallback_console->device) {
> + of_fallback_console->flags |= CON_CONSDEV;
> + preferred_console = 0;
> + }
> + }
> +
> + enable_console(of_fallback_console);
> + }
>
> for_each_console(con) {
> if (!keep_bootcon && con->flags & CON_BOOT) {
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
next prev parent reply other threads:[~2016-10-31 15:51 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-09 12:50 [PATCH] console: Don't prefer first registered if DT specifies stdout-path Paul Burton
2016-08-09 14:12 ` kbuild test robot
2016-08-09 15:10 ` kbuild test robot
2016-08-09 15:19 ` [PATCH v2] " Paul Burton
2016-08-09 21:57 ` Andrew Morton
2016-10-16 18:07 ` Andreas Schwab
2016-10-17 10:33 ` Paul Burton
2016-10-17 17:39 ` Andreas Schwab
2016-10-18 9:18 ` [PATCH] console: use first console if stdout-path device doesn't appear Paul Burton
2016-10-18 18:58 ` Andreas Schwab
2016-10-30 9:46 ` Andreas Schwab
2016-10-31 5:28 ` Michael Ellerman
2016-10-31 12:14 ` [PATCH v2] " Paul Burton
2016-10-31 15:50 ` Paul Burton [this message]
2016-10-31 19:21 ` Larry Finger
2016-10-31 23:09 ` Sergey Senozhatsky
2016-10-31 23:31 ` Larry Finger
2016-11-03 12:57 ` [PATCH v3] " Paul Burton
2016-11-03 17:40 ` Sergey Senozhatsky
2016-11-03 21:17 ` Paul Burton
2016-11-04 15:44 ` Sergey Senozhatsky
2016-11-04 8:05 ` Andreas Schwab
[not found] ` <8737j3n18r.fsf@concordia.ellerman.id.au>
2016-11-07 9:18 ` Paul Burton
2016-11-07 15:26 ` Larry Finger
2016-11-07 17:21 ` Paul Burton
2016-11-07 18:27 ` Larry Finger
2016-11-08 13:21 ` revert 05fd007e46296afb (was: [PATCH v3] console: use first console if stdout-path device doesn't appear) Sergey Senozhatsky
2016-11-03 13:04 ` [PATCH v2] console: use first console if stdout-path device doesn't appear Paul Burton
2016-11-01 4:39 ` Michael Ellerman
2016-10-31 15:58 ` Larry Finger
2016-10-31 12:23 ` [PATCH] " Paul Burton
2016-10-18 9:21 ` [PATCH v2] console: Don't prefer first registered if DT specifies stdout-path Paul Burton
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=1593250.MZpe3pfUW6@np-p-burton \
--to=paul.burton@imgtec.com \
--cc=Larry.Finger@lwfinger.net \
--cc=akpm@linux-foundation.org \
--cc=bp@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=pmladek@suse.com \
--cc=schwab@linux-m68k.org \
--cc=sergey.senozhatsky@gmail.com \
--cc=tj@kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).