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 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 6A240606A32F for ; Sat, 5 Dec 2026 08:31:35 +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=4VvrxNeE; dkim=fail reason="signature verification failed" (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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To: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-Unsubscribe-Post:List-Owner; bh=nU2/hsoDmjItJpiKRAblN+F+FKlkLgIl7KCfDVD/6/U=; b=4VvrxNeEUvzVJS5kt9qzB4NPe3 oESjYXRqeBlbICMMLVb3T+g9y7dU1F/iOqMCctHBdjTLp7+6tRZaeNNmUxTnOCt8hdU1WJY8WZ954 KgyA68ngJsW9SOi9p4m9QoGbxlN1ppK7Q4p50KGoq/9zGH/nzbWxiAN25BhrDp6mJw37cmGQJ7cD4 KswXMWgxw90uMmmyvx3LZGbhg4l91NNXOBK3zJH3mRZZmmWfSTVpo8AMfyc0GwQulDLpc4Kcts/F8 VoEBiQ4JxPEGPqMkAOD7zhcxUcEJ/8hj8WdsOYV0e9lBI8O5kxaYRFUY/VRouiXEeC+ti7mvK+prt VEKxYTyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZlB2-000000029fq-17mc; Sat, 05 Dec 2026 08:31:28 +0000 Received: from mail-dy1-x132f.google.com ([2607:f8b0:4864:20::132f]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZlAy-000000029fB-34uO for linux-rockchip@lists.infradead.org; Sat, 05 Dec 2026 08:31:26 +0000 Received: by mail-dy1-x132f.google.com with SMTP id 5a478bee46e88-386c71feeeaso2198869eec.0 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=GyfYnXnPnLQrHnr4F5Jar4f/ojqSRV31SeT8eR97m69d1YblZjlubHYvzOiyyV5P6k xwCF5/A3Is2XK8kUE+jKJUiChzht42pSvinx2yZptOUKLo+FqkvaviLugGZvjS4tp8ry keyeDU0uKISWV6oO9UuObEQhLJjJMC+d4nP0EQL7fFEuctpRIDyTyY3vAwijftQzdzVs lcyBauqhJa7OpjxxDnbRmcQ4K+tUS6vfUFUJa8mYAdYk7hrWQFEkVfVh9V+Is1fHZrq0 ZS27NffVFehc2wThv+meP0ZoEt9QYwfiz7dB3yFQBWZogTKRXU7cnhKZsP3Tra38MqZJ a2/Q== X-Forwarded-Encrypted: i=1; AL+hErFn+iDk71f0gMWGm8VZpa9kozOo/ellQv5NGYB8I/Y/HxMkFgJe+Tlb1MJcngTVgtKZCZ6WWRTcogVfdg3leA==@lists.infradead.org X-Gm-Message-State: AB4q+uHmAB0xo02BKcXrEzpA5GIM4YXhiUv5Nh6kGKKumZVlWhHvG3s8 cl+283ZioH+nQLVuKrslVHc8MR/vPyycKXyCVAZ2UFOjUIGRCDik7QXf X-Gm-Gg: AZFdTZdmr2rTTbpuyjQrhpMRWHlkrgvpsLsbBe+p2w+uesGa85rXkwvvMux/3Xf0ZPo WlJXae8upAJEh550HwNyp/E2nqZ3LsYtAQS+hao4AXV/xcAWqHhamRpoO6ykxqxP7wmO8Atwhg+ J7ynh4AZrKIrrrV+AGbHh8jk2//avNsnWR3mdr0sRJDGWQedd01alVZi57gyYewnoR3DjcPRajX QyVleqqmo17IBF2N9jBSgqlcS68QExs1tW72oeFNrsthkMK61+C2eS/LUyfhkRBZwDJu+JJMT5R JEzrZ202EJayevnGx1f/A15YqSUpjO3gM7VgDYKYJqGNFN97cqihOYtPDX13ZVRpgpJU5AdiZtj G62xBCol0Cfgu40mq/W/KTBkfj5ZPUn5dU099TUyJSnY0Aade3O2I+HuQ69f11xRRI2ls+uIb0I YZUKKWOmOAWdWv55ozpZVKsiup36PDris12u2jg16MvLds83gsYTR0H+UJyFNauZ3rtHw7Cc5IU sAWmbKuJ/Id36uBtsA0TOe8tRIlMHhpHklgeNiEbQKvxRrxRIgdR36RMritAHow4FELiaTq806U mKMbXtBovzw4CNWAiKPEtD8c1YhYI6n5RiQ2LWknjeBk5K3BoL48jiXti9DxLfqJtJjNXyN58bf 645vjxJd7v8EH+w== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261205_003124_798616_CD2ECAB0 X-CRM114-Status: GOOD ( 22.04 ) X-Spam-Score: -1.8 (-) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" X-Spam-Status: No, score=-14.1 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,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 _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip