From patchwork Mon Dec 18 07:09:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 180173 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1076130dyi; Sun, 17 Dec 2023 23:15:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFn1u6VLdFaR9WckZQmVU65z4MoqoAl6q1dxzhd4MrERSxb0uw2Nhwr2JLUsLQVLpDhp+yS X-Received: by 2002:a17:90a:d253:b0:28b:460e:e532 with SMTP id o19-20020a17090ad25300b0028b460ee532mr612268pjw.40.1702883728039; Sun, 17 Dec 2023 23:15:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702883728; cv=none; d=google.com; s=arc-20160816; b=P8rkv4XMt0zwYJL7CWDHeLVw+qLsokYDJiQ+EoQX0G17i+M00dd7tXVwldQ/d94eX1 y/LaY42+kgXII4rDOZRiOkctbZGsGp4a5/J59ibQkFwKMAn1nNPyZJ53LNFOt0ZqDgJr btDOMD58KwBS6P56P83Mnp5cDkU7okpWOYnUHsSH2oPg+k0O6sqBWPixgS6uyHZyp9Ni 3/0BvAdeUgEmahMDhfmbrIjf/HWNUIThOSwuyjQ4pzk6fOz7Q87tiuD1+rnowKESJMSC apJtXyCA8DjHCifxaiuZhDukJPNnb2rzUyBvUngpBj+RaEHbKWcDnQ3+dpGzuhThfyA9 Bjxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JnXO/R0Qsx3ADz59naq/5Fh84jL7/qgZDH/6FO2+A+Q=; fh=OQrZIrddo55Tm+afxTOsnGwFgD38y2NNd7tU+1OGSCE=; b=BLBWTRg6ArlonO5U0kqGaj/86Drvo9AYSmYv6OHVAPhAUt01ET1cFtpTwGfrBQa+y6 dhB3LHtejd0gS8UBTY8FLTWcwanGxbHWYGLEOl0Fs+9mai87UeVRyDJK5exR73RjxgsH stEdCJp5tYNOdaCmKHBsfS81iQTD4YX2OOuAtuTEvMVOIoAazqF93C4HPQStpCIue1Tx N9lXHsJ+gABwtqHxyukzr7SlUXu3ugbJwBq+KqvXDPdp9rU45hzZN+3+LwYTXQ1yPYRE 54VCDjdGGaVX4ydJEEhuNnNiX7Lmuw6GIB6PVZhf3Lc2f09XVo+FvxMrKBVnBBY7BNE+ Kocw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@atomide.com header.s=25mailst header.b=ndXogUuI; spf=pass (google.com: domain of linux-kernel+bounces-3088-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3088-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i20-20020a17090ad35400b0028b158f2c52si6685657pjx.96.2023.12.17.23.15.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 23:15:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3088-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@atomide.com header.s=25mailst header.b=ndXogUuI; spf=pass (google.com: domain of linux-kernel+bounces-3088-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3088-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 132F128211A for ; Mon, 18 Dec 2023 07:15:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8623FC8F1; Mon, 18 Dec 2023 07:15:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=atomide.com header.i=@atomide.com header.b="ndXogUuI" X-Original-To: linux-kernel@vger.kernel.org Received: from mail5.25mail.st (mail5.25mail.st [74.50.62.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5B3CF9C1; Mon, 18 Dec 2023 07:14:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomide.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=atomide.com Received: from localhost (91-158-86-216.elisa-laajakaista.fi [91.158.86.216]) by mail5.25mail.st (Postfix) with ESMTPSA id D2F55603E6; Mon, 18 Dec 2023 07:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=atomide.com; s=25mailst; t=1702883696; bh=uFBmtVSwmPLt0wPwCU7cDBhUtKLWh7AsC+S0n1T9l/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ndXogUuI9gQ7MSv6nnSm1nCRDOfn6//M3fDHZ9Es31/TLhdgyzB+yBP6CQCIZkIu+ XBth8x4UXUpkjKSP7L8cIqrasBtGg4Lq4j4sPBBeHkCb3v9QDJNQQcH4+0cUxAla0T roX1oaGQTsKMmAj684PhtrcVk6PyqNC0W7j0HEnvQVRS5axIPycRcev3wMw1W8CGVw q7/zLsBaAq8+fJ6o9vKHvVJDZxhnpO+HJoN/Bz+xpgRwmJOAnb9fnhUGk/avqMzrjb bCZtBNopPhwfWTqLwHvKOgtS6nomMifunZQLFHgT5Z6dJPPnMLGflp3Pu6NP2J7V24 3x8UttRCCFxFQ== 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: [RFC PATCH v5 6/6] serial: 8250: Add preferred console in serial8250_isa_init_ports() Date: Mon, 18 Dec 2023 09:09:53 +0200 Message-ID: <20231218071020.21805-7-tony@atomide.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218071020.21805-1-tony@atomide.com> References: <20231218071020.21805-1-tony@atomide.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785603007946660453 X-GMAIL-MSGID: 1785603007946660453 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() to drop a dependency to setup_console() handling the ttyS related quirks. Otherwise when console_setup() handles the ttyS related options, console gets enabled only at driver probe time. 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 | 5 +++++ drivers/tty/serial/serial_base.h | 8 ++++++++ drivers/tty/serial/serial_base_bus.c | 21 +++++++++++++++++++++ 3 files changed, 34 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 @@ -41,6 +42,8 @@ #include +#include "../serial_base.h" /* For serial_base_add_isa_preferred_console() */ + #include "8250.h" /* @@ -563,6 +566,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); + + serial_base_add_isa_preferred_console(serial8250_reg.dev_name, i); } } diff --git a/drivers/tty/serial/serial_base.h b/drivers/tty/serial/serial_base.h --- a/drivers/tty/serial/serial_base.h +++ b/drivers/tty/serial/serial_base.h @@ -51,6 +51,8 @@ void serial_core_unregister_port(struct uart_driver *drv, struct uart_port *port int serial_base_add_preferred_console(struct uart_driver *drv, struct uart_port *port); +int serial_base_add_isa_preferred_console(const char *name, int idx); + #else static inline @@ -60,4 +62,10 @@ int serial_base_add_preferred_console(struct uart_driver *drv, return 0; } +static inline +int serial_base_add_isa_preferred_console(const char *name, int idx) +{ + return 0; +} + #endif diff --git a/drivers/tty/serial/serial_base_bus.c b/drivers/tty/serial/serial_base_bus.c --- a/drivers/tty/serial/serial_base_bus.c +++ b/drivers/tty/serial/serial_base_bus.c @@ -317,6 +317,27 @@ int serial_base_add_preferred_console(struct uart_driver *drv, return serial_base_add_one_prefcon(port_match, drv->dev_name, port->line); } +#ifdef CONFIG_SERIAL_8250_CONSOLE + +/* + * Early ISA ports initialize the console before there is no struct device. + * This should be only called from serial8250_isa_init_preferred_console(), + * other callers are likely wrong and should rely on earlycon instead. + */ +int serial_base_add_isa_preferred_console(const char *name, int idx) +{ + return serial_base_add_prefcon(name, idx); +} + +#else + +int serial_base_add_isa_preferred_console(const char *name, int idx) +{ + return 0; +} + +#endif + #endif static int serial_base_init(void)