From patchwork Thu Aug 8 14:11:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Draszik?= X-Patchwork-Id: 13757556 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B5DBDC3DA4A for ; Thu, 8 Aug 2024 14:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To: Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id:Date:Subject: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=wieDPHjSPi1ZLsan7+O0Z+D8NjoHSP8ahDa0aetrxpk=; b=o4j4Udp00C1f40 I4AIfd6ohKIrPflEBnIn3nsojAfpmP9a+N1ffvDMb+H5tawV9TEbMxQnysR1TZBPwRJVzPCyQFazt sX/g0s5c708TG3U/rc2/gVxkQWRZuM3E9nCpkiND2Afsbp8bVev3LnPc0gAdy+NtXBZwg9ok7fDPa h+h/7EAuhrNymJFL/YEZpHGrhcXJulhenTOOj7OdK1VfScAo2Ny01Jjy6I9DRBCx5JOiBvlPe5G9P n5fAPmc5nez23XSZP/XjKbuS5QZRjk4XggnMPJ1gS073uZDywxJX03YM+uY3TIV06JvRgjpGL42vC fMCIclmC2zpqtqqbCvdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc3sT-00000008TG8-3wyd; Thu, 08 Aug 2024 14:12:29 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc3rL-00000008StO-1O7d for linux-arm-kernel@lists.infradead.org; Thu, 08 Aug 2024 14:11:21 +0000 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5af51684d52so1208975a12.1 for ; Thu, 08 Aug 2024 07:11:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723126277; x=1723731077; darn=lists.infradead.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=wieDPHjSPi1ZLsan7+O0Z+D8NjoHSP8ahDa0aetrxpk=; b=QWyerRUhxDTn57GH6mOyounHfhFauNUfcG6HEMOeYLXgGZZS0fcRYfyu7rN54rOavi uYn/LcYB3qDwe3+6J937SpyP0Vi4hhPNMctjBu1Irg9PqWrQAWI6SDXqWZbA/LQPSkOm 9b+QQkcnnbrxOzdvIYu/yNsKrM6O+d6h/5MtCHJ8q6zSWrGjox1rMYa1NP28vTLYxxDu f8tATYsDXlBV5XJyqmK+KEAYHQqHI8VI9vEwHqfA6ivrgjnCFWQ+Sy3+TNyWk8gOYFYu jDRmDxfSerF7wZpvmJpSToqwrVApNGX3Gf5CMMSPjEEh6y2pMYpCWQZV2StPnAgy+b7x aqQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723126277; x=1723731077; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wieDPHjSPi1ZLsan7+O0Z+D8NjoHSP8ahDa0aetrxpk=; b=cvFjxLjD+D1TrCSHHwxUFRuAMfF6QDi+sSe45r5LiLGv68mcgGBUoFl0pIeVX6NhC+ qQWZgSLHPha8wEifqADfxMo82125RZrm8/VPWqLgC6wW7nAhcz0GkcwLViyHYb5sdnvi gvk7W8WOwYl3JK/9bHnZN6V8C8o7sMkbcybdmGXWbEfDF9Wxo0l3XF+9z8QMPyEbe/Ia 5Al6yRNL+3uc7/Ne2qQxCKCFsu7bfhAQUXMoaHzGddOFmWp96qsHasy9DNv/apbNfPUE C4fy6I8uESlnLfD4LpPiDHBMCeVPB/0sotlHgqocsg8tfSsxARPxPZZFq2IBqkgNiIha qlFw== X-Forwarded-Encrypted: i=1; AJvYcCVQDnmssKxj3IKzE93ZvApCkvBqWlnTa+yzBtp2bLVYo3Q0czGOeLzkMP5bLS8iHNf1Mayt6CrXSspXdzgwiT0OO6bBW5sO7dYGrapj/zL//fzQh3o= X-Gm-Message-State: AOJu0Yx387vc6k7//Hrt4BTV4+AAAZthAgNq1kwcIv7mKQiUAF1yFLPb 7ociKlG+8tvJ4/cne5kE2AaKw7U5cjBH7ZOKIctQDgbxKd08NhktniNJJgQnazc= X-Google-Smtp-Source: AGHT+IHdqxblFw4szqgN7ofHM/QU50Nzna/i6RgnPnDiQEz7rQf3FzXP5OyidprWJ44HWP8e2NZg+Q== X-Received: by 2002:a05:6402:11c8:b0:5a0:f8a2:9cf4 with SMTP id 4fb4d7f45d1cf-5bbb2234eacmr1617101a12.25.1723126276628; Thu, 08 Aug 2024 07:11:16 -0700 (PDT) Received: from puffmais.c.googlers.com (64.227.90.34.bc.googleusercontent.com. [34.90.227.64]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5bbb2c29f79sm671761a12.33.2024.08.08.07.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 07:11:16 -0700 (PDT) From: =?utf-8?q?Andr=C3=A9_Draszik?= Subject: [PATCH v5 00/20] clk: help OF platforms with their stdout (earlycon) clocks during early boot Date: Thu, 08 Aug 2024 15:11:14 +0100 Message-Id: <20240808-gs101-non-essential-clocks-2-v5-0-11cffef0634e@linaro.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAALStGYC/4XOsU7DMBCA4VepPHPRne2koRPvgRhc+5JYDTY6R xFQ5d1xykCZOv7Lp/+qCkvkok6HqxJeY4k51WifDspPLo0MMdRWGrVFaxDGQkiQcgIuhdMS3Qx +zv5SQEPnjO5xcHTmXlXiQ3iInzf+9a32IPkdlknY/aFkEJ9NT7qho+1a0kDgUhBugrjyHS8vc 0xOcpNl3M0pliXL1+14Nbv86xzpwdxqAKEN/twHtBjI38P73WrvNf1As1UzhI4ZA9uO/2nbtv0 AZwaD7VsBAAA= To: Michael Turquette , Stephen Boyd , Peter Griffin , Krzysztof Kozlowski , Sylwester Nawrocki , Chanwoo Choi , Alim Akhtar , Sam Protsenko , Tudor Ambarus , Abel Vesa , Peng Fan , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: Will McVicker , kernel-team@android.com, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, imx@lists.linux.dev, =?utf-8?q?Andr=C3=A9_Draszik?= X-Mailer: b4 0.13.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240808_071119_628737_A1FF09D5 X-CRM114-Status: GOOD ( 18.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On at least two plaforms, i.MX and the Exynos-derivative gs101, earlycon depends on the bootloader setup stdout clocks being retained. In some cases stdout UART clocks (or their parents) can get disabled during loading of other drivers (e.g. i2c or UART driver init) causing earlycon to stop to work sometime into the boot, halting the whole system, see e.g. [3]. Code exists in the i.MX clock drivers to deal with that by temporarily bumping the reference count of the relevant stdout clocks during early boot. While gs101 doesn't have such code, some UART clocks had been marked 'critical' for a different reason originally, and by accident worked-around the same problem. v4 of this series proposed addition of similar code to gs101 to be able to drop the 'critical' flag from its clocks, but Stephen suggested to move all this into the clk core instead. This series now does that: * instead of duplicating such code to gs101, teaches the clk core to deal with stdout clocks during early boot, similar to the existing support in i.MX This is hooked into of_clk_add_hw_provider() and of_clk_add_provider() * updates gs101 to remove the 'critical' flag from affected clocks, as not necessary. This is essentially the last remaining patch [1] with all review comments addressed, from the series [2] that was sent earlier this year, see lore links below. * updates i.MX to remove the now-unnecessary platform specific code in its clock drivers. I believe this also plugs a memory and extra clock reference leak at least on imx7ulp, see below. Note 1: For the avoidance of doubt, any of the above is relevant only if earlycon and OF are enabled, behaviour is based on the 'earlycon' kernel command line parameter. As this is meant to also replace i.MX specific code, the 'earlyprintk' is also supported (since it was supported on i.MX) Note 2: On i.MX, at least clk-imx7ulp.c calls imx_register_uart_clocks() twice (once for each compatible), but imx_register_uart_clocks() can not handle that and will leak memory and clock references in that case. The new clk core code handles multiple invocations without such issues. Note 3: I am not in a position to test any of the i.MX changes and would appreciate feedback. In particular with these changes stdout clocks are enabled when of_clk_add_hw_provider() or of_clk_add_provider() return, but: * some i.MX platforms did some reparenting or frequency changes in the old approach before enabling stdout clocks. I believe they're all unrelated to stdout, though * some i.MX platforms enabled stdout clocks before the call to of_clk_add_hw_provider() or of_clk_add_provider(). Again, I don't think that difference is going to be relevant. Signed-off-by: André Draszik [1] https://lore.kernel.org/all/20240130093812.1746512-6-andre.draszik@linaro.org/ [2] https://lore.kernel.org/all/20240130093812.1746512-1-andre.draszik@linaro.org/ [3] https://lore.kernel.org/all/d45de3b2bb6b48653842cf1f74e58889ed6783ae.camel@linaro.org/ Changes in v5: - move stdout uart clock handling from gs101 into clk core (Stephen) - update i.MX to drop now-unnecessary code - update series' subject due to changed scope - Link to v4: https://lore.kernel.org/r/20240712-gs101-non-essential-clocks-2-v4-0-310aee0de46e@linaro.org Changes in v4: - new patch "clk: samsung: gs101: allow earlycon to work unconditionally" - update commit message for patch 2 - Link to v3: https://lore.kernel.org/r/20240710-gs101-non-essential-clocks-2-v3-0-5dcb8d040d1c@linaro.org --- André Draszik (20): clk: bump stdout clock usage for earlycon clk: samsung: gs101: don't mark non-essential (UART) clocks critical clk: imx: imx25: drop call to imx_register_uart_clocks() clk: imx: imx27: drop call to imx_register_uart_clocks() clk: imx: imx35: drop call to imx_register_uart_clocks() clk: imx: imx5: drop call to imx_register_uart_clocks() clk: imx: imx6q: drop call to imx_register_uart_clocks() clk: imx: imx6sl: drop call to imx_register_uart_clocks() clk: imx: imx6sll: drop call to imx_register_uart_clocks() clk: imx: imx6sx: drop call to imx_register_uart_clocks() clk: imx: imx6ul: drop call to imx_register_uart_clocks() clk: imx: imx7d: drop call to imx_register_uart_clocks() clk: imx: imx7ulp: drop calls to imx_register_uart_clocks() clk: imx: imx8mm: drop call to imx_register_uart_clocks() clk: imx: imx8mn: drop call to imx_register_uart_clocks() clk: imx: imx8mp: drop call to imx_register_uart_clocks() clk: imx: imx8mq: drop call to imx_register_uart_clocks() clk: imx: imx8ulp: drop call to imx_register_uart_clocks() clk: imx: imx93: drop call to imx_register_uart_clocks() clk: imx: drop imx_register_uart_clocks() drivers/clk/clk.c | 129 ++++++++++++++++++++++++++++++++++++++++ drivers/clk/imx/clk-imx25.c | 2 - drivers/clk/imx/clk-imx27.c | 2 - drivers/clk/imx/clk-imx35.c | 2 - drivers/clk/imx/clk-imx5.c | 6 -- drivers/clk/imx/clk-imx6q.c | 2 - drivers/clk/imx/clk-imx6sl.c | 2 - drivers/clk/imx/clk-imx6sll.c | 2 - drivers/clk/imx/clk-imx6sx.c | 2 - drivers/clk/imx/clk-imx6ul.c | 2 - drivers/clk/imx/clk-imx7d.c | 2 - drivers/clk/imx/clk-imx7ulp.c | 4 -- drivers/clk/imx/clk-imx8mm.c | 2 - drivers/clk/imx/clk-imx8mn.c | 2 - drivers/clk/imx/clk-imx8mp.c | 2 - drivers/clk/imx/clk-imx8mq.c | 2 - drivers/clk/imx/clk-imx8ulp.c | 2 - drivers/clk/imx/clk-imx93.c | 2 - drivers/clk/imx/clk.c | 72 ---------------------- drivers/clk/imx/clk.h | 7 --- drivers/clk/samsung/clk-gs101.c | 7 +-- 21 files changed, 132 insertions(+), 123 deletions(-) --- base-commit: 1e391b34f6aa043c7afa40a2103163a0ef06d179 change-id: 20240430-gs101-non-essential-clocks-2-6a3280fa1be8 Best regards,