Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Stefan Dösinger" <stefandoesinger@gmail.com>
Cc: linux-phy@lists.infradead.org, vkoul@kernel.org,
	neil.armstrong@linaro.org, olteanv@gmail.com,
	conor+dt@kernel.org, mfd@lists.linux.dev,
	devicetree@vger.kernel.org, lee@kernel.org, robh@kernel.org
Subject: Re: [PATCH v10 07/12] clk: zte: Add zx PLL support infrastructure
Date: Mon, 10 Aug 2026 07:13:57 +0000	[thread overview]
Message-ID: <20260810071357.9B5A41F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260810-zx29clk-v10-7-63846490712c@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Due to integer division truncation, valid PLL configurations are falsely rejected during clk_set_rate(), causing frequency changes to fail when the calculated VCO falls slightly below the minimum limit.
--

--- Patch [7]: [PATCH v10 07/12] clk: zte: Add zx PLL support infrastructure ---
commit 02ad18f21bbd9b41b5dbd910425b934e48d8ecd9
Author: Stefan Dösinger <stefandoesinger@gmail.com>

clk: zte: Add zx PLL support infrastructure

This commit adds PLL support infrastructure for ZTE ZX-series platforms.
It implements the standard clock API operations including rate calculation,
parent selection, and configuration of fractional and post dividers.

> diff --git a/drivers/clk/zte/pll-zx.c b/drivers/clk/zte/pll-zx.c
> index fc76c6524a163..e8d57dd1386f1 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]
Can this strict lower bound check reject valid configurations? 

If a frequency is requested where the chosen dividers produce a VCO at or
just above the 900 MHz minimum, integer division truncation might cause the
recalculated vco to fall slightly below ZX29_PLL_VCO_MIN_FREQ, falsely
rejecting the configuration.

[ ... ]

> +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);
> +	if (!setting)
> +		return -EINVAL;

[Severity: Medium]
Will zx29_pll_set_rate() unexpectedly fail here for valid rates it previously
advertised via zx29_pll_determine_rate()?

If the requested rate was slightly truncated due to integer division, passing
it back into zx29_pll_calc_values() with strict exact-match bounds where
min_rate and max_rate equal the truncated rate might trigger the minimum VCO
limit check shown above. This would result in returning -EINVAL and breaking
the frequency change.

> +
> +	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/20260810-zx29clk-v10-0-63846490712c@gmail.com?part=7

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2026-08-10  7:14 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-09 21:28 [PATCH v10 00/12] ZTE zx297520v3 clock bindings and driver Stefan Dösinger
2026-08-09 21:28 ` [PATCH v10 01/12] dt-bindings: clk: zte: Add zx297520v3 top clock and reset controller Stefan Dösinger
2026-08-10  7:12   ` sashiko-bot
2026-08-10 15:38     ` Rob Herring
2026-08-10 18:49       ` Stefan Dösinger
2026-08-09 21:28 ` [PATCH v10 02/12] dt-bindings: clk: zte: Add zx297520v3 matrix " Stefan Dösinger
2026-08-10  7:07   ` sashiko-bot
2026-08-09 21:28 ` [PATCH v10 03/12] dt-bindings: clk: zte: Add zx297520v3 LSP " Stefan Dösinger
2026-08-10  7:05   ` sashiko-bot
2026-08-09 21:28 ` [PATCH v10 04/12] mfd: zx297520v3: Add a clock and reset MFD driver Stefan Dösinger
2026-08-10  7:10   ` sashiko-bot
2026-08-09 21:28 ` [PATCH v10 05/12] clk: zte: Add Clock registration infrastructure Stefan Dösinger
2026-08-10  7:17   ` sashiko-bot
2026-08-10 21:47   ` Brian Masney
2026-08-09 21:28 ` [PATCH v10 06/12] clk: zte: Add regmap-based clocks Stefan Dösinger
2026-08-10  7:10   ` sashiko-bot
2026-08-09 21:28 ` [PATCH v10 07/12] clk: zte: Add zx PLL support infrastructure Stefan Dösinger
2026-08-10  7:13   ` sashiko-bot [this message]
2026-08-10 21:56   ` Brian Masney
2026-08-09 21:28 ` [PATCH v10 08/12] clk: zte: Introduce a driver for zx297520v3 top clocks Stefan Dösinger
2026-08-10  7:15   ` sashiko-bot
2026-08-10 21:58   ` Brian Masney
2026-08-09 21:28 ` [PATCH v10 09/12] clk: zte: Introduce a driver for zx297520v3 matrix clocks Stefan Dösinger
2026-08-10  7:14   ` sashiko-bot
2026-08-10 21:59   ` Brian Masney
2026-08-09 21:28 ` [PATCH v10 10/12] clk: zte: Introduce a driver for zx297520v3 LSP clocks Stefan Dösinger
2026-08-10  7:10   ` sashiko-bot
2026-08-10 21:59   ` Brian Masney
2026-08-09 21:28 ` [PATCH v10 11/12] reset: zte: Add a zx297520v3 reset driver Stefan Dösinger
2026-08-10  7:15   ` sashiko-bot
2026-08-10  7:03 ` [PATCH v10 12/12] ARM: dts: zte: Declare zx297520v3 CRM device nodes Stefan Dösinger
2026-08-10  7:11   ` 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=20260810071357.9B5A41F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lee@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