Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yu-Chun Lin" <eleanor.lin@realtek.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v8 04/10] clk: realtek: Add support for phase locked loops (PLLs)
Date: Wed, 10 Jun 2026 08:18:54 +0000	[thread overview]
Message-ID: <20260610081855.044371F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260610080824.255063-5-eleanor.lin@realtek.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] `clk_pll_determine_rate()` ignores consumer constraints (`req->min_rate` and `req->max_rate`), leading to invalid frequency selection and rejected clock rate changes.
- [High] `is_power_on()` incorrectly returns `true` when register reads fail, masking hardware errors and causing silent enablement failures.
- [Low] Unnecessary semicolon at the end of the `ftbl_find_by_val_with_mask` function definition.
--

commit 4d3f4fa427421504b7a5b08f5c9946c2979abab1
Author: Cheng-Yu Lee <cylee12@realtek.com>

clk: realtek: Add support for phase locked loops (PLLs)

Provide a full set of PLL operations for programmable PLLs and a read-only
variant for fixed or hardware-managed PLLs.

> diff --git a/drivers/clk/realtek/clk-pll.c b/drivers/clk/realtek/clk-pll.c
> new file mode 100644
> index 0000000000000..6c4343d71dbe4
> --- /dev/null
> +++ b/drivers/clk/realtek/clk-pll.c

[ ... ]

> +static bool is_power_on(struct clk_pll *clkp)
> +{
> +	u32 val;
> +
> +	/* reg == 0 means not configured (assume always on).
> +	 * Register offset 0 is never a valid address on Realtek SoCs.
> +	 */
> +	if (!clkp->power_reg)
> +		return true;
> +
> +	if (regmap_read(clkp->clkr.regmap, clkp->power_reg, &val))
> +		return true;

[Severity: High]
Will this incorrectly mask hardware errors and cause silent enablement failures?

If regmap_read() fails, the function returns true. This false positive
causes clk_pll_enable() to assume the PLL is already powered on.

This skips the seq_power_on sequence and immediately returns success,
so the clock core framework considers the clock successfully enabled while
the physical hardware remains disabled.

> +
> +	return (val & clkp->power_mask) == clkp->power_val_on;
> +}

[ ... ]

> +static int clk_pll_determine_rate(struct clk_hw *hw,
> +				  struct clk_rate_request *req)
> +{
> +	struct clk_pll *clkp = to_clk_pll(hw);
> +	const struct freq_table *ftblv = NULL;
> +
> +	ftblv = ftbl_find_by_rate(clkp->freq_tbl, req->rate);

[Severity: High]
Does this ignore the req->min_rate and req->max_rate constraints?

The ftbl_find_by_rate() helper solely searches for the largest available
frequency less than or equal to req->rate.

If req->rate was clamped to min_rate by the core framework, the search may
select an entry strictly less than min_rate. The framework will subsequently
reject this out-of-bounds rate, even though a valid higher frequency
within the bounds might exist in the table.

> +	if (!ftblv)
> +		return -EINVAL;
> +
> +	req->rate = ftblv->rate;
> +
> +	return 0;
> +}

[ ... ]

> diff --git a/drivers/clk/realtek/freq_table.c b/drivers/clk/realtek/freq_table.c
> new file mode 100644
> index 0000000000000..0ff1e5e79102b
> --- /dev/null
> +++ b/drivers/clk/realtek/freq_table.c

[ ... ]

> +const struct freq_table *
> +ftbl_find_by_val_with_mask(const struct freq_table *ftbl, u32 mask, u32 value)
> +{
> +	for (; !IS_FREQ_TABLE_END(ftbl); ftbl++) {
> +		if ((ftbl->val & mask) == (value & mask))
> +			return ftbl;
> +	}
> +	return NULL;
> +};

[Severity: Low]
this isn't a bug, but there is an unnecessary semicolon at the end of the
ftbl_find_by_val_with_mask() definition.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260610080824.255063-1-eleanor.lin@realtek.com?part=4

  reply	other threads:[~2026-06-10  8:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-10  8:08 [PATCH v8 00/10] clk: realtek: Add RTD1625 clock support Yu-Chun Lin
2026-06-10  8:08 ` [PATCH v8 01/10] dt-bindings: clock: Add Realtek RTD1625 Clock & Reset Controller Yu-Chun Lin
2026-06-10  8:08 ` [PATCH v8 02/10] reset: Add Realtek basic reset support Yu-Chun Lin
2026-06-10  8:18   ` sashiko-bot
2026-06-10  8:08 ` [PATCH v8 03/10] clk: realtek: Introduce a common probe() Yu-Chun Lin
2026-06-10  8:08 ` [PATCH v8 04/10] clk: realtek: Add support for phase locked loops (PLLs) Yu-Chun Lin
2026-06-10  8:18   ` sashiko-bot [this message]
2026-06-10  8:08 ` [PATCH v8 05/10] clk: realtek: Add support for gate clock Yu-Chun Lin
2026-06-10  8:08 ` [PATCH v8 06/10] clk: realtek: Add support for mux clock Yu-Chun Lin
2026-06-10  8:19   ` sashiko-bot
2026-06-10  8:08 ` [PATCH v8 07/10] clk: realtek: Add support for MMC-tuned PLL clocks Yu-Chun Lin
2026-06-10  8:19   ` sashiko-bot
2026-06-10  8:08 ` [PATCH v8 08/10] clk: realtek: Add RTD1625-CRT clock controller driver Yu-Chun Lin
2026-06-10  8:08 ` [PATCH v8 09/10] clk: realtek: Add RTD1625-ISO " Yu-Chun Lin
2026-06-10  8:08 ` [PATCH v8 10/10] arm64: dts: realtek: Add clock support for RTD1625 Yu-Chun Lin

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=20260610081855.044371F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=eleanor.lin@realtek.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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