Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp875381ybc; Tue, 19 Nov 2019 10:41:48 -0800 (PST) X-Google-Smtp-Source: APXvYqxX2IFVZwcTFKwW91Bxo8W9gN1d78vky68K2TuSOGnq9j1k46kY9YDepCxppD66vr+Nob5A X-Received: by 2002:adf:edd2:: with SMTP id v18mr27319794wro.253.1574188908720; Tue, 19 Nov 2019 10:41:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574188908; cv=none; d=google.com; s=arc-20160816; b=wUG+m4nbm9nlep3iLQbuk3Gtv6B1pHcA8zHVaxisFTxzBpjkU+HEIDhKGqaIZI4c0j o5jJLujKbjosg4fxtZDxGOVYHE8HgsdSLRxZvKjwgBRx0uS/oM+PMnzK69fISOFoNoCI 1zUrRqTledYthyHdlOISAjPPBguWg4ATvnmDWovDWqYSUKi8Omi/KpBTW2YJ69yt+KNf v99MEygJO51qlQWZl77fyfRpuIOEa6eFcTEUBXc9i0xaSMFEOISjBQXRZUzDn8iPBSky MGLVhEKRzVTZEgw44Lf544hNSY9pvk4t7nNfLc7PXKnC30C1mMclMX3Apl0KF23VKKGj eAVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=48NxQ9DqPXE8NNblSh0ekMtCcPv6pfnlvSzVAtj6Tnc=; b=IHG2lmo1Gg0hqZX5KSyT+WmLrRGsC1MCJ0dF7FUh/Xy2H+8J+Rnrz1s8608QnZDWyq vrXg41K9oFY8iP2ktTynDzWIGngMrU+Il8zkihxAZGrvKPjgCbfkPitgnJkIe31YNA5F YmRsngZqBLnt6yvJYMOO0xlS+ijkLpkaEl37SIP/LDzkbXumSvantSSXveJXNQVli8hu KRTPnHcpoNj+XKIaHysP3RDSFhz8o8nA0ua6eLaeViyxe3EILVKXUJLyigMQmIZSJsSU EK8AdXFylutC1/d1IvSdnAByd4kkWrb70xaRtuuwxX4+gdFvVCw4BQJtLVwKDgsgrBMq UNaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=RMXEHvj3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d28si15917792edb.10.2019.11.19.10.41.25; Tue, 19 Nov 2019 10:41:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=RMXEHvj3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727421AbfKSShN (ORCPT + 99 others); Tue, 19 Nov 2019 13:37:13 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:34370 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727399AbfKSShM (ORCPT ); Tue, 19 Nov 2019 13:37:12 -0500 Received: by mail-io1-f67.google.com with SMTP id q83so24460691iod.1 for ; Tue, 19 Nov 2019 10:37:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=48NxQ9DqPXE8NNblSh0ekMtCcPv6pfnlvSzVAtj6Tnc=; b=RMXEHvj3EoauWpOTHC9DGe2xoQbch3nIQRppx+5a165AAFr2pXgjUUUcZOaEHUPwVO EbptRRN5y8bbR5Tg/n04tP0tF49AfrZSxvH38R5PT69YyQHS9ID7YHSRFS9g7N8k6cIl mnyyWcmiq7sek6yIXKi7adOO9vcgTB0Aer4/Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=48NxQ9DqPXE8NNblSh0ekMtCcPv6pfnlvSzVAtj6Tnc=; b=rY9e32dcEScV++i/VjrM2bRdqqHS9UxqyFobvm+Rt37zJEIqwxNyzJHghmHckGZJP/ hNBQIbQQOEUgkCKruuEa8ZjZHfgsbwcKAQfQBHryr6bIhoWtyHMIzHCy1z5ODl1cbELr 0PSLWHpdBPlXplSsMDdVybrLXmECioRGl+exJkfBiaZ/fD8nQbIKKKHNhI9qdiUGeZF0 KkraSyKcEVYd8Fp/+eEYAfM6CEkJsQk0WPsHfxeLwiOP7/qmdOA24TqGMGHXGqiEVXkb yg9LHzSUcRXzT5VMg9gx0dfOzC+ZAcBevL8eYOladx50uTYR1/0N9Zlm+JKJfNeEe9Cm pdBg== X-Gm-Message-State: APjAAAUD19QgZGdlGXei+dieE5aJBMaNG5tHV6mjT8W9F2RbJFWamA6p kIsrtVg0cKiwWlILJKBCMgKQhGdLs0lT4MODsqD88Q== X-Received: by 2002:a6b:7307:: with SMTP id e7mr3495492ioh.218.1574188630704; Tue, 19 Nov 2019 10:37:10 -0800 (PST) MIME-Version: 1.0 References: <20191114095737.wl5nvxu3w6p5thfc@pathway.suse.cz> <20191115043356.GA220831@google.com> <20191119113027.74lp3dsg5ftvylp4@pathway.suse.cz> In-Reply-To: <20191119113027.74lp3dsg5ftvylp4@pathway.suse.cz> From: Jonathan Richardson Date: Tue, 19 Nov 2019 10:36:59 -0800 Message-ID: Subject: Re: console output duplicated when registering additional consoles To: Petr Mladek Cc: Sergey Senozhatsky , gregkh@linuxfoundation.org, jslaby@suse.com, sergey.senozhatsky@gmail.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Scott Branden , Ray Jui , Srinath Mannam Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 19, 2019 at 3:30 AM Petr Mladek wrote: > > On Mon 2019-11-18 13:38:04, Jonathan Richardson wrote: > > On Thu, Nov 14, 2019 at 8:33 PM Sergey Senozhatsky > > 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? > > Interesting idea. Well, do early consoles have 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. > > Jonathan, have you tried this patch, please? > Does it solve your problem? I've tried it and it doesn't solve the problem. newcon is not a known console at the time I register my second console. The only thing I can do is not replay the log by not setting CON_PRINTBUFFER and I shouldn't have to do that after reading Sergey's last response.