From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Jonathan Richardson <jonathan.richardson@broadcom.com>,
gregkh@linuxfoundation.org, jslaby@suse.com,
sergey.senozhatsky@gmail.com, linux-serial@vger.kernel.org,
linux-kernel@vger.kernel.org,
Scott Branden <scott.branden@broadcom.com>,
Ray Jui <ray.jui@broadcom.com>,
Srinath Mannam <srinath.mannam@broadcom.com>
Subject: Re: console output duplicated when registering additional consoles
Date: Fri, 15 Nov 2019 13:33:56 +0900 [thread overview]
Message-ID: <20191115043356.GA220831@google.com> (raw)
In-Reply-To: <20191114095737.wl5nvxu3w6p5thfc@pathway.suse.cz>
Gosh, that part of printk is really complex.
On (19/11/14 10:57), Petr Mladek wrote:
> For a proper solution we would need to match boot and real
> consoles that write messages into the physical device.
> But I am afraid that there is no support for this.
Wouldn't those have same tty driver?
---
kernel/printk/printk.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index f1b08015d3fa..a84cb20acf42 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2690,6 +2690,19 @@ static int __init keep_bootcon_setup(char *str)
early_param("keep_bootcon", keep_bootcon_setup);
+static bool known_console_driver(struct console *newcon)
+{
+ struct console *con;
+
+ for_each_console(con) {
+ if (!(con->flags & CON_ENABLED))
+ continue;
+ if (con->device && con->device == newcon->device)
+ return true;
+ }
+ return false;
+}
+
/*
* The console driver calls this routine during kernel initialization
* to register the console printing procedure with printk() and to
@@ -2828,6 +2841,9 @@ void register_console(struct console *newcon)
if (newcon->flags & CON_EXTENDED)
nr_ext_console_drivers++;
+ if (known_console_driver(newcon))
+ newcon->flags &= ~CON_PRINTBUFFER;
+
if (newcon->flags & CON_PRINTBUFFER) {
/*
* console_unlock(); will print out the buffered messages
next prev parent reply other threads:[~2019-11-15 4:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-07 1:09 console output duplicated when registering additional consoles Jonathan Richardson
2019-11-14 1:28 ` Jonathan Richardson
2019-11-14 9:57 ` Petr Mladek
2019-11-15 4:33 ` Sergey Senozhatsky [this message]
2019-11-18 21:38 ` Jonathan Richardson
2019-11-19 0:34 ` Sergey Senozhatsky
2019-11-19 18:46 ` Jonathan Richardson
2019-11-21 9:33 ` Petr Mladek
2019-11-19 11:30 ` Petr Mladek
2019-11-19 18:36 ` Jonathan Richardson
2019-11-20 0:28 ` Sergey Senozhatsky
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=20191115043356.GA220831@google.com \
--to=sergey.senozhatsky.work@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jonathan.richardson@broadcom.com \
--cc=jslaby@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=ray.jui@broadcom.com \
--cc=scott.branden@broadcom.com \
--cc=sergey.senozhatsky@gmail.com \
--cc=srinath.mannam@broadcom.com \
/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).