From: sashiko-bot@kernel.org
To: "Louis-Alexis Eyraud" <louisalexis.eyraud@collabora.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v4 12/24] clk: mediatek: pll: Add ops for PLLs using set/clr regs
Date: Thu, 30 Jul 2026 10:05:30 +0000 [thread overview]
Message-ID: <20260730100531.401011F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260729-mt8189-clocks-system-base-v4-12-e356b813a64c@collabora.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Critical] Reusing common prepare/unprepare functions for SET/CLR registers incorrectly performs read-modify-write (RMW) operations, failing to toggle the target PLL and potentially disabling unrelated active PLLs.
- [High] `mtk_pll_prepare_setclr` and `unprepare_setclr` improperly call common functions that execute `pwr_addr` register writes, contradicting the hardware design.
- [High] Missing hardware state rollback when `rst_bar` polling fails in `mtk_pll_prepare_setclr()`.
- [High] Early return on `rst_bar` timeout in `mtk_pll_unprepare_setclr()` aborts PLL teardown, leaving the hardware fully powered on.
--
--- Patch [12]: [PATCH v4 12/24] clk: mediatek: pll: Add ops for PLLs using set/clr regs ---
commit 85e380ac652f1fdab76c2fb7262d10466dfdb403
Author: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com>
clk: mediatek: pll: Add ops for PLLs using set/clr regs
MT8189 SoC uses a new combination of status and set/clr registers to
control its PLL power state and perform BAR reset, that are different
than the current default clock prepare/unprepare operations are using.
Add new set of PLL clock operations to support this logic that relies
on the following registers for prepare/unprepare operations:
- en/en_set/en_clr, rather than pwr register, for PLL power
control
- rst_bar/rst_bar_set/rst_bar_clr, rather than default rst_bar
register for BAR reset control
Also, handle rst_bar register setting/clearing with a timeout, to
verify the operation was correctly performed.
> diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c
> --- a/drivers/clk/mediatek/clk-pll.c
> +++ b/drivers/clk/mediatek/clk-pll.c
> @@ -305,6 +307,48 @@ void mtk_pll_unprepare(struct clk_hw *hw)
> }
> EXPORT_SYMBOL_GPL(mtk_pll_unprepare);
>
> +int mtk_pll_prepare_setclr(struct clk_hw *hw)
> +{
> + struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
> + u32 val = 0;
> + int ret;
> +
> + mtk_pll_prepare_common(pll, pll->en_set_addr);
[Severity: High]
The commit message mentions these new PLLs use en/en_set/en_clr rather than
the pwr register for power control. Since mtk_pll_prepare_common() executes
read-modify-write operations on pll->pwr_addr (such as setting CON0_PWR_ON),
does this corrupt other configuration bits at REG_CON0 if pwr_addr points to
the default base offset?
> +
> + if (pll->data->flags & HAVE_RST_BAR) {
> + writel(pll->data->rst_bar_mask, pll->rst_bar_set_addr);
> +
> + ret = readl_poll_timeout(pll->rst_bar_addr, val,
> + (val & pll->data->rst_bar_mask), 1,
> + RST_BAR_TIMEOUT);
> + if (ret)
> + return ret;
[Severity: High]
If the rst_bar readiness polling times out, does this leave the hardware in
an inconsistent state?
Since mtk_pll_prepare_common() was already called to power on the PLL and
enable the tuner, returning the error directly here skips undoing those
steps. The clock core sees the prepare fail and will not invoke the unprepare
callback on error paths, permanently leaking power.
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(mtk_pll_prepare_setclr);
> +
> +void mtk_pll_unprepare_setclr(struct clk_hw *hw)
> +{
> + struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
> + u32 val = 0;
> + int ret;
> +
> + if (pll->data->flags & HAVE_RST_BAR) {
> + writel(pll->data->rst_bar_mask, pll->rst_bar_clr_addr);
> +
> + ret = readl_poll_timeout(pll->rst_bar_addr, val,
> + !(val & pll->data->rst_bar_mask), 1,
> + RST_BAR_TIMEOUT);
> + if (ret)
> + return;
[Severity: High]
If this polling times out, does the early return permanently leak the PLL's
active state?
Skipping the final call to mtk_pll_unprepare_common() leaves the hardware
fully powered on, but the clock core considers the clock disabled since this
function returns void. Hardware teardown paths typically proceed on a best
effort basis rather than bailing out at the first error.
> + }
> +
> + mtk_pll_unprepare_common(pll, pll->en_clr_addr);
[Severity: Critical]
Does passing a clear (W1C) register to mtk_pll_unprepare_common() cause
unintended side effects?
Looking at mtk_pll_unprepare_common(), it performs a read-modify-write:
r = readl(en_addr) & ~BIT(pll->data->pll_en_bit);
writel(r, en_addr);
If en_clr_addr reads back the status of all PLLs, wouldn't masking out the
target bit to 0 and writing the result back write 1s for all other active
PLLs, inadvertently disabling them?
> +}
> +EXPORT_SYMBOL_GPL(mtk_pll_unprepare_setclr);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260729-mt8189-clocks-system-base-v4-0-e356b813a64c@collabora.com?part=12
next prev parent reply other threads:[~2026-07-30 10:05 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 10:02 [PATCH v4 00/24] MT8189: Add support for system and base clock controllers Louis-Alexis Eyraud
2026-07-29 10:02 ` [PATCH v4 01/24] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8186 Louis-Alexis Eyraud
2026-07-30 10:05 ` sashiko-bot
2026-07-29 10:02 ` [PATCH v4 02/24] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8192 Louis-Alexis Eyraud
2026-07-29 10:02 ` [PATCH v4 03/24] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8195 Louis-Alexis Eyraud
2026-07-29 10:02 ` [PATCH v4 04/24] dt-bindings: clock: mediatek: reorder MT8186 compatibles Louis-Alexis Eyraud
2026-07-29 10:02 ` [PATCH v4 05/24] dt-bindings: clock: mediatek: regroup MT8188 dt-bindings into MT8186 Louis-Alexis Eyraud
2026-07-30 10:05 ` sashiko-bot
2026-07-29 10:02 ` [PATCH v4 06/24] dt-bindings: clock: mediatek: regroup MT8192 " Louis-Alexis Eyraud
2026-07-30 10:05 ` sashiko-bot
2026-07-29 10:02 ` [PATCH v4 07/24] dt-bindings: clock: mediatek: regroup MT8195 " Louis-Alexis Eyraud
2026-07-29 10:02 ` [PATCH v4 08/24] dt-bindings: clock: mediatek: Add MT8189 system/base clocks and resets Louis-Alexis Eyraud
2026-07-29 10:02 ` [PATCH v4 09/24] clk: mediatek: Harmonize mtk_pll_fenc related symbol names Louis-Alexis Eyraud
2026-07-29 10:02 ` [PATCH v4 10/24] clk: mediatek: pll: Add BAR reset register offsets Louis-Alexis Eyraud
2026-07-30 10:05 ` sashiko-bot
2026-07-29 10:02 ` [PATCH v4 11/24] clk: mediatek: pll: split default prepare/unprepare callbacks Louis-Alexis Eyraud
2026-07-29 10:02 ` [PATCH v4 12/24] clk: mediatek: pll: Add ops for PLLs using set/clr regs Louis-Alexis Eyraud
2026-07-30 10:05 ` sashiko-bot [this message]
2026-07-29 10:02 ` [PATCH v4 13/24] clk: mediatek: pllfh: Add configurable clock ops to mtk_pllfh_data Louis-Alexis Eyraud
2026-07-30 10:05 ` sashiko-bot
2026-07-29 10:02 ` [PATCH v4 14/24] clk: mediatek: pllfh: Add ops for PLLs using set/clr regs Louis-Alexis Eyraud
2026-07-30 10:05 ` sashiko-bot
2026-07-29 10:02 ` [PATCH v4 15/24] clk: mediatek: Add MT8189 apmixedsys clock support Louis-Alexis Eyraud
2026-07-30 10:05 ` sashiko-bot
2026-07-29 10:03 ` [PATCH v4 16/24] clk: mediatek: Add MT8189 topckgen " Louis-Alexis Eyraud
2026-07-30 10:05 ` sashiko-bot
2026-07-29 10:03 ` [PATCH v4 17/24] clk: mediatek: Add MT8189 vlpckgen " Louis-Alexis Eyraud
2026-07-29 10:03 ` [PATCH v4 18/24] clk: mediatek: Add MT8189 vlpcfg " Louis-Alexis Eyraud
2026-07-29 10:03 ` [PATCH v4 19/24] clk: mediatek: Add MT8189 bus " Louis-Alexis Eyraud
2026-07-29 10:03 ` [PATCH v4 20/24] clk: mediatek: Add MT8189 dbgao " Louis-Alexis Eyraud
2026-07-29 10:03 ` [PATCH v4 21/24] clk: mediatek: Add MT8189 dvfsrc " Louis-Alexis Eyraud
2026-07-29 10:03 ` [PATCH v4 22/24] clk: mediatek: Add MT8189 i2c " Louis-Alexis Eyraud
2026-07-29 10:03 ` [PATCH v4 23/24] clk: mediatek: Add MT8189 scp " Louis-Alexis Eyraud
2026-07-29 10:03 ` [PATCH v4 24/24] clk: mediatek: Add MT8189 ufs " Louis-Alexis Eyraud
2026-07-30 10:05 ` 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=20260730100531.401011F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=louisalexis.eyraud@collabora.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 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.