Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2024709lqb; Mon, 27 May 2024 05:41:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXti3RBqLEKfDjmiinlbW3iazZkHfKyW+CsyxIhUaYKId9jycIVWEZj4RkYnEXbZNtv2AQFZOUqLiQkZK/FBUySWDd+CV6uhz2ft3X7jg== X-Google-Smtp-Source: AGHT+IEdlFBxgsFPUSmuR/FcGC1C/Hfn91xdIo8dh7886MPpa0jmDsUij1tE1Fqi0uPv3fFrVzcx X-Received: by 2002:a05:622a:13cd:b0:43d:f64c:420f with SMTP id d75a77b69052e-43fb0efb491mr95682481cf.67.1716813693403; Mon, 27 May 2024 05:41:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716813693; cv=pass; d=google.com; s=arc-20160816; b=iwf/16Ice/T+TJr+tfnwVMc1mLUC8jtqrh2oX8kOqcbN+gEPEx96O+SUTMdY4p7v2D 22yBmCr+lbzLqeTXlsThO8XAy6+5Q6Pbyw9JG8JSDMFKPIhVWclq1hKfrzcfnOUJNFGn IoVIwjtEtB1jOImT0BFmyrQhdaTwUWep6GR4TZaw80JFAv/YPDvYGIZ0UII1hiY7n8h6 Gna1Nexx80SmXRvPyYiwiiUIpDkRh4GAbuewe4W4y/r960BxgUVv6hxDpzq/CPrhe99v aR3hMSBw+lYh0lQzQ+mMDSRrOnQH4iKfO6uOhPiQUxrzwbqAKPY1kDJkE5V4w8kcfHHm Oc9Q== ARC-Message-Signature: i=2; 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; bh=bJ6SgbL/vpuVNA0J1wjLrxVEHU5mC3vKpDzquv4a1B8=; fh=JhTdWYFZ8w88n/94sqvWELMCujglPo7hfkIbZpbglA4=; b=AaCYQXWxL9O21oz0b/0IrlLMCqNgk4hdCPM5P3I7hKKq/St7Z2NpIxo9JEQbAFnr2S WS0T4SloCYxHwH7g49heKR0dKBrTxsSisZZxF/lCtVHTUdMp2p5lZTUqGrtF3fq7iATr /FDN6PT5ko5WpNcIe+hVx2ayABl7oHr6cyQGu8Vs3KQj9gnPa7Lyy81EJOlYB56GoQpa mPT3egr+L7mesaCD+lW5qB2hu6QassDm3KpOU4nCWISlgEJN6/9IVd2QF9WUc2feh8rm jxim1L40zcyvResKu21FbyliDh+LcMcoYkkbCHqCbiQJTLSrKVfxKKXGky29BE7JstgF hZBA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-190594-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190594-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43fb18a86a1si78774911cf.389.2024.05.27.05.41.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:41:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190594-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-190594-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190594-linux.lists.archive=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 139531C20A7E for ; Mon, 27 May 2024 12:41:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D35715E5C6; Mon, 27 May 2024 12:41:25 +0000 (UTC) Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [195.130.137.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8616D15DBCA for ; Mon, 27 May 2024 12:41:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.137.89 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716813684; cv=none; b=Gv6k/ZR8/KpzWoKts4B3TZJHvX347BYyMnGuzGu3zv5vGUx38Hw/u0GwNuJqOKY0XczewUIvqRKvAFqCZPg5NzUUmHB8u2Ut4ICWvm6bD2BJhGTJ+SRDhr9Lml1Ki1/vpGpLsEOaO+rCTvZtRv7NxLTmOFr2Yf6vueTE/x6G4+E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716813684; c=relaxed/simple; bh=EIepfrHfmhIc9MJ0QvPBLJEXp/OzidtfVr/2NHCOLWI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q+MB6k/wvJ/EPA492BdeUlFly8NxUKQFS5u1Cx/hf5J1q5BFqp5EHMaGJ2dHQ1qUoe6oSIah+udheZK42SlOQIO62RQVeR/6S4Js9FDl6u25o34ImrwkfORsBed7UENN9cFrTaFHP+kVLUQY/Oze7X0SMYUoEqzS8+grQmKFj5c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=glider.be; spf=none smtp.mailfrom=linux-m68k.org; arc=none smtp.client-ip=195.130.137.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=glider.be Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:c993:5573:f894:7353]) by laurent.telenet-ops.be with bizsmtp id UChF2C0022nC7mg01ChFPu; Mon, 27 May 2024 14:41:19 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1sBZeD-00CfTe-4S; Mon, 27 May 2024 14:41:14 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1sBZf8-003hdZ-Sf; Mon, 27 May 2024 14:41:14 +0200 From: Geert Uytterhoeven To: Ulf Hansson , Greg Kroah-Hartman , Jiri Slaby , "Rafael J . Wysocki" , Rob Herring , Saravana Kannan Cc: Claudiu Beznea , Peng Fan , linux-pm@vger.kernel.org, linux-serial@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH/RFC 1/3] earlycon: Export clock and PM Domain info from FDT Date: Mon, 27 May 2024 14:41:11 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Earlycon relies on the serial port to be initialized by the firmware and/or bootloader. Linux is not aware of any hardware dependencies that must be met to keep the port working, and thus cannot guarantee they stay met, until the full serial driver takes over. E.g. all unused clocks and unused PM Domains are disabled in a late initcall. As this happens after the full serial driver has taken over, the serial port's clock and/or PM Domain are no longer deemed unused, and this is typically not a problem. However, if the serial port's clock or PM Domain is shared with another device, and that other device is runtime-suspended before the full serial driver has probed, the serial port's clock and/or PM Domain will be disabled inadvertently. Any subsequent serial console output will cause a crash or system lock-up. Provide a mechanism to let the clock and/or PM Domain subsystem or drivers handle this, by exporting the clock and PM Domain dependencies for the serial port, as available in the system's device tree. Note that as this is done during early boot-up, the device_node structure pointing to the earlycon console is not yet created, so this has to resort to raw property data. Signed-off-by: Geert Uytterhoeven --- drivers/tty/serial/earlycon.c | 14 +++++++++++++- include/linux/serial_core.h | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c index a5fbb6ed38aed681..abe4831d9685e2b8 100644 --- a/drivers/tty/serial/earlycon.c +++ b/drivers/tty/serial/earlycon.c @@ -250,11 +250,14 @@ early_param("earlycon", param_setup_earlycon); #ifdef CONFIG_OF_EARLY_FLATTREE +const __be32 *earlycon_clocks, *earlycon_power_domains; +int earlycon_clocks_ncells, earlycon_power_domains_ncells; + int __init of_setup_earlycon(const struct earlycon_id *match, unsigned long node, const char *options) { - int err; + int err, size; struct uart_port *port = &early_console_dev.port; const __be32 *val; bool big_endian; @@ -309,6 +312,15 @@ int __init of_setup_earlycon(const struct earlycon_id *match, if (val) port->uartclk = be32_to_cpu(*val); + earlycon_clocks = of_get_flat_dt_prop(node, "clocks", &size); + if (earlycon_clocks) + earlycon_clocks_ncells = size / sizeof(u32); + + earlycon_power_domains = of_get_flat_dt_prop(node, "power-domains", + &size); + if (earlycon_power_domains) + earlycon_power_domains_ncells = size / sizeof(u32); + if (options) { early_console_dev.baud = simple_strtoul(options, NULL, 0); strscpy(early_console_dev.options, options, diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 8cb65f50e830c8d4..70689a3363951dac 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -954,6 +954,16 @@ static const bool earlycon_acpi_spcr_enable EARLYCON_USED_OR_UNUSED; static inline int setup_earlycon(char *buf) { return 0; } #endif +#ifdef CONFIG_OF_EARLY_FLATTREE +extern const __be32 *earlycon_clocks, *earlycon_power_domains; +extern int earlycon_clocks_ncells, earlycon_power_domains_ncells; +#else +#define earlycon_clocks NULL +#define earlycon_clocks_ncells 0 +#define earlycon_power_domains NULL +#define earlycon_power_domains_ncells 0 +#endif + /* Variant of uart_console_registered() when the console_list_lock is held. */ static inline bool uart_console_registered_locked(struct uart_port *port) { -- 2.34.1