From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.174 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796459485; b=XGSdf1Otk1SmUqOTyLrE0rOp+LI1yiy7h9y+NBDHw/jfdJyBgA65XFz1WdvhdGdXr3e9 4vgdB1ATEgmjZe/9e4DNgPsrHcXBOsqZsr7Uy+5CwITbztfLpjvWV0A3Xs8iHxZB1xDng Wt7OySrjzIEiqFaBRECjBEvKmCubjUz+0bAaIUGIbJATtZ0uFiu5GTiSnihEOE02SY5gn QJW7Y8O7SBZxsS2VhxYCL4XncqQ56aIZaIsrMSBEIUO1VO9jUAI/YJ4Om7Q5eaLkuRD3s UE/fLortrVrnCVN6Pfu0vCW7nHOF/pmo+EQ4IfgMI81Fg1x60o0Dq+Z+pzuLydXA2+w== 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=3zyMSj65RXLw/IoX47k8lFWJ1GbrGxMxV7p47TGdKqEEWu9r2olu0FHs+6gf8al/JK8z LTzHsr3dmubePIg+Zz9rKlHQZwl6qGtfRan9If7gYjCmYXDlB0w27P0iVLWxOlL1oGcwO n3K7ur3KuNaqLlSXW0Ev2iWjrwQTOFYS8hB/hm0WgQQGNHIlsnWMHwOPgsv8RXA0XNSWC 1/b4cUbP8eOZoOIqM0gsALa09Va/Of59Ygwu9NYhPNsZ554hh9zylKhf0GVgD5xx++1oN xKJxz5gVkTWHhJhzuH2/xUeU4KMWLObKt4CS80ToD2BYRFQSjocytg1afgntx79hmAA== 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.174 Received: from mail-dy1-f174.google.com (mail-dy1-f174.google.com [74.125.82.174]) (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 9FF17606A32F for ; Sat, 5 Dec 2026 08:31:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9FF17606A32F 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-f174.google.com with SMTP id 5a478bee46e88-38431138772so2454245eec.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=v102ceis5izFIA4tLr82Y40j7bpLYPbvM4AHvyQhqmfIIVrVU7IQB8ZkWg+twIDpLp uekBN0lUkHTtn8ak3GJ34CYpifYih/I9biKPikn3A1OSLLgnKmLN9pCapllZ2uUE8zqm 5uTBStS7wOK0C5QQgrQS0kTBKm18nrZ/Jb+jWoukII4un8a8ZtIh7RAjBY4WGSMNV5Ud hKY6Q/klHYNcngoLI1WjNdGeCqjxwk2vCYX8baTXuAwersd7nIZv8Sy4AZSN9IrDKwoe 7tB5bTtymV1L8Qnwz3jqWFEVX8M4pA++0Bh2belsBeOhXc+KkXeVaSFBq8RLTBaoKDIz OKnA== X-Forwarded-Encrypted: i=1; AL+hErFEdNCg5fwUNrLPJziyl7Kewn9yliQwJxmqg3IAEA+m0K0XyhJ8cPbee+8c6VK/NN0NQN1g+C0=@vger.kernel.org X-Gm-Message-State: AB4q+uHsfqH0HjH4pMI13X1QvSR/QVdc0mzxBFznYLk9iBcL4asbQpNY UEkATe4KPHQ1AJKvByFtmZ+MNAlorwACiU6WcmbDmhRFZyIrcI9JHgtghKwa/mKG X-Gm-Gg: AZFdTZdlMJ3zJ1Fvm693xRZVDboFXNq4LksBRVxiHrUN10WFXHRqnvJ9OZ8lI6OYH3Z ybnwnmYRSbUH9SN3DppnYFh9tuTPWt/Md5fCUye+nWh50vzyc83KZNSVqCZl+YbbRK7RVj9kS55 8zp63s6OH/yDVRmN01fR2ALUBjL2cYwoWQwSo5Lt23sSmNtIIyap9crcRMWQYYqYJCN9jf+dFGk sdlPuY1O0YB9wP/VtMp48SPptAfAt8Nz3TX+f9fTiVsoJMZDmxb8fG73YgCStjSCpbyUehOcfs8 eD+gMv42WfBM7UofXWl0Mc6kr1bIqzCI80LnWAWDnVnghQctBUnX76w/UU0SnkiJps3DwX0CeDO jOBsIUYDxqKDNyxEH0oP1FqJvgbeey2XbA/AOdHYYdsPeWAs4STnFUE57iAYFU6EVs5f/b0iHUw fpaj7GHzEMDkDJwwHED/CBkDYMqWpw0wg0R1dO2YJIQfudeeeVRsuSj5MPqY/wf9ZDadX5IFln7 +giiaiVCmAJBaQRE/y7q4+lk4ECbEs4GipQd1vpcwwpJi+MSUoO6o78VyU/Spm35YkOUEia2Da3 emg0u07ZfVTRz5WfRuaOaq0U04McrXGd6tYnGbEW6Pu+oNOoiBAirMonQB04txCb6F1ImKs7Fvd dAyrGSj0IwJ6Gew== 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: stable@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