From: sashiko-bot@kernel.org
To: "Yu-Chun Lin" <eleanor.lin@realtek.com>
Cc: conor+dt@kernel.org, krzk+dt@kernel.org,
devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v7 04/10] clk: realtek: Add support for phase locked loops (PLLs)
Date: Fri, 08 May 2026 21:41:50 +0000 [thread overview]
Message-ID: <20260508214150.A6064C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260508111641.3192177-5-eleanor.lin@realtek.com>
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [Critical] Missing spinlock release and IRQ restore in `clk_pll_recalc_rate()` error path.
- [High] Severe scheduling latency due to up to 2ms delay in atomic context with interrupts disabled.
- [High] `is_power_on()` masks hardware read errors, leading to silent hardware failures.
- [High] Valid register offset `0x0` is treated as 'no register' in `is_power_on()`.
- [Medium] `clk_pll_determine_rate()` fails to enforce frequency bounds.
--
commit df23b935aa675a5465a9a387a1eecbe47915033e
Author: Cheng-Yu Lee <cylee12@realtek.com>
clk: realtek: Add support for phase locked loops (PLLs)
This commit introduces support for realtek programmable and fixed or
hardware-managed PLLs. It provides 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..b63f3aa92d3f4
> --- /dev/null
> +++ b/drivers/clk/realtek/clk-pll.c
[ ... ]
> +static int wait_freq_ready(struct clk_pll *clkp)
> +{
> + u32 pollval;
> +
> + if (!clkp->freq_ready_valid)
> + return 0;
> +
> + return regmap_read_poll_timeout_atomic(clkp->clkr.regmap, clkp->freq_ready_reg, pollval,
> + (pollval & clkp->freq_ready_mask) == clkp->freq_ready_val, 1, TIMEOUT);
> +}
Is a 2000 microsecond (2ms) timeout safe in an atomic context? wait_freq_ready()
is called from clk_pll_enable() and clk_pll_set_rate(), both of which hold
clkp->lock and disable interrupts via spin_lock_irqsave(). Spinning for 2ms
with local interrupts disabled could degrade system responsiveness and trigger
NMI watchdogs.
Should multi-millisecond hardware waits be moved to sleepable callbacks (like
.prepare() instead of .enable()) using mutexes?
> +static bool is_power_on(struct clk_pll *clkp)
> +{
> + u32 val;
> +
> + if (!clkp->power_reg)
> + return true;
Does this check inadvertently treat the valid register offset 0x0 as 'no
register'?
In regmap-based MMIO devices, offset 0x0 is a common and valid register address.
If a PLL maps its power register to offset 0, will the driver skip reading it
and incorrectly assume the clock is powered on?
> +
> + if (regmap_read(clkp->clkr.regmap, clkp->power_reg, &val))
> + return true;
Does returning true on a regmap_read() error mask hardware read failures?
If this fails, clk_pll_enable() will interpret the clock as already powered
on, skip the seq_power_on sequence, and return success while the hardware
remains unpowered. Could this lead to silent failures and crashes when
dependent drivers access unclocked registers?
> +
> + 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);
> + if (!ftblv)
> + return -EINVAL;
> +
> + req->rate = ftblv->rate;
Does this callback need to enforce frequency bounds?
The determine_rate callback is generally expected to select a valid frequency
that satisfies req->min_rate <= rate <= req->max_rate. It looks like the closest
rate is assigned without checking if it falls within the requested bounds.
> +
> + return 0;
> +}
> +
> +static unsigned long clk_pll_recalc_rate(struct clk_hw *hw,
> + unsigned long parent_rate)
> +{
> + struct clk_pll *clkp = to_clk_pll(hw);
> + const struct freq_table *fv;
> + unsigned long flags;
> + u32 freq_val;
> +
> + spin_lock_irqsave(&clkp->lock, flags);
> +
> + if (regmap_read(clkp->clkr.regmap, clkp->freq_reg, &freq_val))
> + return 0;
Is there a missing spin_unlock_irqrestore() in this error path?
If regmap_read() fails, the function returns immediately, leaving the spinlock
acquired and interrupts disabled. Any future attempt to acquire this lock would
deadlock.
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260508111641.3192177-1-eleanor.lin@realtek.com?part=4
next prev parent reply other threads:[~2026-05-08 21:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 11:16 [PATCH v7 00/10] clk: realtek: Add RTD1625 clock support Yu-Chun Lin
2026-05-08 11:16 ` [PATCH v7 01/10] dt-bindings: clock: Add Realtek RTD1625 Clock & Reset Controller Yu-Chun Lin
2026-05-08 11:16 ` [PATCH v7 02/10] reset: Add Realtek basic reset support Yu-Chun Lin
2026-05-08 11:16 ` [PATCH v7 03/10] clk: realtek: Introduce a common probe() Yu-Chun Lin
2026-05-08 21:24 ` sashiko-bot
2026-05-08 11:16 ` [PATCH v7 04/10] clk: realtek: Add support for phase locked loops (PLLs) Yu-Chun Lin
2026-05-08 21:41 ` sashiko-bot [this message]
2026-05-08 11:16 ` [PATCH v7 05/10] clk: realtek: Add support for gate clock Yu-Chun Lin
2026-05-08 11:16 ` [PATCH v7 06/10] clk: realtek: Add support for mux clock Yu-Chun Lin
2026-05-08 22:21 ` sashiko-bot
2026-05-08 11:16 ` [PATCH v7 07/10] clk: realtek: Add support for MMC-tuned PLL clocks Yu-Chun Lin
2026-05-08 22:42 ` sashiko-bot
2026-05-08 11:16 ` [PATCH v7 08/10] clk: realtek: Add RTD1625-CRT clock controller driver Yu-Chun Lin
2026-05-08 23:17 ` sashiko-bot
2026-05-08 11:16 ` [PATCH v7 09/10] clk: realtek: Add RTD1625-ISO " Yu-Chun Lin
2026-05-08 23:50 ` sashiko-bot
2026-05-08 11:16 ` [PATCH v7 10/10] arm64: dts: realtek: Add clock support for RTD1625 Yu-Chun Lin
2026-05-08 23:55 ` sashiko-bot
2026-06-05 10:33 ` [PATCH v7 00/10] clk: realtek: Add RTD1625 clock support 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=20260508214150.A6064C2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=eleanor.lin@realtek.com \
--cc=krzk+dt@kernel.org \
--cc=robh@kernel.org \
--cc=sashiko@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 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.