From patchwork Thu Aug 16 17:39:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prarit Bhargava X-Patchwork-Id: 10567939 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4815C913 for ; Thu, 16 Aug 2018 17:39:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31B822B303 for ; Thu, 16 Aug 2018 17:39:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 261FE2B30C; Thu, 16 Aug 2018 17:39:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 871AC2B303 for ; Thu, 16 Aug 2018 17:39:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728990AbeHPUjD (ORCPT ); Thu, 16 Aug 2018 16:39:03 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60352 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728702AbeHPUjD (ORCPT ); Thu, 16 Aug 2018 16:39:03 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 80C43401021C; Thu, 16 Aug 2018 17:39:12 +0000 (UTC) Received: from prarit.bos.redhat.com (prarit-guest.khw.lab.eng.bos.redhat.com [10.16.186.145]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33CA810FFE4E; Thu, 16 Aug 2018 17:39:10 +0000 (UTC) From: Prarit Bhargava To: linux-kernel@vger.kernel.org Cc: Prarit Bhargava , Mark Salter , Al Stone , "Rafael J. Wysocki" , Len Brown , Pavel Machek , x86@kernel.org, Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Kees Cook , Greg Kroah-Hartman , linux-pm@vger.kernel.org Subject: [PATCH v2] console: Add console=auto option Date: Thu, 16 Aug 2018 13:39:01 -0400 Message-Id: <20180816173902.18971-1-prarit@redhat.com> In-Reply-To: <728a8e68-ea4b-4040-a0fc-217df4f1928d@redhat.com> References: <728a8e68-ea4b-4040-a0fc-217df4f1928d@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 16 Aug 2018 17:39:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 16 Aug 2018 17:39:12 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'prarit@redhat.com' RCPT:'' Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ACPI may contain an SPCR table that defines a default system console. On ARM if the table is present then the SPCR console is enabled by default. On x86 the SPCR console is used if 'earlycon' (no parameters) is specified as a kernel parameter and is used only as the early console. To use the SPCR data as a console a user must boot with 'earlycon', grep logs & specify a console= kernel parameter, and then reboot again. Add 'console=auto' that enables a firmware or hardware console, and on x86 enable the SPCR console if 'console=auto' is specified. Tested on systems with and without an ACPI SPCR. The following kernel parameters were also tested: console=ttyS0,115200 works earlycon works (early console only) console=auto works (full console as expected) no console or earlycon arguments works (no output as expected) v2: Fix prototype. Signed-off-by: Prarit Bhargava Cc: Mark Salter Cc: Al Stone Cc: "Rafael J. Wysocki" Cc: Len Brown Cc: Pavel Machek Cc: x86@kernel.org Cc: Petr Mladek Cc: Sergey Senozhatsky Cc: Steven Rostedt Cc: Kees Cook Cc: Greg Kroah-Hartman Cc: linux-pm@vger.kernel.org --- Documentation/admin-guide/kernel-parameters.txt | 1 + arch/x86/kernel/acpi/boot.c | 5 +++++ include/linux/console.h | 1 + kernel/printk/printk.c | 10 ++++++++++ 4 files changed, 17 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index a32f2a126791..dd057224f33b 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -635,6 +635,7 @@ hvc Use the hypervisor console device . This is for both Xen and PowerPC hypervisors. + auto [X86] Enable ACPI SPCR console If the device connected to the port is not a TTY but a braille device, prepend "brl," before the device type, for instance diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index 3b20607d581b..fb2616ba3b21 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -1771,3 +1771,8 @@ void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size) e820__range_add(addr, size, E820_TYPE_ACPI); e820__update_table_print(); } + +void __init arch_console_setup(void) +{ + acpi_parse_spcr(false, true); +} diff --git a/include/linux/console.h b/include/linux/console.h index dfd6b0e97855..c2a6dde9a799 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -181,6 +181,7 @@ extern int is_console_locked(void); extern int braille_register_console(struct console *, int index, char *console_options, char *braille_options); extern int braille_unregister_console(struct console *); +void arch_console_setup(void); #ifdef CONFIG_TTY extern void console_sysfs_notify(void); #else diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 247808333ba4..bdd53858664b 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2078,6 +2078,11 @@ static int __init console_msg_format_setup(char *str) } __setup("console_msg_format=", console_msg_format_setup); +void __init __weak arch_console_setup(void) +{ + return; +} + /* * Set up a console. Called via do_early_param() in init/main.c * for each "console=" parameter in the boot command line. @@ -2088,6 +2093,11 @@ static int __init console_setup(char *str) char *s, *options, *brl_options = NULL; int idx; + if (!strcmp(str, "auto")) { + arch_console_setup(); + return 1; + } + if (_braille_console_setup(&str, &brl_options)) return 1;