Received: by 10.213.65.68 with SMTP id h4csp1366368imn; Wed, 14 Mar 2018 19:06:18 -0700 (PDT) X-Google-Smtp-Source: AG47ELteXk8Mj3qVxwvjPYGlTM2otM9l3mnB+7BgJ7XWzAVwbNOXEc8xbasCaWNl0FetD36OzhEv X-Received: by 2002:a17:902:1486:: with SMTP id k6-v6mr6123080pla.376.1521079578128; Wed, 14 Mar 2018 19:06:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521079578; cv=none; d=google.com; s=arc-20160816; b=buAdqMC6TAuVbabM1L2rIa8boY28uIcxwAeK80aLA05QLLuW2+SuNzdq6KAt4s1CXD 3uvvhJtceEFtrqsZu0xe9/ti5INJNwIZH2Ql6+D2jCLuUZqZ0Yy1pzjxdWGOZVt08L2m XEyq2kHNJKMYEQvS3WoR0EY/9IRtwhs++jkSlVjhwtCeFbTL9iD26g9yQoDzqM77AR7L jk8d7pVQNtLjPHNlMLIvB5iPKWdLWlK4PySbpqz6FHd1jawNolbIVz0DGM5elRzq2taz 5fbwqoXU76yjDgwvYScsj6p/YRd+grCUnA5Pch4uNwEh2iPSrAHV8uCm+Im/5jCP08iV tRew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=I/SalXWyRJ/dyODSLks4sLP8EjMRtHl7xxxotkgiXAE=; b=z26y/5aZ2cc10nk49DyAPr3crsnQqqBvF8hhvJ5gvbdc7ONNENQFjHXMrUWm/nJ8lx WUyB4My3uyKkXi7fAeKMkBVN4/ddvCwxJRFrSktCKilQWolTNXNtme6qnFkDX9z6ZD9P 3MG+fILlwGglElWN8oTnuuwXHzGw10gAHkRWsmf7CVH8tAm2e2S+6+g5U20uQBFnS4Rn Swq9vX/qv2pf/e2MKNajcanytbuukn7eC9CiEv47TuQvzl/bo4EQ5F4J79QDXbM9BZoi M52tfM80SLvHG+BMHcHUAJIkW3Rm4oEAb/3aPs+UQyMu4EwlQYzlBPtPluMx2HIQkc7v L/WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ALE+bnc7; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b81si3096897pfj.22.2018.03.14.19.06.04; Wed, 14 Mar 2018 19:06:18 -0700 (PDT) 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=@chromium.org header.s=google header.b=ALE+bnc7; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751970AbeCOCFC (ORCPT + 99 others); Wed, 14 Mar 2018 22:05:02 -0400 Received: from mail-ot0-f195.google.com ([74.125.82.195]:41151 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751731AbeCOCE5 (ORCPT ); Wed, 14 Mar 2018 22:04:57 -0400 Received: by mail-ot0-f195.google.com with SMTP id i28-v6so660313otf.8 for ; Wed, 14 Mar 2018 19:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I/SalXWyRJ/dyODSLks4sLP8EjMRtHl7xxxotkgiXAE=; b=ALE+bnc7qdZt6RUtWVYMCcnNjI8AAQfE9zaBIng1LrlmACwmv9FXH8EpYTzw/Z8P3e Ny4KJlccHwc29DBPhbLuAAj1+nG19jTYcmLKChRv/icCg4gRQpRCcTeMn23EuvVS27/E Jyx1vFiR7SprswotZNl0lty0Ic/A7yAj/BH6s= 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:in-reply-to :references; bh=I/SalXWyRJ/dyODSLks4sLP8EjMRtHl7xxxotkgiXAE=; b=nFD34op5FywDHtZd/YVTdvUDko9h8TMn+gQL2VWtmHVR2fRmfn97th7xczg54uGntK yuwsb/UBa/K19qHrNGtsCP2hE9nj398aXqc4MlHxgMSQAMel4ownZ6onIjn3INgTSm5e WgkGzLohZ1CtJqdW4PNT3lkRa2ZM9O6SIHHx2qIDhUbwC31HLiA3RFBzf4xFoqpCShdS EaTTd3YeoXLddXYp4YqOU2qRJs/CqxqFc481R7Z5bArbgmA42AKu8cznpGTG5t4p96BD A81/CmG+AzYmrRELbFbJgRaPLCCZGYMqp7KTWMhJxiXWPKrbKbJaETi3x1hchYNMLVld 2a1A== X-Gm-Message-State: AElRT7G7itax0nBW6oIlSDJKubK/4+mQUQNINF4pIJGBjGqSil6F3nIX u3BmFGXt58lFpz8lwNMIThUb82UkZeI= X-Received: by 10.157.46.112 with SMTP id c45mr4107027otd.124.1521079497178; Wed, 14 Mar 2018 19:04:57 -0700 (PDT) Received: from djkurtz2.bld.corp.google.com ([2620:15c:183:0:1cfd:61a5:7215:5f9c]) by smtp.gmail.com with ESMTPSA id j142sm1642773oih.7.2018.03.14.19.04.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Mar 2018 19:04:56 -0700 (PDT) From: Daniel Kurtz To: Greg Kroah-Hartman Cc: adurbin@chromium.org, linux-kernel@vger.kernel.org, Daniel Kurtz , "Rafael J. Wysocki" , Len Brown , Jiri Slaby , Andy Shevchenko , Kees Cook , Matthias Brugger , David Howells , Allen Pais , Sean Young , Douglas Anderson , Matt Redfearn , Jeffy Chen , Marc Gonzalez , linux-acpi@vger.kernel.org (open list:ACPI), linux-serial@vger.kernel.org (open list:SERIAL DRIVERS) Subject: [PATCH v3 3/3] serial: core: Allow skipping old serial port initialization Date: Wed, 14 Mar 2018 20:04:45 -0600 Message-Id: <20180315020445.150604-4-djkurtz@chromium.org> X-Mailer: git-send-email 2.16.2.804.g6dcf76e118-goog In-Reply-To: <20180315020445.150604-1-djkurtz@chromium.org> References: <20180315020445.150604-1-djkurtz@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The old_serial_port global array in 8250_core is supposed to hold an entry for each serial port on the system that cannot be discovered via a standard enumeration mechanism (aka ACPI/PCI/DTS). The array is populated at compile-time from the value specified in the SERIAL_PORT_DFNS macro. This macro is defined in arch/serial.h. For x86, this macro is currently unconditionally initialized to supply four ioport UARTs (0x3F8, 0x2F8, 0x3E8, 0x2E8). However, not all x86 CPUs have these four ioport UARTs. For example, the UARTs on AMD Carrizo and later are separate memory mapped Designware IP blocks. Fairly early in boot the console_initcall univ8250_console_init iterates over this array and installs these old UARTs into the global array serial8250_ports. Further, it attempts to register them for use as the console. In other words, if, for example, the kernel commandline has console=ttyS0, the console will be switched over to one of these non-existent UARTs. Only later, when the real UART drivers are probed and their devices are instantiated will the console switch back over to the proper UART. This is noticeable when using earlycon, since part of the serial console log will appear to disappear (when the bogus old takes over) and then re-appear (when the real UART finally gets registered for the console). The problem is even more noticable when *not* using earlycon, since in this case the entire console output is missing, having been incorrectly played back to the non-existing serial port. Create a global variable to allow skipping old serial port initialization and wire it up to the AMDCZ ACPI SPCR quirk and the special amdcz earlycon setup handler. Signed-off-by: Daniel Kurtz --- Changes since v1: * Rename variable to serial8250_skip_old_ports * Also set variable in acpi/spcr to support no-earlycon case. Changes since v2: * Added IS_ENABLED(CONFIG_SERIAL_825) and removed the .h #ifdef as suggested by Kees Cook. drivers/acpi/spcr.c | 3 +++ drivers/tty/serial/8250/8250_core.c | 6 ++++++ drivers/tty/serial/8250/8250_early.c | 1 + include/linux/serial_8250.h | 2 ++ 4 files changed, 12 insertions(+) diff --git a/drivers/acpi/spcr.c b/drivers/acpi/spcr.c index 52d840d0e05b..d1affdf2bc37 100644 --- a/drivers/acpi/spcr.c +++ b/drivers/acpi/spcr.c @@ -14,6 +14,7 @@ #include #include #include +#include #include /* @@ -208,6 +209,8 @@ int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console) } if (amdcz_present(table)) { + if (IS_ENABLED(CONFIG_SERIAL_8250)) + serial8250_skip_old_ports = true; if (enable_earlycon) uart = "amdcz"; } diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c index 9342fc2ee7df..a04da392a251 100644 --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c @@ -66,6 +66,9 @@ static unsigned int skip_txen_test; /* force skip of txen test at init time */ #define SERIAL_PORT_DFNS #endif +bool serial8250_skip_old_ports; +EXPORT_SYMBOL(serial8250_skip_old_ports); + static const struct old_serial_port old_serial_port[] = { SERIAL_PORT_DFNS /* defined in asm/serial.h */ }; @@ -537,6 +540,9 @@ static void __init serial8250_isa_init_ports(void) if (share_irqs) irqflag = IRQF_SHARED; + if (serial8250_skip_old_ports) + return; + for (i = 0, up = serial8250_ports; i < ARRAY_SIZE(old_serial_port) && i < nr_uarts; i++, up++) { diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c index c6bf971a6038..288d2be82990 100644 --- a/drivers/tty/serial/8250/8250_early.c +++ b/drivers/tty/serial/8250/8250_early.c @@ -202,6 +202,7 @@ static int __init early_amdcz_setup(struct earlycon_device *dev, { struct uart_port *port = &dev->port; + serial8250_skip_old_ports = true; port->uartclk = 48000000; return early_serial8250_setup(dev, opt); diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h index a27ef5f56431..ae739c34546f 100644 --- a/include/linux/serial_8250.h +++ b/include/linux/serial_8250.h @@ -136,6 +136,8 @@ struct uart_8250_port { struct uart_8250_em485 *em485; }; +extern bool serial8250_skip_old_ports; + static inline struct uart_8250_port *up_to_u8250p(struct uart_port *up) { return container_of(up, struct uart_8250_port, port); -- 2.16.2.804.g6dcf76e118-goog