Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2025128lqb; Mon, 27 May 2024 05:42:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWfMqd8FZkfCipWJyq6gm233xm8bu7ZeKKwkI5QGTLbp03k9Bqor32eMzEbofknEJDaE1RqJ4xlntG5rryNfMCKjkogbJunFfmwA0u8ZQ== X-Google-Smtp-Source: AGHT+IHtAGfOydiXGLwsV3eMTmWWa9syYvlYoFmh3JZh1eXeKHb/f4hANNJSN+OQ8YU6/jaDS6gt X-Received: by 2002:a17:90b:fd2:b0:2b9:7a42:e3ab with SMTP id 98e67ed59e1d1-2bf5ee148d0mr9651966a91.20.1716813741990; Mon, 27 May 2024 05:42:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716813741; cv=pass; d=google.com; s=arc-20160816; b=vS4FCEhTsmqXCipHa82q2opA4zD7ngeU2kwn+9ivUewuMFUWU/5Ihrj3o/JqkVX9/m TUSRBcucjPRq6urH1CdifxrEnqjCOpSFpHA/zvbtWcY6ypf2uwk3RhcB4biqV3CErIIH Ar8xi07DuB0EG3D5+gYRiany9GL8hl9mwPWrOhc2rqK9JqV33WBB+NBHYSgvxS97dbD2 I61TUGG8wi3hhdtoIec3XWUY62+LvjfYNoIVkjCNm+AmS4nb0H++NpZbvw87Jb96qUrE bs7X0EBLWee0GTW0rhyjx6WOlPsVRVAAWVICih4ttkm9yPxgXQT2Hf9lXhlxC04uZrNO pZug== 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:message-id:date:subject:cc:to :from; bh=ps0lGWB9TGC2DYctB5kQpCa8K2grjONxIHCpo3JJIJ0=; fh=JhTdWYFZ8w88n/94sqvWELMCujglPo7hfkIbZpbglA4=; b=HJbq7yK6vihMqNvif1u/+VsDVSdzJExPPwFEwPjXUIUJpOegAB7GAltirYcoQ0WvnB ZhybVfWmCCid4TC6CnM/T/r9koUnDeyv3i/ym4k3S9iOEYpVsQzsqxgb42NwbhTi4DxZ NUMqeByD+n05QV11D3npc22kz/xDIpRBzAxjnQHFmgGPo1Fggt1U3jwtVogJjwZ2iEKG z59qL3H6EkO3mvZf8Q6BTghsUB4v8StIfkEsnUXuLqAgCvG/zxJG4bP0lfg7t9ufC4gm FLtrepvOlkuGnQvOUEpYF0bTU+cJ3DzHo+oA2J7Od6MIZMS5Q2aC3gQbIYszSMO34zcN k0tQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-190596-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190596-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2bdd9ed1bc3si7841832a91.28.2024.05.27.05.42.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 05:42:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190596-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-190596-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190596-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 98E172847E1 for ; Mon, 27 May 2024 12:41:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B438615ECEA; Mon, 27 May 2024 12:41:32 +0000 (UTC) Received: from gauss.telenet-ops.be (gauss.telenet-ops.be [195.130.132.49]) (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 03C6415ECC4 for ; Mon, 27 May 2024 12:41:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.130.132.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716813692; cv=none; b=Uee+QfMj4uMHR5J3Wz59Jwa5F7i/4OQS0Em4RTooWR15D0MUmZMHwWO5w8YtoazHeRGxqfkyWBuYN5vptPp9h4pDVym/ET7LcBiyAOLxU6i1lzgGFDcTOsyTLdRwjiB5BQUR2cNvGZCumT1A+aOX0nzcrnn0KPZKV6Gpu6ZxNJc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716813692; c=relaxed/simple; bh=8hdldazWVA2zqxn3teJVpbzPafUsFkhaXGXuAlZegCc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=gyiyKI3/LdQh6NXfs3Uj12SxUmM2kqTzy29Z17mwmjhYsfoEtnld195Sj3M7wnRbqC7KJdArLrlqkczJgqcFzM0BQpwdSAApzYgBShy5PrQmUeoUb4Zd6P0fNs3lVNOoUlidx4LeBLo/1zPAfN9Ipi+eYy9W+e+/XZk7DC5VGUk= 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.132.49 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 andre.telenet-ops.be (andre.telenet-ops.be [IPv6:2a02:1800:120:4::f00:15]) by gauss.telenet-ops.be (Postfix) with ESMTPS id 4VnwHq28Pjz4wy8b for ; Mon, 27 May 2024 14:41:27 +0200 (CEST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:c993:5573:f894:7353]) by andre.telenet-ops.be with bizsmtp id UChF2C0032nC7mg01ChF7d; 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-00CfTd-4Q; Mon, 27 May 2024 14:41:14 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1sBZf8-003hdW-RS; 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 0/3] pmdomain: renesas: rmobile-sysc: Remove serial console handling Date: Mon, 27 May 2024 14:41:10 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi all, Since commit a47cf07f60dcb02d ("serial: core: Call device_set_awake_path() for console port"), the serial driver properly handles the case where the serial console is part of the awake path, and it looked like we could start removing special serial console handling from PM Domain drivers like the R-Mobile SYSC PM Domain driver. Unfortunately the devil is in the details, as usual... 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. E.g. on R/SH-Mobile SoCs, the serial ports share their PM Domain with several other I/O devices. After the use of pwm (Armadillo-800-EVA) or i2c (KZM-A9-GT) during early boot, before the full serial driver takes over, the PM Domain containing the early serial port is powered down, causing a lock-up when booted with "earlycon". This RFC patch series aims to provide a mechanism for handling this, and to fix it for the PM Domain case: 1. The first patch provides 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, 2. The second patch introduces a new flag to handle a PM domain that must be kept powered-on during early boot, and by setting this flag if the PM Domain contains the serial console (originally I handled this inside rmobile-sysc, but it turned out to be easy to generalize this to other platforms in the core PM Domain code). 3. The third patch removes the no longer needed special console handling from the R-Mobile SYSC PM Domain driver. I did not fix the similar clock issue, as it is more complex (there can be multiple clocks, and each clock provider can have its own value of #clock-cells), and I do not need it for Renesas ARM platforms. This has been tested on the APE6-EVM, Armadillo-800-EVA, and KZM-A9-GT development boards, with and without earlycon, including s2ram with and without no_console_suspend. Notes: - This should not be needed on RZ/G3S, where each serial port device has its own PM Domain, - drivers/clk/imx/clk.c and drivers/pmdomain/imx/scu-pd.c have special handling for the of_stdout device, but is probably not affected, as each serial port seems to share its PM Domain only with the serial port's clock controller. Thanks for your comments! Geert Uytterhoeven (3): earlycon: Export clock and PM Domain info from FDT pmdomain: core: Avoid earlycon power-down pmdomain: renesas: rmobile-sysc: Remove serial console handling drivers/pmdomain/core.c | 24 ++++++++++++++++-- drivers/pmdomain/renesas/rmobile-sysc.c | 33 +------------------------ drivers/tty/serial/earlycon.c | 14 ++++++++++- include/linux/pm_domain.h | 4 +++ include/linux/serial_core.h | 10 ++++++++ 5 files changed, 50 insertions(+), 35 deletions(-) -- 2.34.1 Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds