From patchwork Tue Apr 29 22:00:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 4089431 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 224649F271 for ; Tue, 29 Apr 2014 22:03:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 022672021B for ; Tue, 29 Apr 2014 22:03:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CABCC20200 for ; Tue, 29 Apr 2014 22:03:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WfG5E-0006WP-T6; Tue, 29 Apr 2014 22:01:00 +0000 Received: from mail-ig0-x22e.google.com ([2607:f8b0:4001:c05::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WfG5B-0006T5-Me for linux-arm-kernel@lists.infradead.org; Tue, 29 Apr 2014 22:00:58 +0000 Received: by mail-ig0-f174.google.com with SMTP id h18so6712649igc.13 for ; Tue, 29 Apr 2014 15:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=gKNrzSNpndOKWJLNjx8NmuqQNdGvFbWqu+s5Ze0lhNE=; b=QY8fgVj/n/A/l4dICwTfQJc9HDOlDJkYWzVLHx5tbNymDT9gCHrdRKP9hvJTlOZ80c vHGc3Cj36/Ut5ZBHLJ1NpIBOy+DI0qZ+ulFnpQTRDAuNZJGV6H6gbmcmFvJOE09djbaX opYF7bkq4K2M16KlNkRzSfKNFjQ7x3AZ5BixRQQlzw699yFYr38eL1kBj5Qaf+BpJRPZ FD5GC3fcxFiyhA4QuDAPn7o2+J3vhFL1L1QZPw8/doNVR5Td3JhuXTez5Aaj4Vx6sApu GVx50SQUndDMRyRfanlps3t4BlwVaLXtceP9b8IDDS9scbzFR11LTmT8Aq4aVCJAVKra TMXg== MIME-Version: 1.0 X-Received: by 10.50.57.109 with SMTP id h13mr33957188igq.3.1398808834831; Tue, 29 Apr 2014 15:00:34 -0700 (PDT) Received: by 10.64.60.232 with HTTP; Tue, 29 Apr 2014 15:00:34 -0700 (PDT) In-Reply-To: References: <1397859600-11507-1-git-send-email-robherring2@gmail.com> <1397859600-11507-4-git-send-email-robherring2@gmail.com> Date: Tue, 29 Apr 2014 15:00:34 -0700 X-Google-Sender-Auth: 5wGiUtswvxM8e_OUQ1-42Gs1Km4 Message-ID: Subject: Re: [PATCH v2 3/7] tty/serial: convert 8250 to generic earlycon From: Yinghai Lu To: Rob Herring , "H. Peter Anvin" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140429_150057_838830_E90ED38A X-CRM114-Status: GOOD ( 27.91 ) X-Spam-Score: 0.0 (/) Cc: Russell King , Arnd Bergmann , Greg Kroah-Hartman , Will Deacon , Linux Kernel Mailing List , "linux-serial@vger.kernel.org" , Catalin Marinas , Andrew Morton , Jiri Slaby , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Apr 29, 2014 at 1:41 PM, Rob Herring wrote: > On Tue, Apr 29, 2014 at 1:22 PM, Yinghai Lu wrote: >> >> You want to obsolete "console=uart,io,0x3f8,115200n8" ? >> >> Let's check with Andrew. He suggested to use uart and uart8250 at that time. > > No, that is not what I'm saying. For the 2 callers of > setup_early_serial8250_console which are crafting a console string > from firmware data, they can and do use uart8250. I don't expect this > mechanism for setting up early console to expand to other users. The > whole point of this series is to allow any uart to be supported for > earlycon. For anyone using the kernel command line, both uart and > uart8250 are still supported. That is confusing, why not keeping them consistent? I posted one patch before about "early early console for x86", and it is in my local tree for some time.support both "uart,io" and "uart8250,io". Peter, Can you check that patch again? --- updated version attached. and inlined. Thanks Yinghai Subject: [PATCH -v4] x86: Setup early console as early as possible in x86_start_kernel() Analyze "console=uart8250,io,0x3f8,115200n8" in i386_start_kernel/x86_64_start_kernel, and call setup_early_serial8250_console() to init early serial console. Only can handle io port kind of 8250, because mmio need ioremap. Use boot_params.hdr.version instead of adding another variable, Suggested by hpa. Also need to apply this one after x86 memblock patchset. Signed-off-by: Yinghai Lu --- arch/x86/include/asm/setup.h | 2 ++ arch/x86/kernel/head.c | 26 ++++++++++++++++++++++++++ arch/x86/kernel/head32.c | 1 + arch/x86/kernel/head64.c | 5 ++++- kernel/printk/printk.c | 11 +++++++---- 5 files changed, 40 insertions(+), 5 deletions(-) Subject: [PATCH -v4] x86: Setup early console as early as possible in x86_start_kernel() Analyze "console=uart8250,io,0x3f8,115200n8" in i386_start_kernel/x86_64_start_kernel, and call setup_early_serial8250_console() to init early serial console. Only can handle io port kind of 8250, because mmio need ioremap. Use boot_params.hdr.version instead of adding another variable, Suggested by hpa. Also need to apply this one after x86 memblock patchset. Signed-off-by: Yinghai Lu --- arch/x86/include/asm/setup.h | 2 ++ arch/x86/kernel/head.c | 26 ++++++++++++++++++++++++++ arch/x86/kernel/head32.c | 1 + arch/x86/kernel/head64.c | 5 ++++- kernel/printk/printk.c | 11 +++++++---- 5 files changed, 40 insertions(+), 5 deletions(-) Index: linux-2.6/arch/x86/include/asm/setup.h =================================================================== --- linux-2.6.orig/arch/x86/include/asm/setup.h +++ linux-2.6/arch/x86/include/asm/setup.h @@ -49,6 +49,8 @@ static inline void x86_acpi_override_fin #endif extern unsigned long saved_video_mode; +int setup_early_serial8250_console(char *cmdline); +void setup_early_console(void); extern void reserve_standard_io_resources(void); extern void i386_reserve_resources(void); Index: linux-2.6/arch/x86/kernel/head.c =================================================================== --- linux-2.6.orig/arch/x86/kernel/head.c +++ linux-2.6/arch/x86/kernel/head.c @@ -69,3 +69,29 @@ void __init reserve_ebda_region(void) /* reserve all memory between lowmem and the 1MB mark */ memblock_reserve(lowmem, 0x100000 - lowmem); } + +void __init setup_early_console(void) +{ +#ifdef CONFIG_SERIAL_8250_CONSOLE + char constr[64], *p, *q; + + /* Can not handle mmio type 8250 uart yet, too early */ + p = strstr(boot_command_line, "console=uart8250,io,"); + if (!p) + p = strstr(boot_command_line, "console=uart,io,"); + if (!p) + return; + + p += 8; /* sizeof "console=" */ + q = strchr(p, ' '); + if ((q - p) >= sizeof(constr)) + return; + + memset(constr, 0, sizeof(constr)); + memcpy(constr, p, q - p); + + lockdep_init(); + + setup_early_serial8250_console(constr); +#endif +} Index: linux-2.6/arch/x86/kernel/head32.c =================================================================== --- linux-2.6.orig/arch/x86/kernel/head32.c +++ linux-2.6/arch/x86/kernel/head32.c @@ -32,6 +32,7 @@ static void __init i386_default_early_se void __init i386_start_kernel(void) { sanitize_boot_params(&boot_params); + setup_early_console(); /* Call the subarch specific early setup function */ switch (boot_params.hdr.hardware_subarch) { Index: linux-2.6/arch/x86/kernel/head64.c =================================================================== --- linux-2.6.orig/arch/x86/kernel/head64.c +++ linux-2.6/arch/x86/kernel/head64.c @@ -166,6 +166,7 @@ void __init x86_64_start_kernel(char * r load_idt((const struct desc_ptr *)&idt_descr); copy_bootdata(__va(real_mode_data)); + setup_early_console(); /* * Load microcode early on BSP. @@ -187,8 +188,10 @@ void __init x86_64_start_kernel(char * r void __init x86_64_start_reservations(char *real_mode_data) { /* version is always not zero if it is copied */ - if (!boot_params.hdr.version) + if (!boot_params.hdr.version) { copy_bootdata(__va(real_mode_data)); + setup_early_console(); + } reserve_ebda_region(); Index: linux-2.6/kernel/printk/printk.c =================================================================== --- linux-2.6.orig/kernel/printk/printk.c +++ linux-2.6/kernel/printk/printk.c @@ -2227,11 +2227,14 @@ void register_console(struct console *ne struct console_cmdline *c; if (console_drivers) - for_each_console(bcon) - if (WARN(bcon == newcon, - "console '%s%d' already registered\n", - bcon->name, bcon->index)) + for_each_console(bcon) { + /* not again */ + if (bcon == newcon) { + printk(KERN_INFO "console '%s%d' already registered\n", + bcon->name, bcon->index); return; + } + } /* * before we register a new CON_BOOT console, make sure we don't