From patchwork Thu Mar 2 13:11:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksey Makarov X-Patchwork-Id: 94778 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp156083qgd; Thu, 2 Mar 2017 05:15:32 -0800 (PST) X-Received: by 10.84.169.36 with SMTP id g33mr18554017plb.36.1488460531938; Thu, 02 Mar 2017 05:15:31 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w21si7407776pgf.318.2017.03.02.05.15.31; Thu, 02 Mar 2017 05:15:31 -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=@linaro.org; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752890AbdCBNPY (ORCPT + 25 others); Thu, 2 Mar 2017 08:15:24 -0500 Received: from mail-lf0-f48.google.com ([209.85.215.48]:33477 "EHLO mail-lf0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752749AbdCBNPT (ORCPT ); Thu, 2 Mar 2017 08:15:19 -0500 Received: by mail-lf0-f48.google.com with SMTP id a6so33461252lfa.0 for ; Thu, 02 Mar 2017 05:15:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=YKQo8DJrakIx0cGVYUMAWuOlFX1C2Pqyk8z/FgiM4/A=; b=dm6oKJXbVGhZ8+AVV32BJrLszkp1IVAeJR0RAACs46wqvz0ZunNFKSlQ6pBiyQAMCZ D1xbCyuXfTgbT5L86gyUpagwWKRL0s1x8/2PEBmeAU+Z//o/gmQDzLZME5rI08b7WeiR 4nqD9F1I/iWKek8Guf5n6eE047HfPPsp7KRKM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YKQo8DJrakIx0cGVYUMAWuOlFX1C2Pqyk8z/FgiM4/A=; b=iqDSgFVNfgrOz8ySxM0UymeyzxGwNaHcJ6Qkr5gigbi2eEFwQS8mVEXrV+iWwXHvgd hSdkvn2iXunCAAdH9cH3MERyFXU9yAi5XCXEOeaJ/I/oYEbkyX5XBMC/ZEXXMkGT9pGE UTpqY9vN9B7ThKyowwHqn58NOERrsT8KUN5CUrD0QxnQrZK32bn8aniiiLtlKyU/tjRT TWKNgLHUqiACorCaxOq1uceiMMiyNzelzcFDalGqxvFnqwgxEfGZDjDd990iPtpulz51 ZW9gysjSM/9mR9SOEvxlWuB7PnuzKC5Lxt4JzZksUxeJGBAbQCJCmMXHM1z3d0T+1g8K Udww== X-Gm-Message-State: AMke39kz/JNPk4PiNULfRv/CL8QFVNTWatQXuVq/wctA8QUb9k9A2bUYL5p+PvuOTU/S/Rn2 X-Received: by 10.25.215.89 with SMTP id o86mr4802164lfg.92.1488460517217; Thu, 02 Mar 2017 05:15:17 -0800 (PST) Received: from localhost.localdomain (nivc-213.auriga.ru. [80.240.102.213]) by smtp.gmail.com with ESMTPSA id c69sm1696062lfe.23.2017.03.02.05.15.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 05:15:16 -0800 (PST) From: Aleksey Makarov To: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Aleksey Makarov , Sudeep Holla , Greg Kroah-Hartman , Peter Hurley , Jiri Slaby , Robin Murphy , Steven Rostedt , "Nair, Jayachandran" Subject: [PATCH v2 0/3] printk: fix double printing with earlycon Date: Thu, 2 Mar 2017 16:11:31 +0300 Message-Id: <20170302131153.22733-1-aleksey.makarov@linaro.org> X-Mailer: git-send-email 2.11.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. v1: https://lkml.kernel.org/r/20170301161347.4202-1-aleksey.makarov@linaro.org [1] https://lkml.kernel.org/r/1485963998-921-1-git-send-email-sudeep.holla@arm.com commit aea9a80ba98a ("tty: serial: pl011: add ttyAMA for matching pl011 console") [2] https://lkml.kernel.org/r/20170301152304.29635-1-aleksey.makarov@linaro.org [3] https://lkml.kernel.org/r/1455299022-11641-2-git-send-email-aleksey.makarov@linaro.org Aleksey Makarov (3): printk: fix name/type/scope of preferred_console var printk: rename selected_console -> preferred_console printk: fix double printing with earlycon kernel/printk/printk.c | 63 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 22 deletions(-) -- 2.11.1