From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DA80606A322 for ; Sat, 5 Dec 2026 08:31:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=oUSpM/Be; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=AZQcpkoo 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:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Unsubscribe-Post:List-Owner; bh=5VYtERQnlqR6z0RfgEBN3eiSddueMFHwx7JIcHZ/34Q=; b=oUSpM/BeS+8nu3gru1JD04+f9e pfCVZ/toZgrbq5musZqllXkwr3ADKACZ1KL05MDcsgeQrqYvWaD6U+uszC5nYZn6vuNv/gZEf78Uf U5WI2Akvoib0RnoV++73bAw6uhuneMPpA3iaJJi9lp8BbvJ3ZHUphfeCo3mGBQN0xSNG8mP1qkd/w NyjUWOrigqXLYoAAQE+Wwfwf+XuNItAoYVvOpr/bzjxTbg/0cYVJinurlWRfERbwD4o6BFLI40D8g 4JWuyKwUToIkGNcyqCuVFUeC+rDKy8UJt+v+jJ6OHej4wAwom3w5o2hVKeYjUKTj2ixrnxJetGz3n 0mXOMjGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZlB2-000000029fw-1vNY; Sat, 05 Dec 2026 08:31:28 +0000 Received: from mail-dy1-x1333.google.com ([2607:f8b0:4864:20::1333]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZlAy-000000029fC-3O6m for linux-arm-kernel@lists.infradead.org; Sat, 05 Dec 2026 08:31:26 +0000 Received: by mail-dy1-x1333.google.com with SMTP id 5a478bee46e88-38431138772so2454248eec.1 for ; Sat, 05 Dec 2026 00:31:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796459484; x=1797064284; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=5VYtERQnlqR6z0RfgEBN3eiSddueMFHwx7JIcHZ/34Q=; b=AZQcpkooJIPaklNejKdYABX+YAUvsL7g5G3OsQK8Mp+73BGrfeOhwKBeldMTIsefjU gxlvyE79UJsxA1SfAYcIQrY0dnq3/6Ik+9x8bW+BBzk+U4lek2PToLLUBYjJZcila0lR Hz/45fHAegfdoZaaxgxDTEMeTzURLkq0rmXK1J5Hy/TYJnC9ycYaltW1bu0w3gI/z8r7 680xrnO+HN4J1+nmBuiyuUs2NQnSg5ZoTy8AFKH7ZDl7xTzpuZczDHdk7xebofo4EXxO yCjq4cnOEHcg/cwQIjY8Jtf7J01kuUdi5py06katY2XIrT2vo74MD7ojwDRbaectYGot 38jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796459484; x=1797064284; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=5VYtERQnlqR6z0RfgEBN3eiSddueMFHwx7JIcHZ/34Q=; b=l1QPpOTULdF3Hbd3Fl0jX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/Vc5DlsIC03tZRn36sRZ tGkvjzMg5SycWnvZvDgxpGcx1v6K+EyGPbu/OYTJySE8LupdNui161WMIhz8lj7JVSzphqRJ5Xi t4YoCl2dfpOnzAoXheXivMaCKclmZd8t8R33ltXvWze2iDUwpUr25K7CmAYCLD4/Au6SnCDnt7v scOPOckPMh8YjBA== X-Received: by 2002:a05:693c:87c7:10b0:386:a217:aade with SMTP id 5a478bee46e88-387521e272emr4423907eec.29.1796459483557; Sat, 05 Dec 2026 00:31:23 -0800 (PST) Received: from localhost.localdomain (wood.seclab.cs.ucsb.edu. [128.111.49.37]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-38752204591sm18908053eec.21.2026.12.05.00.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 00:31:23 -0800 (PST) From: Praneeth Balasubramanian To: Stephen Boyd , Brian Masney , Jerome Brunet , Heiko Stuebner Cc: Praneeth Balasubramanian , stable@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] clk: rockchip: Do not gate rk3066 PLLs when the GRF regmap is missing Date: Sat, 5 Dec 2026 00:31:17 -0800 Message-Id: <20261205083117.2603316-1-praneethb2002@gmail.com> X-Mailer: git-send-email 2.25.1 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261205_003124_877845_DF6A8408 X-CRM114-Status: GOOD ( 23.35 ) X-Spam-Score: -1.8 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 The rockchip,grf property of the RK3188, RK3288 and RK3368 CRU nodes is optional in the DT bindings. When it is absent, syscon_regmap_lookup_by_phandle() stores an error pointer in ctx->grf. For rk3066-type PLLs the registration code then selects the no-rate ops. Those ops still install the .enable callback. rockchip_rk3066_pll_enable() calls rockchip_pll_wait_lock(), which passes the error pointer to regmap_read_poll_timeout(). All in-tree DTs set the property, so this needs an out-of-tree DT. The lock bit lives in the GRF. Without it there is no way to know when a PLL is locked after power up. So do not power these PLLs up or down at all. Add ops with only .recalc_rate and .is_enabled and select them when the GRF is missing. The PLL then stays in the state the bootloader left it in. The set_rate path that also uses the GRF was already excluded. rockchip_pll_wait_lock() used to be reached only from the set_rate and init callbacks, which are not installed when the GRF is missing. Commit 9be83448951a ("clk: rockchip: add pll_wait_lock for pll_enable") added the call in the enable path. This was found by an LLM-based audit that checks code against the rules stated in kernel comments. Fixes: 9be83448951a ("clk: rockchip: add pll_wait_lock for pll_enable") Cc: stable@vger.kernel.org Signed-off-by: Praneeth Balasubramanian --- Notes: Changes in v2: - Reworked. v1 returned 0 from rockchip_pll_wait_lock() when the GRF is missing, so a PLL could be used before it locked again after a re-enable (Sashiko). v2 installs no enable, disable or rate callbacks without the GRF, so Linux never gates these PLLs. Fixes now names 9be83448951a. The changelog has the right function name and says the property is optional in the bindings. v1: https://lore.kernel.org/all/20261205064016.2525825-1-praneethb2002@gmail.com/ This was found by an LLM-based audit, part of research at UCSB SecLab. An LLM turned a kernel comment into a rule, and three LLM votes checked the code against it. The fix and changelog were drafted with GLM-5.3, then checked against the source and partly rewritten with Claude Opus 5.5. The v2 changes were made with Claude Opus 5.5 after it checked the Sashiko review against the source. I reviewed the patch and take responsibility for it. Testing: builds without new warnings with W=1 (x86_64 allmodconfig), clang 23. checkpatch.pl is clean. Not runtime-tested, and there is no reproducer. I do not have this hardware. drivers/clk/rockchip/clk-pll.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c index d371c66800df..5f60516b2791 100644 --- a/drivers/clk/rockchip/clk-pll.c +++ b/drivers/clk/rockchip/clk-pll.c @@ -86,8 +86,7 @@ static int rockchip_pll_determine_rate(struct clk_hw *hw, /* * Wait for the pll to reach the locked state. - * The calling set_rate function is responsible for making sure the - * grf regmap is available. + * The caller is responsible for making sure the grf regmap is available. */ static int rockchip_pll_wait_lock(struct rockchip_clk_pll *pll) { @@ -575,6 +574,15 @@ static const struct clk_ops rockchip_rk3066_pll_clk_norate_ops = { .is_enabled = rockchip_rk3066_pll_is_enabled, }; +/* + * Without the GRF the lock bit cannot be read, so the PLL is left as the + * bootloader set it: it is never powered down, powered up or reprogrammed. + */ +static const struct clk_ops rockchip_rk3066_pll_clk_nogrf_ops = { + .recalc_rate = rockchip_rk3066_pll_recalc_rate, + .is_enabled = rockchip_rk3066_pll_is_enabled, +}; + static const struct clk_ops rockchip_rk3066_pll_clk_ops = { .recalc_rate = rockchip_rk3066_pll_recalc_rate, .determine_rate = rockchip_pll_determine_rate, @@ -1161,7 +1169,9 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx, init.ops = &rockchip_rk3036_pll_clk_ops; break; case pll_rk3066: - if (!pll->rate_table || IS_ERR(ctx->grf)) + if (IS_ERR(ctx->grf)) + init.ops = &rockchip_rk3066_pll_clk_nogrf_ops; + else if (!pll->rate_table) init.ops = &rockchip_rk3066_pll_clk_norate_ops; else init.ops = &rockchip_rk3066_pll_clk_ops; base-commit: 29beb21c21ada7207692b2d69fc58dcd15dab6e9 -- 2.25.1