Linux-Rockchip Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Praneeth Balasubramanian <praneethb2002@gmail.com>
To: Stephen Boyd <sboyd@kernel.org>,
	Brian Masney <bmasney+clk@redhat.com>,
	Jerome Brunet <jbrunet+clk@baylibre.com>,
	Heiko Stuebner <heiko@sntech.de>
Cc: Praneeth Balasubramanian <praneethb2002@gmail.com>,
	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] clk: rockchip: Skip PLL lock wait when GRF regmap is unavailable
Date: Fri,  4 Dec 2026 22:40:16 -0800	[thread overview]
Message-ID: <20261205064016.2525825-1-praneethb2002@gmail.com> (raw)

When the DT node for a CRU has no rockchip,grf phandle,
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_pll_enable()
calls rockchip_pll_wait_lock(), which passes the error pointer to
regmap_read_poll_timeout().

The only way to reach this state is a DT error, so the harm is limited
to robustness against a broken DT. Add an IS_ERR() check on the GRF
regmap in rockchip_pll_wait_lock() and return 0 when it is missing.
Without the GRF the lock bit cannot be polled, so the PLL is assumed to
lock after the powerdown bit is cleared. The set_rate path that also
uses the GRF is already excluded by the ops selection.

This was found by an LLM-based audit that checks code against the rules
stated in kernel comments.

Fixes: 90c590254051 ("clk: rockchip: add clock type for pll clocks and pll used on rk3066")
Cc: stable@vger.kernel.org
Signed-off-by: Praneeth Balasubramanian <praneethb2002@gmail.com>
---

Notes:
    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 and
    checked against the source with Claude Opus 5.5. 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 | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c
index d371c66800df..88bced1915e6 100644
--- a/drivers/clk/rockchip/clk-pll.c
+++ b/drivers/clk/rockchip/clk-pll.c
@@ -95,6 +95,9 @@ static int rockchip_pll_wait_lock(struct rockchip_clk_pll *pll)
 	unsigned int val;
 	int ret;
 
+	if (IS_ERR(grf))
+		return 0;
+
 	ret = regmap_read_poll_timeout(grf, pll->lock_offset, val,
 				       val & BIT(pll->lock_shift), 0, 1000);
 	if (ret)

base-commit: 29beb21c21ada7207692b2d69fc58dcd15dab6e9
-- 
2.25.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

                 reply	other threads:[~2026-12-05  6:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261205064016.2525825-1-praneethb2002@gmail.com \
    --to=praneethb2002@gmail.com \
    --cc=bmasney+clk@redhat.com \
    --cc=heiko@sntech.de \
    --cc=jbrunet+clk@baylibre.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=sboyd@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox