From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.175 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796459485; b=SaEAJOw55+uSux2fWTQIFuN6Gva1mMNywrfHUimpAozSl59QHafPiULCJLiUsuhNENUw /iK+FHIyJx/ritteu7zATCBLPE4RrMz73l+yeXwhC0gnJo+yUkWkAnzkHxF1VytL1bwyx pwsrBEpHPc0FgwuL95sm1fs6TU7Ow3lWLSJ+FNL5QDOc5bf2KnmoVhgo5u3j2Hz28RM/2 pJGrTIqUbgAPq9rvDAm0fMmsF0odlzaoUHuoV111dULDZQoLpZMhr0dWX639vEGdscPv1 TIloOcVAVzBoZ22RAgjuFdXnM7JcwBHvSYR65smI4mE+YxurP1Ay9n2Dx0zpwJWkzWg== 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=YJQnIUJWSf3jbd/c45gNGpOogaT7aK/bf134j4lBX/DFRulOq2t1Upai+qazQSbCddMi yuU8pedoVbw9YqrFmx7sxm9S2xlZMLN4IYgRaJAq7nKSfLBAPDFQtNsKUaQpb6W/QdmHj CaEE3h794jpUoWtZLkzqz5TeIY3PhRGKERNT1GkAqBIGyrxWbQV2qJaBHUtk1JtZ5IhhJ /QI1boFNzScBRWGGbXhAndrAyFIZkw3cdNQY6bUDmuN0+OqsUVh8/dZtHuNXx1J7vbK0N H4fXmWEh6l85tMlwo6JNHjhf0/BoT1KZZ7XXS0cKZYJ/DHs6PU89IH78a9TDsDQQsCQ== 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.175 Received: from mail-dy1-f175.google.com (mail-dy1-f175.google.com [74.125.82.175]) (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 97A4F606A322 for ; Sat, 5 Dec 2026 08:31:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 97A4F606A322 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-f175.google.com with SMTP id 5a478bee46e88-38431138772so2454246eec.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=gqhd89RsbY5Xqu5BsSGN15CddYX9Fmvkobntd8l0OzkQyPMqJxpdj4sbtki/ylKO+f CxdSS4oepdSgcIlns7s+0MPMm2WFCXrhoMxXicixxWx99jHYX81dRAJLxHTJoFeg3Vaz XUPRe6P1kPkgmxEgmJaS38U0hWCWAx7OutQmZtfs7AvZcC+9NEC3QtPIDEGpT/A3kMRW fSreF6o+ArN3K4Ip4LCIBl8a8yqRupR+FYpahvckYFbmDeX5WbKC3RoswA43IewcD9+T Dw6ZziT48umDS2EASU5APKLNHvzDp4JgSgegex+mwWp4t7PoQR5WmGheEasaIW8wnqkr Ooog== X-Forwarded-Encrypted: i=1; AL+hErGGU3F4WbDA/uVyXRSNtsDweAj2he/vV5p1HMJGM5F3S9NHRFnSRm6M5zkDaRNa/uBLGwbVJydIuQ0=@vger.kernel.org X-Gm-Message-State: AB4q+uE3Zwgk5uMQ3RhpDTGWXRgzSZgTuSdQbrGybIRg0fua2AlzCqT1 yAIlSfAhymBHqQ4MHllVz2OZByDn9qZ1wQvZlgrN3wfPkaLRfRx/JdhZ X-Gm-Gg: AZFdTZcifpewLpFGmtDj6hM0hzTaCxhyWCccU0jgyjS9pB+0iP+fqId7egGIKu2OaCf K1mlDQoANeV+2WFG3txzhUVxHzmXdVm7AvYpoEsT+zqSFoDTGI3JwrwGveHiTtby9Iy/THD1RBh Y6XG8jZOXWKk211EKHiU996Gm9EmoHjBy7AbsWVmFwDacuATf6hHUkQVMwvCLRqtXNdzEIiUpTC C0/0TOTDW/EvOtX3OwEx/8dECbuEsZd4sJioMw4x3x1Dci7hAF6E7eCqpRLYmv8N3Dk272EQ4um HuwbmKeugZrlfvfxO8N0uwsG8BwhNs0/KTe9VTrwL/ZxIScixR/EGRGY04DIRuiALf68EEnG/oc cdFPvfnYqI1gCER6agpleS36WqZCGA6uhRjFF/vBrK2tjmbHTc/LgEBgkep+MHm6zbemUDQ1hrt MDtd5s6APC/31zS4CLxzo7OhRXBq3D//W6GEwKC2DhLSgKgRZYs4kletM/Lu+cT12xxqWw7JtgU i5ZSPZLmL0ljdw4U35oirmh5OQkJ/Uy1kS9m8iaKN1clOomQOCnf03Mb444bWpTwdzn1FJ3T3u5 qkHfbmqaKiodzx60ThOGYYEJ7SVpdxCChvGu73cqmaQ9nDaFWHGsu9+dRHdSFce7EdgAKBqXxtv P4npfR2NjVgBPJQ== 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-clk@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