Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Stefan Dösinger" <stefandoesinger@gmail.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org,
	linux-phy@lists.infradead.org, olteanv@gmail.com, lee@kernel.org,
	linux-clk@vger.kernel.org, mfd@lists.linux.dev,
	conor+dt@kernel.org, neil.armstrong@linaro.org, vkoul@kernel.org
Subject: Re: [PATCH v12 07/12] clk: zte: Add zx PLL support infrastructure
Date: Wed, 23 Sep 2026 18:42:04 +0000	[thread overview]
Message-ID: <20260923184204.82F1C1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260923-zx29clk-v12-7-9c243796b6d2@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] clk: zte: set_rate rejects valid rates due to strict VCO bounds check
--

commit 03d27f14b3d2dbba9c34e624628df45495020947
Author: Stefan Dösinger <stefandoesinger@gmail.com>

clk: zte: Add zx PLL support infrastructure

This patch adds code to decode and program PLL settings on ZTE's
zx297520v3 SoC.

> diff --git a/drivers/clk/zte/pll-zx.c b/drivers/clk/zte/pll-zx.c
> index fc76c6524a163..d3687495d06ce 100644
> --- a/drivers/clk/zte/pll-zx.c
> +++ b/drivers/clk/zte/pll-zx.c
[ ... ]
> +static u32 zx29_pll_calc_values(const struct zx29_clk_pll *pll, unsigned long parent_rate,
> +				unsigned long rate, unsigned long min_rate, unsigned long max_rate)
> +{
[ ... ]
> +	for (j = 1; j <= postdiv2_max; j++) {
> +		for (i = 1; i <= postdiv1_max; i++) {
> +			u64 vco = (u64)rate * i * j;
> +			unsigned long out;
> +
> +			if (vco > ZX29_PLL_VCO_MAX_FREQ || vco < ZX29_PLL_VCO_MIN_FREQ)
> +				continue;

[Severity: Medium]
Will this strict bounds check reject valid rates during zx29_pll_set_rate()?

If the requested target rate maps to a VCO frequency at the very bottom edge of
the valid bounds (e.g. exactly 900 MHz), the rational approximation for the
dividers could produce an actual VCO frequency just below 900 MHz.

When zx29_pll_determine_rate() returns this slightly truncated output rate, it
is then passed to zx29_pll_set_rate() which passes it back to this function.

At that point, the recalculated VCO will fall slightly below
ZX29_PLL_VCO_MIN_FREQ and be strictly rejected.

[ ... ]
> +static int zx29_pll_set_rate(struct clk_hw *hw, unsigned long rate,
> +			     unsigned long parent_rate)
> +{
> +	struct zx29_clk_pll *pll = to_zx29_clk_pll(hw);
> +	u32 setting;
> +
> +	/*
> +	 * TODO: Implement gradual PLL rate change. PLLs can be changed while they are running and
> +	 * downstream hardware is generally fine with that. The exception is DRAM, which reads
> +	 * incorrect values if changed too fast.
> +	 *
> +	 * Changing the mpll rate is potentially useful for over/underclocking. Gating mpll is
> +	 * unrealistic because too many devices depend on it.
> +	 */
> +	setting = zx29_pll_calc_values(pll, parent_rate, rate, rate, rate);

[Severity: Medium]
Since zx29_pll_calc_values() can fail due to the strict VCO bounds check, does
this cause zx29_pll_set_rate() to unexpectedly return -EINVAL for a rate that
was just validated by zx29_pll_determine_rate()?

This breaks the Common Clock Framework (CCF) contract, which expects set_rate()
to succeed when passed a rate validated by determine_rate(). Could this cause
regressions through unexpected driver probe failures?

> +	if (!setting)
> +		return -EINVAL;
> +
> +	dev_dbg(pll->dev, "%s: Setting new configuration: 0x%08x\n", clk_hw_get_name(hw), setting);
> +
> +	return regmap_update_bits(pll->map, pll->reg, 0x00ffffff, setting);
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260923-zx29clk-v12-0-9c243796b6d2@gmail.com?part=7

  reply	other threads:[~2026-09-23 18:42 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23 18:28 [PATCH v12 00/12] ZTE zx297520v3 clock bindings and driver Stefan Dösinger
2026-09-23 18:28 ` [PATCH v12 01/12] dt-bindings: clk: zte: Add zx297520v3 top clock and reset controller Stefan Dösinger
2026-09-23 18:33   ` sashiko-bot
2026-09-23 18:28 ` [PATCH v12 02/12] dt-bindings: clk: zte: Add zx297520v3 matrix " Stefan Dösinger
2026-09-23 18:37   ` sashiko-bot
2026-09-23 18:28 ` [PATCH v12 03/12] dt-bindings: clk: zte: Add zx297520v3 LSP " Stefan Dösinger
2026-09-23 18:32   ` sashiko-bot
2026-09-23 18:28 ` [PATCH v12 04/12] mfd: zx297520v3: Add a clock and reset MFD driver Stefan Dösinger
2026-09-23 18:35   ` sashiko-bot
2026-09-24 14:15   ` Lee Jones
2026-09-23 18:28 ` [PATCH v12 05/12] clk: zte: Add Clock registration infrastructure Stefan Dösinger
2026-09-23 18:36   ` sashiko-bot
2026-09-23 18:28 ` [PATCH v12 06/12] clk: zte: Add regmap-based clocks Stefan Dösinger
2026-09-23 18:38   ` sashiko-bot
2026-09-23 18:28 ` [PATCH v12 07/12] clk: zte: Add zx PLL support infrastructure Stefan Dösinger
2026-09-23 18:42   ` sashiko-bot [this message]
2026-09-23 18:28 ` [PATCH v12 08/12] clk: zte: Introduce a driver for zx297520v3 top clocks Stefan Dösinger
2026-09-23 18:44   ` sashiko-bot
2026-09-23 18:28 ` [PATCH v12 09/12] clk: zte: Introduce a driver for zx297520v3 matrix clocks Stefan Dösinger
2026-09-23 18:40   ` sashiko-bot
2026-09-23 19:06     ` Stefan Dösinger
2026-09-23 18:28 ` [PATCH v12 10/12] clk: zte: Introduce a driver for zx297520v3 LSP clocks Stefan Dösinger
2026-09-23 18:40   ` sashiko-bot
2026-09-23 18:28 ` [PATCH v12 11/12] reset: zte: Add a zx297520v3 reset driver Stefan Dösinger
2026-09-23 18:45   ` sashiko-bot
2026-09-23 18:28 ` [PATCH v12 12/12] ARM: dts: zte: Declare zx297520v3 CRM device nodes Stefan Dösinger
2026-09-23 18:39   ` sashiko-bot

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=20260923184204.82F1C1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=mfd@lists.linux.dev \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=stefandoesinger@gmail.com \
    --cc=vkoul@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