From patchwork Mon Dec 18 07:09:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 18210 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1074897dyi; Sun, 17 Dec 2023 23:12:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUUmYsY2nE/SuMoxLYz4Ces8sqinD3Gxkhyoo6tOw4ctscXNNVDlHL0UoKMCPwOAuD9m5i X-Received: by 2002:a05:6122:201c:b0:4b2:9ba4:7b12 with SMTP id l28-20020a056122201c00b004b29ba47b12mr11123072vkd.9.1702883528695; Sun, 17 Dec 2023 23:12:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702883528; cv=none; d=google.com; s=arc-20160816; b=OS3OeV5YuGPVMFbNDiQW4V0WGFK3j6lhDBaPQBBWIyC07Lldxwr0n+x9As3o+qVF/7 tYcNWrokgcN9bjv4dFPkI4Afy4Ogq8vNYSyjzx9r7W+Voz6WvZ7PdFuZYCkLZql+jCv1 Yvh70LMsbmHb5UN7/YnY8j5t4M26wbSgL3fa4cxxFHpNe4OaDPHVOSBZJk5oabsvOToa 16HPYdB/RP2E22GEXt4diwwC9NIiTFywt5Ka795JHNPhiLp7Z8jbaE1UyZS/goVEMYGi 7QP6vmbhnbFEpAxuAdewXm4IhkEzcuyc+zySFU1ud7udxxnsfHnxKZnzJbxlim28gNKY dUdA== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=bpbcKqSHH7EWEOwqc95348G6T4zObvlGadiEuNDk9YY=; fh=OQrZIrddo55Tm+afxTOsnGwFgD38y2NNd7tU+1OGSCE=; b=m9UYLtfE+C/iKHFwYNmTfCYbiEM7mHNmosYnQTWfmqYRKSgG50JsRGqb5lQzunVKwd pu2mOSfEGTKDw0nrWXl5imWWzcpB8NP+FJeN/N4xxeldB3YhSwB6N+O4/AXZV8NNZ8Go I0/2PS+Sh9qgPJNe20747sBpB0epoXh9jD1PA+OY+zUf6kQ4NkVdtY3W5EaOc2G1cmp7 6+4G+B5nQv4sIMkpaTPg/ihKpdeSpWsF48eo5ieHmWIHXZS7Q9WklAYCHkFPfj+c5wcp 9Pk0PF5yM4t8kFDHOjUkefX67YKAKDF2Yqo5dXySFsvZkx0Y9LJXlzfOumarqQD1hvZX Bfvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@atomide.com header.s=25mailst header.b=hVM+t6hz; spf=pass (google.com: domain of linux-kernel+bounces-3080-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3080-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i17-20020a0cab51000000b0067f2fc95266si3824180qvb.94.2023.12.17.23.12.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 23:12:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3080-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@atomide.com header.s=25mailst header.b=hVM+t6hz; spf=pass (google.com: domain of linux-kernel+bounces-3080-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3080-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 781CE1C22311 for ; Mon, 18 Dec 2023 07:12:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4BEBE551; Mon, 18 Dec 2023 07:11:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=atomide.com header.i=@atomide.com header.b="hVM+t6hz" 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 48E14D533; Mon, 18 Dec 2023 07:11:20 +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 421CA603E6; Mon, 18 Dec 2023 07:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=atomide.com; s=25mailst; t=1702883479; bh=+3hCOyBA6B8r1AjHV1DyAm1ub22CieIvEKi/FHo1oXg=; h=From:To:Cc:Subject:Date:From; b=hVM+t6hzx8orPqGP8RUPdB0AiqlocXu4uS/f7d5LLp9EPMcGQubhRJXUM1A/2MHqX zO3/KJftoe/Obs8qrgWkiyJ1pdN5AUHjYe5EWalWLI4F0eE+Wr10zCfsvl/gA/HHlm qexQ0dFITeaQWZwGGS2AWUyWi0fmLzCnAm37nQHHf9zUKQLmYX0xX3fryVeRorvmAP lP/V+3l4EyRbcHAS3Y+1EyWH2bm4lOdYT4stbG8ETC+aIWdyfjWYZ1wIEwHnzY8YF5 E8jaj/+hBVHnDlbeyTSS/o2UisGtDRTxNkbYUuOeTvWtl6du8LWpKVBmRYJJZvMxLo srGQ0YMvEOi7g== 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 0/6] Add support for DEVNAME:0.0 style hardware based addressing Date: Mon, 18 Dec 2023 09:09:47 +0200 Message-ID: <20231218071020.21805-1-tony@atomide.com> X-Mailer: git-send-email 2.43.0 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: 1784426421740447840 X-GMAIL-MSGID: 1785602798627137456 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. We also prepare the serial core to handle the ttyS related quirks done in console_setup() to prepare things for eventually dropping the parsing from console_setup(). Regards, Tony Changes since v4: - Fix passing empty brl_opt to add_preferred_console() instead of NULL - Fix console_setup() trying to parse a console index out of a DEVNAME:0.0 option that can be an IO address instead of an index - Fix issue with default console getting enabled before DEVNAME:0.0 handling device driver calls add_preferred_console() - Fix error check for kasprintf(), use serial_base_add_one_prefcon() and coding suggestions by Andy - Fixed compile errors if console is not enabled in .config as noted by kernel test robot Changes since v3: - Fix handling of brl_options by saving them too in console_opt_save() - Drop changes to remove console_setup() parsing, further changes to register_console() are still needed before can leave out the early parsing - Added a patch for serial8250_isa_init_preferred_console(), otherwise the console gets initialized later for x86 when the console_setup() parsing is dropped as pointed out by Petr - Initialize __free() variables to NULL as noted by Dan - Return handled in console_setup() if saving console options fails - Simplify serial_base_add_preferred_console() and add a helper for serial_base_add_one_prefcon() as suggested by Andy - Header include changes to kernel/printk/conopt.c as suggested by Andy 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 (6): printk: Save console options for add_preferred_console_match() printk: Don't try to parse DEVNAME:0.0 console options printk: Flag register_console() if console is set on command line serial: core: Add support for DEVNAME:0.0 style naming for kernel console serial: core: Handle serial console options serial: 8250: Add preferred console in serial8250_isa_init_ports() drivers/tty/serial/8250/8250_core.c | 5 + drivers/tty/serial/serial_base.h | 24 +++++ drivers/tty/serial/serial_base_bus.c | 136 +++++++++++++++++++++++++ drivers/tty/serial/serial_core.c | 4 + include/linux/printk.h | 3 + kernel/printk/Makefile | 2 +- kernel/printk/conopt.c | 142 +++++++++++++++++++++++++++ kernel/printk/console_cmdline.h | 6 ++ kernel/printk/printk.c | 23 ++++- 9 files changed, 340 insertions(+), 5 deletions(-) create mode 100644 kernel/printk/conopt.c