Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752468AbdCNQS3 (ORCPT ); Tue, 14 Mar 2017 12:18:29 -0400 Received: from foss.arm.com ([217.140.101.70]:36678 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751073AbdCNQS1 (ORCPT ); Tue, 14 Mar 2017 12:18:27 -0400 Subject: Re: [PATCH v2 0/3] printk: fix double printing with earlycon To: Aleksey Makarov , linux-serial@vger.kernel.org References: <20170302131153.22733-1-aleksey.makarov@linaro.org> Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Peter Hurley , Jiri Slaby , Robin Murphy , Steven Rostedt , "Nair, Jayachandran" From: Sudeep Holla Organization: ARM Message-ID: Date: Tue, 14 Mar 2017 16:17:59 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170302131153.22733-1-aleksey.makarov@linaro.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1896 Lines: 49 Hi Aleksey, (Sorry for the delayed response, was on vacation) On 02/03/17 13:11, Aleksey Makarov wrote: > If a console was specified by ACPI SPCR table _and_ command line parameters like > "console=ttyAMA0" _and_ "earlycon" were specified, then log messages > appear twice. > > This issue was addressed in the patch [1] but the approach was wrong and > a revert [2] was suggested. > > First two patches "printk: fix name/type/scope of preferred_console var" and > "printk: rename selected_console -> preferred_console" were sent sent some > time ago as one patch "printk: fix name and type of some variables" [3]. > They fix name/type/scope of some variables without changing the logic. > > The real fix is in the second patch. The root cause is that the code traverses > the list of specified consoles (the `console_cmdline` array) and stops at the > first match. But it may happen that the same console is referred by > the elements of this array twice: > > pl011,mmio,0x87e024000000,115200 -- from SPCR > ttyAMA0 -- from command line > > but in this case `preferred_console` points to the second entry and > the flag CON_CONSDEV is not set, so bootconsole is not deregistered. > > To fix that, match the console against the `console_cmdline` entry > pointed by `preferred_console` instead of the first match. > > v2: > - split the patch that renames `selected_console` and `preferred_console` > into two patches (Steven Rostedt) > - add a comment explaining why we need a separate match to check for > preferred_console (Steven Rostedt) > - v1 of this patchset changed the logic of console initialization a bit. > That could lead to bugs/incompatibilities. Use the exactly the same > logic as in the original code. > Tested the series(v3 of patch 3) and works as expected. Thanks for the proper fix. Tested-by: Sudeep Holla -- Regards, Sudeep