Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3507001ybc; Mon, 18 Nov 2019 16:36:47 -0800 (PST) X-Google-Smtp-Source: APXvYqyMm9FmCO1PuyQ3laZgw8GbXOiUBlBF5A4s413FFvizfeLuitUM5kVMeqA4tr19aDxO+I8B X-Received: by 2002:adf:f5cf:: with SMTP id k15mr37102192wrp.265.1574123807369; Mon, 18 Nov 2019 16:36:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574123807; cv=none; d=google.com; s=arc-20160816; b=A8Cn1/K03F2cesxrOh0Wosf9C5K1ZmFEgFkSzDg6XGWeonFeZjfyYbHJG6GuxRFA/h BzE5RlaVRAgN2cp8e5D10THrrOLvki5gR5PZKjPmtEtx2WVGFID3clea2/kIW3Nyz94d +MOefrZWhVguaBmGJPk6n8if8aOw4sWVU9NNZyOck8ZwgaYBFshz+DMd6f2yUnjh3baY Exl6KRwEykhrnSjbnICuZs3kKU0+WxNKgr2NGxhyjQtMwBjNPCZr/CICgT7S9Pz5n2FR cKmHB4q8h6tS451R79dtTh27pOWwzN52bDzGHIvuhkw9lkVVSqqLqA0Ny5iHdbliZ+9J w6cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=FN106ZUWWfNYwsB0PRZFSrGY6XvVfYNB96qNuOPH1T0=; b=G9Z5qEgcmJ147NXOqOZvgBIj2th2xmNd2Z/35guWnU7jCIwnb9p4R8Kgni23RXk7Tg GDcvnf9a7gwrcE+ZS4vZoQwHN2i+4i/ber7AHVtQ9w7kRNgpTPzxcRYOqStL0FxZWwVu lsF8KzdsEyqsFpwZXhk82C47hzgzIOwD0eQn4AskQ2W8pdMR1FjR0OhuvYwaBNiY3lbh 1u65x4hyr64kesQoN9g6CYKy1c+KA1LANovgNaReyX+DWaTVA9NjJ63vgTDxLREVsZIb 4Jzq2hoU732dNyaCcKtAuyoRFe/rUnOdwhjUSJm3urq5RJs1Xwvc/JkU6vHQHCELkueN TZ4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rdSa8VqB; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x37si15509134edd.228.2019.11.18.16.36.20; Mon, 18 Nov 2019 16:36:47 -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=@gmail.com header.s=20161025 header.b=rdSa8VqB; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727004AbfKSAfD (ORCPT + 99 others); Mon, 18 Nov 2019 19:35:03 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:39698 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726952AbfKSAfD (ORCPT ); Mon, 18 Nov 2019 19:35:03 -0500 Received: by mail-pj1-f65.google.com with SMTP id t103so2003660pjb.6; Mon, 18 Nov 2019 16:35:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=FN106ZUWWfNYwsB0PRZFSrGY6XvVfYNB96qNuOPH1T0=; b=rdSa8VqByecMeeFhXC93q1cjf2TEgfSBNQv2wWcWqptlTltoqwJPXcLpHIxvRDRJjf gyIgtbgAs5SHmZBp5dUcMBZyr9Ge1tyLuxPKj+ZWOpxuN0PpdQcNowZOlPqiuFae87BF joU2w8BJwq5ks1saq66N6OPfQNmgpj544Z/s5MJDNPcgWksWo4ZcSu3LumEknEQ3AsNV aE8Dfu5hQkhZaxUt7bz6F50MT7tE80bkjw6YjfK+PopBbUbxElrveWu9dcG1GWlTxrb7 wtT+qhXkoEBpwlmYcifWKrRFGzqHh8cWfKY3gdrE6hIEINoqz+lJSH1+8UDAe6htcaZz uvyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=FN106ZUWWfNYwsB0PRZFSrGY6XvVfYNB96qNuOPH1T0=; b=qRMW3x0vfgGNhjacRRD9WhA1RT9kPoCOHuSE/n1l0h2H5P7KURMBTqlenqcHqs2QcI O4+h+0nIP7vl01IogIEqsV4Y4LyVuO3onytjhvFJ6/LieZskxIroFqlzEJgviozRYn/+ iMdqeRkesUYFMKe9p7i2Zp7h2ZGJz3upq94idwEEa3MExQuiI0bisEFJ+6JOTj/HeHW1 6x+0hoLOEzHHECn1nzqWZFlkx7X7B2BXTuLkjTEG3Y7RPiyPs7f9/I92tbMBraqqHeUn SiebP0hulYFZz2RoTth/Mvt64yToLK1KOgdQW68WHPfuFxTRS0dRn9FAmMrCIoKi6AtG v9pg== X-Gm-Message-State: APjAAAXq540vvxFpLoA/DcRm8u9PT4O8SORTvXB8nbquSQUK0f/Exc3V rrevt1X5fjnWLOmuXp874k/l1wvs X-Received: by 2002:a17:902:868f:: with SMTP id g15mr31481417plo.294.1574123701089; Mon, 18 Nov 2019 16:35:01 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:250d:e71d:5a0a:9afe]) by smtp.gmail.com with ESMTPSA id f185sm23241602pfb.183.2019.11.18.16.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2019 16:34:59 -0800 (PST) Date: Tue, 19 Nov 2019 09:34:57 +0900 From: Sergey Senozhatsky To: Jonathan Richardson Cc: Sergey Senozhatsky , 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 Subject: Re: console output duplicated when registering additional consoles Message-ID: <20191119003457.GA208047@google.com> References: <20191114095737.wl5nvxu3w6p5thfc@pathway.suse.cz> <20191115043356.GA220831@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (19/11/18 13:38), Jonathan Richardson wrote: > > +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) The second 'normal' console can be, for instance, netcon - it's sort of OK to have CON_PRINTBUFFER tty and CON_PRINTBUFFER netcon consoles. Maybe > 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. This is up to the console driver to decide. > 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. Not sure I'm following. There are consoles that want all logbuf messages once those consoles are available. $ git grep "\.flags" drivers/tty/ | grep -c CON_PRINTBUFFER 72 -ss