From: sashiko-bot@kernel.org
To: "Troy Mitchell" <troy.mitchell@linux.spacemit.com>
Cc: linux-clk@vger.kernel.org
Subject: Re: [PATCH 4/5] clk: spacemit: reject rate changes to running firmware PLLs
Date: Wed, 09 Sep 2026 14:22:18 +0000 [thread overview]
Message-ID: <20260909142218.BF89E1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260909-spacemit-pll-init-v1-4-b3065ad5a4ac@linux.spacemit.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Calling clk_set_rate() immediately after clk_disable() may intermittently fail with -EBUSY because the hardware PLL lock bit is checked without polling.
--
commit a90cd779d21914719856a7e102c5e63e9892f73b
Author: Troy Mitchell <troy.mitchell@linux.spacemit.com>
clk: spacemit: reject rate changes to running firmware PLLs
CLK_SET_RATE_GATE only protects clocks prepared through CCF. A PLL left
running by firmware can have a zero prepare count, so this flag alone
cannot prevent set_rate() from reprogramming a live PLL.
> diff --git a/drivers/clk/spacemit/ccu_pll.c b/drivers/clk/spacemit/ccu_pll.c
> index c9852fed31017..2573b8396cefa 100644
> --- a/drivers/clk/spacemit/ccu_pll.c
> +++ b/drivers/clk/spacemit/ccu_pll.c
[ ... ]
> @@ -113,6 +122,17 @@ static void ccu_pll_disable(struct clk_hw *hw)
> ccu_update(common, swcr3, PLL_SWCR3_EN, 0);
> }
>
> +static int ccu_pll_check_stopped(struct ccu_pll *pll)
> +{
> + u32 val;
> + int ret;
> +
> + ret = regmap_read(pll->common.lock_regmap, pll->config.reg_lock, &val);
> + if (ret)
> + return ret;
> + return val & pll->config.mask_lock ? -EBUSY : 0;
> +}
[Severity: High]
Can this cause clk_set_rate() to spuriously fail with -EBUSY?
If a driver calls clk_disable_unprepare() followed immediately by
clk_set_rate(), the .disable callback will clear the software enable bit
and return instantly.
When .set_rate calls ccu_pll_check_stopped(), it performs a single
non-blocking read of the hardware PLL lock bit here. Since the analog
PLL requires time to lose lock, wouldn't the lock bit often still be
set, causing the valid rate change to be rejected?
A follow-up patch "clk: spacemit: safely synchronize PLL parameters during
init" seems to acknowledge this behavior by adding a ccu_pll_stop() function
with a polling timeout. Should a similar polling mechanism be used here
instead of a single read?
> +
> /*
> * PLLs must be gated before changing rate, which is ensured by
> * flag CLK_SET_RATE_GATE.
> @@ -122,11 +142,20 @@ static int ccu_pll_set_rate(struct clk_hw *hw, unsigned long rate,
> {
> struct ccu_pll *pll = hw_to_ccu_pll(hw);
> const struct ccu_pll_rate_tbl *entry;
> + int ret;
>
> - entry = ccu_pll_lookup_best_rate(pll, rate);
> - ccu_pll_update_param(pll, entry);
> + /* CLK_SET_RATE_GATE does not account for firmware-only users. */
> + ret = ccu_pll_is_enabled(hw);
> + if (ret)
> + return ret < 0 ? ret : -EBUSY;
> + ret = ccu_pll_check_stopped(pll);
> + if (ret)
> + return ret;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909-spacemit-pll-init-v1-0-b3065ad5a4ac@linux.spacemit.com?part=4
next prev parent reply other threads:[~2026-09-09 14:22 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 14:07 [PATCH 0/5] clk: spacemit: preserve and safely synchronize firmware PLLs Troy Mitchell
2026-09-09 14:07 ` Troy Mitchell
2026-09-09 14:07 ` [PATCH 1/5] clk: spacemit: derive PLL rates from hardware Troy Mitchell
2026-09-09 14:07 ` Troy Mitchell
2026-09-09 14:07 ` [PATCH 2/5] clk: spacemit: make MIX rate selection consistent Troy Mitchell
2026-09-09 14:07 ` Troy Mitchell
2026-09-10 13:01 ` Yao Zi
2026-09-10 13:01 ` Yao Zi
2026-09-10 14:19 ` Troy Mitchell
2026-09-10 14:19 ` Troy Mitchell
2026-09-09 14:07 ` [PATCH 3/5] clk: spacemit: describe CPU clock dividers and shared PLL muxes Troy Mitchell
2026-09-09 14:07 ` Troy Mitchell
2026-09-09 14:21 ` sashiko-bot
2026-09-10 3:23 ` Troy Mitchell
2026-09-09 14:07 ` [PATCH 4/5] clk: spacemit: reject rate changes to running firmware PLLs Troy Mitchell
2026-09-09 14:07 ` Troy Mitchell
2026-09-09 14:22 ` sashiko-bot [this message]
2026-09-10 13:31 ` Yao Zi
2026-09-10 13:31 ` Yao Zi
2026-09-11 2:02 ` Troy Mitchell
2026-09-11 2:02 ` Troy Mitchell
2026-09-09 14:07 ` [PATCH 5/5] clk: spacemit: safely synchronize PLL parameters during init Troy Mitchell
2026-09-09 14:07 ` Troy Mitchell
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=20260909142218.BF89E1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=troy.mitchell@linux.spacemit.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.