linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Richardson <jonathan.richardson@broadcom.com>
To: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Petr Mladek <pmladek@suse.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: Mon, 18 Nov 2019 13:38:04 -0800	[thread overview]
Message-ID: <CAHrpVsWu54rKg3bGhY6WVj5d-myYxGSEkxGhOJKTyyc1EH4qOA@mail.gmail.com> (raw)
In-Reply-To: <20191115043356.GA220831@google.com>

On Thu, Nov 14, 2019 at 8:33 PM Sergey Senozhatsky
<sergey.senozhatsky.work@gmail.com> wrote:
>
> 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

Thanks. It also needs to be cleared when the second console driver is
registered (of the same type, boot or normal), not just when a normal
con replaces a bootconsole. A simple way of avoiding the problem I'm
seeing is to not even set the CON_PRINTBUFFER flag on my consoles. It
skips the replay and the output on all consoles looks fine. The flag
is only used by register_console(), although I don't think that is the
intended usage? There are no console drivers that do this.

  reply	other threads:[~2019-11-18 21:38 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
2019-11-18 21:38       ` Jonathan Richardson [this message]
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=CAHrpVsWu54rKg3bGhY6WVj5d-myYxGSEkxGhOJKTyyc1EH4qOA@mail.gmail.com \
    --to=jonathan.richardson@broadcom.com \
    --cc=gregkh@linuxfoundation.org \
    --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.work@gmail.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).