Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3343538ybc; Mon, 18 Nov 2019 13:41:59 -0800 (PST) X-Google-Smtp-Source: APXvYqwx8q2W5DthqZ01pfC625+0ATe28bhHJLrDpPXHWdfx+r5WFYuivMj1C4pVt6ntrVMO0WIe X-Received: by 2002:a1c:6588:: with SMTP id z130mr1455002wmb.87.1574113319486; Mon, 18 Nov 2019 13:41:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574113319; cv=none; d=google.com; s=arc-20160816; b=yPtfREUKbxAwvADT2phuBN4j9sWh5mADVWOZcoDHm+G3ZLDFtw+Ysp/WkPMtCznEwX gYyCRpbdp7bmEdH2O5lgS4tHXiKpwOpBp3+AG+MhmlaNf8Eogo/mlP+UKuT+NymolPLo qLtJRQJEhvbmeGch7Au9H096ncpPdQyfKf0vA9YcT/nXOZKm2AsVkqRJrZj6MtyXIF+M LgT4V+QyMbYn41CrI/+k7Vj3wBaqWKg2S5QiQnGQ0PnvwhbGR8hpKiEoqhKRARf/E0BV FJH/UEgG/EqeQOMJZK18x9aZFSEPhnjmVPbSjDlzR8XHn18V2B0lChLQkalYAZeVPc54 6mjw== 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=s0l4HZKdtgXTRgqqDAlM3aIr0uwN5tbm3lAzGjvXOfU=; b=YRklBVRxo/AhnfTLipXeVxu1rNESe9D/WQovzWM27Fv1XIbwhpiYyVOjB+5Rggf7e4 fA9RZfksfuqTtdRYu1fUve2uplK1dWaduoviwbG6kPv1gzlfW00fglGo1Dqu+TOHHrZf gP1QdBuKY6YEP7+KF7nAclYO/ttU97QmVT/sXQyr/a04Jfc4hl4DHhw29kH0RfzSZOXn fvUUm1KC8GOOXpgpTnGgyP9mkWgcL1lFgcx5IkyYlDmu696jG1Ka3AxRy+gPdHBamvQV ANzYxghtbHSS4uLfSzq8Ta8cMfAcuCUXWub/vNresFKalEiie025cVCgZlrzq1QNA+QY lgrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=NypYyAXB; 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 h56si14712817edh.363.2019.11.18.13.41.34; Mon, 18 Nov 2019 13:41:59 -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=NypYyAXB; 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 S1726776AbfKRViS (ORCPT + 99 others); Mon, 18 Nov 2019 16:38:18 -0500 Received: from mail-io1-f66.google.com ([209.85.166.66]:35202 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726272AbfKRViS (ORCPT ); Mon, 18 Nov 2019 16:38:18 -0500 Received: by mail-io1-f66.google.com with SMTP id x21so20618739ior.2 for ; Mon, 18 Nov 2019 13:38:16 -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=s0l4HZKdtgXTRgqqDAlM3aIr0uwN5tbm3lAzGjvXOfU=; b=NypYyAXB48zj08S50RkTJaeZR3Xncpt6tIq+Kb/4Djegu9xgaoJKzsPa+MXaM8u6ie SSN73YK14XqKud+G+h7aCUnb9RS90oywdqpT7kDtyIw3NJXL+U9sjltlpeUVZs+VwSJD RlOJUTPJG1sQdOPfojNzDmPLO+HINTMODCsl4= 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=s0l4HZKdtgXTRgqqDAlM3aIr0uwN5tbm3lAzGjvXOfU=; b=JVn71w7tfApNVJULH8RGi1v2B7C6oT8SHxeyJcDauvdBPQz3kH7hmXbU1tQagSVlKG 5WluwvE2mY5ZgyTzyfRvSezgm08E9Ak+LNCQQyTIhs0QpznFQId4+bl/hyncMo65yo/B gce2QMME/gVp3V/GnQUNw/ALcQcTFAGE102mtgJ4zaTxcpPi+ubYgZpYOxGzJc5nZjX0 2QSYlrAjGU0ICRqYg1xZNDIaq1ippdYD0Bal1jZnzdAo9P3lQuYVOAHwDgdIwAGp25+y Je80ED0Xlq901vfqcVjIIHcZIt5U2iMtw5OrqffsBSPQsFN7LEzkmHcI6TBfXqFu2ypA 72cw== X-Gm-Message-State: APjAAAXxSI5AB3gSKCgVZ3VW9OafWggtxd5lJojMcwvsMr8RH11bTceE xP1bFcfhz5P6h0DCCbePnRRNH34sQZOGvnqy0UYikwH74qs= X-Received: by 2002:a02:ca57:: with SMTP id i23mr15043918jal.36.1574113095689; Mon, 18 Nov 2019 13:38:15 -0800 (PST) MIME-Version: 1.0 References: <20191114095737.wl5nvxu3w6p5thfc@pathway.suse.cz> <20191115043356.GA220831@google.com> In-Reply-To: <20191115043356.GA220831@google.com> From: Jonathan Richardson Date: Mon, 18 Nov 2019 13:38:04 -0800 Message-ID: Subject: Re: console output duplicated when registering additional consoles To: Sergey Senozhatsky Cc: Petr Mladek , 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 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? > > --- > > 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.