From patchwork Tue Dec 5 07:32:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 173766 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3266243vqy; Mon, 4 Dec 2023 23:36:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IG0MibP/MSDHtM79rTnqR0mA5MVVu4STNBAr2wF0k4y1M5IKJFdrZRtBkUJAoH/09I4U6aD X-Received: by 2002:a05:6a20:2214:b0:181:15:5755 with SMTP id u20-20020a056a20221400b0018100155755mr5057973pzb.56.1701761780485; Mon, 04 Dec 2023 23:36:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701761780; cv=none; d=google.com; s=arc-20160816; b=PAKHxEYtAnqblM8qLz7m7o3ZAj4XeOtfE+wCgLqCeQZJnB+UYFagaLuFj2poh/ubXQ Z6xf+vdp/Hjz3kXNYYl6Uldw7WlNabCtpVu5mIYTO+5vp/oBdFlKd3gAMNmteuWJrJKU WCP9blhsMhvhL/ZLhB6Ub2waSeNzmkBU/vRyEMbm5b5eSj1pkfQu92bf6N/xWgBWGSUU mUjRnq36JhpggIRqSsUsaz7OrP8PYRL56Ef25sFfkR+29eLJFYRsmazujAPpCI3JgHQ3 QbLaFvG35/o9pORsA1g5T3o/32GaozaJesj7S65OBiNq4/JrQlyNYgaX5B3UTseJiGhX Q0rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=54xGuup/UmdGELeRKFDlzpZM5tgkUbP0ZgeeXRy3GBc=; fh=OQrZIrddo55Tm+afxTOsnGwFgD38y2NNd7tU+1OGSCE=; b=VNdIBWfltTU+2B3u4odBIScG0piTd87rUoQ2IO/wgyW0Q9S7s5DG+cIEO+3UXIXcqr PpzpElfouutZaSrtSNxltmO1Kv/v5EU7ziVV417GMppHAWQ7im4uMAdME05cVnZctIpV sLNkQphWRG9P4P7FusxFo7etONC3SMaPkryqMXPb4Z0j4eXPRpEyr2usUZsCC/5//960 CjxsPa/HbVAgDS57KQA8S5mMF59YQVlnrsHRSmjZm4sMQQvfC1CVjDnVVTUPuGxuKQhm Kya2Y27uFyAiWVgUyjTYczR4XDCSAkWqJYyqhiUai+/uk2bWHKtzoSVCgOdgnDY0SCDr flag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@atomide.com header.s=25mailst header.b=dfOVSwKV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id ca23-20020a056a02069700b00578b487825asi4405374pgb.208.2023.12.04.23.36.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 23:36:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=fail header.i=@atomide.com header.s=25mailst header.b=dfOVSwKV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id BD4F280A281E; Mon, 4 Dec 2023 23:36:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344587AbjLEHgG (ORCPT + 99 others); Tue, 5 Dec 2023 02:36:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbjLEHgE (ORCPT ); Tue, 5 Dec 2023 02:36:04 -0500 Received: from mail5.25mail.st (mail5.25mail.st [74.50.62.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53094C9; Mon, 4 Dec 2023 23:36:11 -0800 (PST) Received: from localhost (91-158-86-216.elisa-laajakaista.fi [91.158.86.216]) by mail5.25mail.st (Postfix) with ESMTPSA id C124C60354; Tue, 5 Dec 2023 07:35:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=atomide.com; s=25mailst; t=1701761770; bh=fXSH3oMsVEjAG6Eqr9C167WFqrDgpOZtF9UGQTqSwU4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dfOVSwKV+A03I7NcIu++5eksbifygpC+AGE8AH7L/hcrmxSYUyUxqCRGQzrZuG+D9 yMWaHvnJDLDgzb+9gZbeorWy2I7T1+gHnUPr4oPy6AwZ2mJFK3U6fOFkTdhv+useMZ TIk4XA+NoO80oiaqyj59Qs6WnpiuB31TWWC+vRM+UXzgzHrfbsOisucKxIrHfQZ1T7 crXax9KkFI5IiZ/EfRYbp046VCSnvRjO+ptPcjgypTSynnohWD2AfFSyrCysJZd7b9 zpqMDOffXNue7nlh907Tedjh4LYVNPEyi6ifksOhUC0qGyUHBF8Da3Bpp4xqF3q8uk hxCt+oSeruevg== From: Tony Lindgren To: Greg Kroah-Hartman , Jiri Slaby , Petr Mladek , Steven Rostedt , John Ogness , Sergey Senozhatsky Cc: "David S . Miller" , Andy Shevchenko , Dhruva Gole , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Johan Hovold , Sebastian Andrzej Siewior , Vignesh Raghavendra , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH v4 4/4] serial: 8250: Add preferred console in serial8250_isa_init_ports() Date: Tue, 5 Dec 2023 09:32:36 +0200 Message-ID: <20231205073255.20562-5-tony@atomide.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231205073255.20562-1-tony@atomide.com> References: <20231205073255.20562-1-tony@atomide.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 04 Dec 2023 23:36:15 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784426560955673919 X-GMAIL-MSGID: 1784426560955673919 Prepare 8250 isa ports to drop kernel command line serial console handling from console_setup(). We need to set the preferred console in serial8250_isa_init_ports(). Otherwise the console gets initialized only later on when the hardware specific driver takes over, and console_setup() is no longer handling the ttyS related quirks. Note that this mostly affects x86 as this happens based on define SERIAL_PORT_DFNS. Signed-off-by: Tony Lindgren --- drivers/tty/serial/8250/8250_core.c | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c @@ -15,6 +15,7 @@ */ #include +#include #include #include #include @@ -517,6 +518,35 @@ static struct uart_8250_port *serial8250_setup_port(int index) return up; } +#ifdef CONFIG_SERIAL_8250_CONSOLE + +/* + * There is no struct device at this point, so let's not try to use + * serial_base_add_preferred_console(). + */ +static void __init serial8250_isa_init_preferred_console(int idx) +{ + const char *name __free(kfree); + int ret; + + name = kasprintf(GFP_KERNEL, "%s%i", serial8250_reg.dev_name, idx); + ret = add_preferred_console_match(name, serial8250_reg.dev_name, idx); + if (!ret || ret == -ENOENT) + return; + + pr_err("Could not add preferred console for %s idx %i\n", + serial8250_reg.dev_name, idx); +} + +#else + +static inline void serial8250_isa_init_preferred_console(struct uart_port *port, + int idx) +{ +} + +#endif + static void __init serial8250_isa_init_ports(void) { struct uart_8250_port *up; @@ -563,6 +593,8 @@ static void __init serial8250_isa_init_ports(void) port->irqflags |= irqflag; if (serial8250_isa_config != NULL) serial8250_isa_config(i, &up->port, &up->capabilities); + + serial8250_isa_init_preferred_console(i); } }