From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.176 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796459485; b=r6pT1P0Bn0Aca32NORfSI8Uaf6Itg00Hoj6/Rkx5OF+o+WjzmeijEMTQ2cy8MsWtA5Um GjgGho6UupeMyORHRi1QdpUUSfqiJnnaoT8AaxdL6NNF3iGif6EbpHPdkn/STauv1P9Ng nS/vX5edep1UdIpGdmt+HBW+zX9Yu0nq++5oM1mOhYy3LMcDYZrygxA6Y8VrMOr2sscOO gEILfrWN7txPva0oiun9/4vGw9nXilri9aFTPgo/ZVpDc7MytvSkfQOg4TEL/4tok7pxN D3VDAba3xoRFU2Znk3y8abSBtkJz9+IMjZjLHBxKW19ThIh3eQE3q7RrwTXbhnPbF6g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796459485; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=5VYtERQnlqR6z0RfgEBN3eiSddueMFHwx7JIcHZ/34Q=; b=iAqb4YvQIGnahAJHSnQYEY/dtj95oJfDHo0xOXCXvv10kII5iOeH71LYLiBKTaTyHKXI QEOYfjHLFKVLe1cCfnAb9EorvjB+aevcwVF5uZHJNB/lEFJg3smnYJfojzjSRPNYr1baP yQWFcv+nRxGtmENUKcanSN00dEGu3yu4nwsP0dqI4YUw6UPchK9eMmeLcCGdnPKx9z0pA Bcqw5EqMLWHtzOZpB5zpbBowS9PuO1fvPtjXu9bycSM3mKnLHySPyptETNACgEinbJnef CUE21oHtctvcwOkliN4JDOYEQIM+9IvaOyTdxL4dxQIyrF95LrumYthQEm5mwuKw3dA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=pHvu8FGJ; arc=none smtp.remote-ip=74.125.82.176 Received: from mail-dy1-f176.google.com (mail-dy1-f176.google.com [74.125.82.176]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD544606A330 for ; Sat, 5 Dec 2026 08:31:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BD544606A330 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=pHvu8FGJ Received: by mail-dy1-f176.google.com with SMTP id 5a478bee46e88-38431138772so2454247eec.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=vger.kernel.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=pHvu8FGJAnF4rPrYl7X03RayuP44GB0Nc6xGxd5Dd7lCFLAWPr+S7lhv2DrzzDQ12h sht10t8La+7SYG0QVy0htt9ugjLnur+3Gd6Ta0mEo9FoPjnOGMDtt8KhwgsYYvlqCQIi 4pYMwtyxFsi7em4bZvsRUmp4aNSwLqGHwrieVDtZtYvgwqQ2mlM6iaf1go1OBhQ/Wl+S ptQC2BSHkSIrDhnSPtSkdb3ibnP3DUFletBeeBh835q8/jelIR/lhH39T7rRAsmVrQeS 4bdHAfRLK+suEIyRRMiFoEXaCkNgsIR4/k+kIagI0+9KqaeTr5AZNZ53mbWIYrpfnUFg H1yQ== 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=GYUbe8tnbf9vbz38x8ju7PMHI3JjnrRMFlI9oLQ2QxrT13UI0Nz3//df+EmFguvMAQ v543368tlGtJalgHhob9swL36d8+8EwNksWp/GKPf59tBMNLqrhqliXOsOpu/4yJe3/n fGifZlrxQipBWhBn1V1PvuTVK+Ysd11BYyVr/FKLhxPXSHE5iQnh1n+hc0JgFrTQ1W6E VpODCyIaUhy+Re+k7A24ZgvpZ/PVgI2bpjaDJKJaRqcLM/vNAf/2eazxZpF+yTiRuwr9 ndvVPt1JGMSbYhYxexUJL0Q0G94DjZiG3b8LCqOWuqweHbronBqUqZv3fzXyJ3MBe/3/ +u1g== X-Forwarded-Encrypted: i=1; AL+hErHU8mo4KwA8ZSJhwj+UTGvoqzMuN5DEtEwCYSqYRZ+V5HlhZqrOdT0eOxbzGBMoe/TJB0vJBtl0ISoLYKQ=@vger.kernel.org X-Gm-Message-State: AB4q+uFGUWjNc1NMs2oTWz9Dp743WS+T5pPc/WLK+1lQK2Bfz3HptMp3 BJyzIQ9lbsNjapQzWkEu0BKQtpbpmC7mhGc3bMtofhpHc96wp0pGsmPE X-Gm-Gg: AZFdTZeON3TJCbJWI93YS/on5j2ISf2d/rr2BLaP5G9gM8tT/0yOzwn+vNXGTo7C7xJ AcoPJBpYjzR56nZ2OMSXNAszfI5OeacKCkMKUjo5Fot+D93R8rcSDB5fQepojXyPWtgiydKSkBy gaQagNjd3wWBZ6dM596/NUR5a//QieuAcdqUsmXrVnQlrsX2o0REzdMnlhy63pFvIktJqEg4sN+ 1xxpFay5i9lDM13oMyUbCFVYRK0KmYjgeBUqNVjk6IgWtzwDTkB/86aoPpHAkhW2K3ziIQ0RoCL Hau2B1XGw1VkqLXi5UgLNpHDy/qB5sbZyOqMSuYyE9stl4hxSvoTWI3IkUggIjY0AEsktCDT2gG 9S29i7KKz0ynjylXaDXcdAhSXF3LSBWlbrZoTul9k2BhQNvH4NEXaPQecRQI/yHviC1JblUYYQX Uu3VQCpFaZIWmWdfEnXZlneXHKBuGxOydNmTm/RF2kcETxFV7jz5d+UYGd+i/mG9v3lE9ac1wSZ D8L3MtBpdG7NleV6svclbRLksXziMIpQbQ90Xfq4fn6+Jyik+ikXpRLMdwT2qlirv14W2BZVig6 z1YLNLtl+ufDu/FslYKw7492JvGUQmF5H1VrdX656YtVf7ID0CjWWnW49Qzd4amNUQAOmKAdW4s h6e+niE4VvBP6eQ== 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-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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