Message ID | 20231121113203.61341-1-tony@atomide.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp553597vqb; Tue, 21 Nov 2023 03:32:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHuyq9LprWe1CGdBxlgKEIQWw3NsI1n2tV70m0ksVt0mbFcfhvvNoWd5NnDk2M0WEAASi60 X-Received: by 2002:a17:90b:3851:b0:283:21d3:11eb with SMTP id nl17-20020a17090b385100b0028321d311ebmr7691014pjb.3.1700566372991; Tue, 21 Nov 2023 03:32:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700566372; cv=none; d=google.com; s=arc-20160816; b=k/EtT4VVPSeg2sCySHuO6GIGYY16EIzMEmuWOOVX6gcqDhyJ32EFVjdcuFk+vp3v5e 0F0FkVzPn0wGioDUz2e0ssYW9B2+A90AImmuju7rbZ2QICAvs0RnfVTNOxm4hbIo1qqN DXgdleXKEGaSWnqbYz8orxQP19Gc+oYjwgl5UKPuB61eUqbvo+QDdHwCiBQ1ETKEZGGD FvQjNO+n2wfEa0gIcAiprVUHw5be8eVzAUxw09+PvYwLd9wbmSavkIet+MZ4/EmuvVcY ypDluEAfqFolKhSdKwk9+mGNLotbTdhSKGW8JyI0DbpvwMW8IYgpt3M/gRiQ/k5tnKcg 5ydQ== 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 :message-id:date:subject:cc:to:from; bh=FlsDs8QRFBtwAUChWEGGUlLJ5XmLc9SS6VuGxIw1WU4=; fh=bWj5KacFiXVp0Il3xL1MvNC9F4GPhzCV51seXUkiNOA=; b=H/nOFd5vXqzyKhg19rnVoGRIRV2S8EW+2zVpWxmvaFWbNQYdTCNYZ1bykZmaWi2QIz 0z91ctp5g5YGmUS4iAh3JP1I19nk8GR1gPnDMm+vsG0cSS7/vZ1YFFQWU3OGzKAR45fg cBdlRM8jg+3gzO9nBULbGI6fFK2T+JY2GgbD0gOjCffTVntTxU6GlfQon2ZiUfnUTrVh L+n3w7uq7rr3zc/KRc2uut8RnZlh2YnbdROttCtgIcoJgtzc8oeXQBDDRkZoejSyulzt RUAlAaEGUeqtqgVxdLkZOPh52Yd5RD++sBi08fkZIRF2M6AaDCZ0RNhUlmpygQqSpCL+ 6AKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id gi16-20020a17090b111000b0028524e799b3si4339366pjb.42.2023.11.21.03.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 03:32:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id D16618031D61; Tue, 21 Nov 2023 03:32:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233753AbjKULct (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Tue, 21 Nov 2023 06:32:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjKULcr (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 21 Nov 2023 06:32:47 -0500 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 761C19C; Tue, 21 Nov 2023 03:32:43 -0800 (PST) Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id F3A6C80CC; Tue, 21 Nov 2023 11:32:39 +0000 (UTC) From: Tony Lindgren <tony@atomide.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org> Cc: "David S . Miller" <davem@davemloft.net>, Petr Mladek <pmladek@suse.com>, Sergey Senozhatsky <senozhatsky@chromium.org>, Steven Rostedt <rostedt@goodmis.org>, Andy Shevchenko <andriy.shevchenko@intel.com>, Dhruva Gole <d-gole@ti.com>, =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>, John Ogness <john.ogness@linutronix.de>, Johan Hovold <johan@kernel.org>, Sebastian Andrzej Siewior <bigeasy@linutronix.de>, Vignesh Raghavendra <vigneshr@ti.com>, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH v3 0/3] Add support for DEVNAME:0.0 style hardware based addressing Date: Tue, 21 Nov 2023 13:31:54 +0200 Message-ID: <20231121113203.61341-1-tony@atomide.com> X-Mailer: git-send-email 2.42.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=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 fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 21 Nov 2023 03:32:48 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783173085112233493 X-GMAIL-MSGID: 1783173085112233493 |
Series |
Add support for DEVNAME:0.0 style hardware based addressing
|
|
Message
Tony Lindgren
Nov. 21, 2023, 11:31 a.m. UTC
Hi all, With the recent serial core changes, we can now add DEVNAME:0.0 style addressing for the serial ports. When using DEVNAME:0.0 naming, we don't need to care which ttyS instance number is allocated depending on HSUART settings or if the devicetree has added aliases for all the ports. This also allows us to also drop the old console_setup() parsing for character device names. Regards, Tony Changes since v2: - Console name got constified and already applied as suggested by Ilpo and Andy - Add printk/conopt.c to save console command line options - Add a patch to drop old console_setup() character device name parsing - Use cleanup.h to simplify freeing as suggested by Andy - Use types.h instead of kernel.h as suggested by Andy - Use strcspn() as suggested by Andy - Various coding improvments suggested by Andy Changes since v1: - Constify printk add_preferred_console() as suggested by Jiri - Use proper kernel command line helpers for parsing console as suggested by Jiri - Update description for HSUART based on Andy's comments - Standardize on DEVNAME:0.0 style naming as suggested by Andy - Added missing put_device() calls paired with device_find_child() Tony Lindgren (3): printk: Save console options for add_preferred_console_match() serial: core: Add support for DEVNAME:0.0 style naming for kernel console serial: core: Move console character device handling from printk drivers/tty/serial/serial_base.h | 14 ++++ drivers/tty/serial/serial_base_bus.c | 104 ++++++++++++++++++++++++ drivers/tty/serial/serial_core.c | 4 + include/linux/printk.h | 3 + kernel/printk/Makefile | 2 +- kernel/printk/conopt.c | 115 +++++++++++++++++++++++++++ kernel/printk/console_cmdline.h | 4 + kernel/printk/printk.c | 41 +++------- 8 files changed, 254 insertions(+), 33 deletions(-) create mode 100644 kernel/printk/conopt.c
Comments
On Tue 2023-11-21 13:31:54, Tony Lindgren wrote: > Hi all, > > With the recent serial core changes, we can now add DEVNAME:0.0 style > addressing for the serial ports. When using DEVNAME:0.0 naming, we don't > need to care which ttyS instance number is allocated depending on HSUART > settings or if the devicetree has added aliases for all the ports. > > This also allows us to also drop the old console_setup() parsing for > character device names. > > Tony Lindgren (3): > printk: Save console options for add_preferred_console_match() > serial: core: Add support for DEVNAME:0.0 style naming for kernel > console > serial: core: Move console character device handling from printk First, I appreciate the effort to match aliases to the same console. Well, my understanding is that it solves the problem only for the newly added console=DEVICENAME:0.0 format. But it does not handle the existing problems with matching console names passed via earlycon= and console= parameters. Am I right? Now, the bad news. This patchset causes regressions which are not acceptable. I have found two so far but there might be more. I used the following kernel command line: earlycon=uart8250,io,0x3f8,115200 console=ttyS0,115200 console=tty0 ignore_loglevel log_buf_len=1M 1. The patchset caused that /dev/console became associated with ttyS0 instead of tty0, see the "C" flag: original # cat /proc/consoles tty0 -WU (EC ) 4:1 ttyS0 -W- (E p a) 4:64 vs. patched # cat /proc/consoles ttyS0 -W- (EC p a) 4:64 tty0 -WU (E ) 4:1 This is most likely caused by the different ordering of __add_preferred_console() calls. The ordering is important because it defines which console will get associated with /dev/console. It is a so called preferred console defined by the last console= parameter. Unfortunately also the ordering of the other parameters is important when a console defined by the last console= parameter is not registered at all. In this case, /dev/console gets associated with the first console with tty binding according to the order on the command line. If you think that it is weird behavior then I agree. But it is a historical mess. It is how people used it when the various features were added. Many changes in this code caused regressions and had to be reverted. See the following to get the picture: + commit c6c7d83b9c9e6a8 ("Revert "console: don't prefer first registered if DT specifies stdout-path") + commit dac8bbbae1d0ccb ("Revert "printk: fix double printing with earlycon""). 2. The serial console gets registered much later with this patchset: original # dmesg | grep printk: [ 0.000000] printk: legacy bootconsole [uart8250] enabled [ 0.000000] printk: debug: ignoring loglevel setting. [ 0.016859] printk: log_buf_len: 1048576 bytes [ 0.017324] printk: early log buf free: 259624(99%) [ 0.141859] printk: legacy console [tty0] enabled [ 0.142399] printk: legacy bootconsole [uart8250] disabled [ 0.143032] printk: legacy console [ttyS0] enabled vs. patched # dmesg | grep printk: [ 0.000000] printk: legacy bootconsole [uart8250] enabled [ 0.000000] printk: debug: ignoring loglevel setting. [ 0.018142] printk: log_buf_len: 1048576 bytes [ 0.018757] printk: early log buf free: 259624(99%) [ 0.160706] printk: legacy console [tty0] enabled [ 0.161213] printk: legacy bootconsole [uart8250] disabled [ 1.592929] printk: legacy console [ttyS0] enabled This is pretty bad because it would complicate or even prevent debugging of the boot stage via serial console. The graphical console is not usable when the system dies. Also finding the right arguments for the earlycon= parameter is tricky so that people enable it only when they have to debug very early messages. I am going to look at the patches more closely to see if I could provide some hints. Best Regards, Petr
* Petr Mladek <pmladek@suse.com> [231201 14:36]: > Well, my understanding is that it solves the problem only for the newly > added console=DEVICENAME:0.0 format. But it does not handle the > existing problems with matching console names passed via earlycon= > and console= parameters. Am I right? Yes that's where the remaining problems are. > Now, the bad news. This patchset causes regressions which are > not acceptable. I have found two so far but there might be more. > > I used the following kernel command line: > > earlycon=uart8250,io,0x3f8,115200 console=ttyS0,115200 console=tty0 ignore_loglevel log_buf_len=1M > > > 1. The patchset caused that /dev/console became associated with > ttyS0 instead of tty0, see the "C" flag: > > original # cat /proc/consoles > tty0 -WU (EC ) 4:1 > ttyS0 -W- (E p a) 4:64 > > vs. > > patched # cat /proc/consoles > ttyS0 -W- (EC p a) 4:64 > tty0 -WU (E ) 4:1 > > This is most likely caused by the different ordering of > __add_preferred_console() calls. Yes I noticed that too. We can't drop the console parsing from console_setup() until we have some solution for flagging register_console() that we do have a console specified on the kernel command line and try_enable_default_console() should not be called. It seems some changes to the console_set_on_cmdline handling might do the trick here. > The ordering is important because it defines which console > will get associated with /dev/console. It is a so called > preferred console defined by the last console= parameter. > > Unfortunately also the ordering of the other parameters > is important when a console defined by the last console= > parameter is not registered at all. In this case, > /dev/console gets associated with the first console > with tty binding according to the order on the command line. > > If you think that it is weird behavior then I agree. > But it is a historical mess. It is how people used it > when the various features were added. Many changes > in this code caused regressions and had to be reverted. Yeah agreed it's a mess :) > See the following to get the picture: > > + commit c6c7d83b9c9e6a8 ("Revert "console: don't > prefer first registered if DT specifies stdout-path") > > + commit dac8bbbae1d0ccb ("Revert "printk: fix double > printing with earlycon""). OK thanks. > 2. The serial console gets registered much later with this > patchset: > > original # dmesg | grep printk: > [ 0.000000] printk: legacy bootconsole [uart8250] enabled > [ 0.000000] printk: debug: ignoring loglevel setting. > [ 0.016859] printk: log_buf_len: 1048576 bytes > [ 0.017324] printk: early log buf free: 259624(99%) > [ 0.141859] printk: legacy console [tty0] enabled > [ 0.142399] printk: legacy bootconsole [uart8250] disabled > [ 0.143032] printk: legacy console [ttyS0] enabled > > vs. > > patched # dmesg | grep printk: > [ 0.000000] printk: legacy bootconsole [uart8250] enabled > [ 0.000000] printk: debug: ignoring loglevel setting. > [ 0.018142] printk: log_buf_len: 1048576 bytes > [ 0.018757] printk: early log buf free: 259624(99%) > [ 0.160706] printk: legacy console [tty0] enabled > [ 0.161213] printk: legacy bootconsole [uart8250] disabled > [ 1.592929] printk: legacy console [ttyS0] enabled > > This is pretty bad because it would complicate or even prevent > debugging of the boot stage via serial console. I think I have a patch coming for 8250 isa ports for that issue. This issue should go away if we call add_preferred_console_match() from serial8250_isa_init_ports() with options for the port like "ttyS0", "ttyS", 0. > The graphical console is not usable when the system dies. Also > finding the right arguments for the earlycon= parameter is > tricky so that people enable it only when they have to debug > very early messages. > > > I am going to look at the patches more closely to see if I could > provide some hints. Great, help with the early console handling is much appreciated. I'll post an updated patchset this week that does not touch console_setup() beyond saving the console options. And then we hopefully have something that avoids the regressions and can be used for further changes later on. Regards, Tony