All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yu-Chun Lin" <eleanor.lin@realtek.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v8 07/10] clk: realtek: Add support for MMC-tuned PLL clocks
Date: Wed, 10 Jun 2026 08:19:06 +0000	[thread overview]
Message-ID: <20260610081906.9FC081F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260610080824.255063-8-eleanor.lin@realtek.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] `clk_pll_mmc_set_rate` entirely ignores dynamic rate parameters and hardcodes the PLL frequency.
- [Medium] `clk_pll_mmc_determine_rate` lacks bounds clamping and allows out-of-bounds rates that map to unsupported hardware configurations.
- [Low] The tristate `RTK_CLK_PLL_MMC` config causes `clk-pll-mmc.o` to be silently dropped from the build when `CONFIG_RTK_CLK_COMMON=y` and `CONFIG_RTK_CLK_PLL_MMC=m`.
--

commit 021382a87679f7b201df250be3c9547b24d2131a
Author: Cheng-Yu Lee <cylee12@realtek.com>

clk: realtek: Add support for MMC-tuned PLL clocks

This commit adds clk_pll_mmc_ops for enable/disable, prepare, rate control,
and status operations on MMC PLL clocks. It also adds clk_pll_mmc_phase_ops
to support phase get/set operations.

> diff --git a/drivers/clk/realtek/Kconfig b/drivers/clk/realtek/Kconfig
> --- a/drivers/clk/realtek/Kconfig
> +++ b/drivers/clk/realtek/Kconfig
[ ... ]
> @@ -27,4 +27,7 @@ config RTK_CLK_COMMON
>  	  multiple Realtek clock implementations, and include integration
>  	  with reset controllers where required.
>  
> +config RTK_CLK_PLL_MMC
> +	tristate
> +
>  endif

[ ... ]

> diff --git a/drivers/clk/realtek/Makefile b/drivers/clk/realtek/Makefile
> --- a/drivers/clk/realtek/Makefile
> +++ b/drivers/clk/realtek/Makefile
[ ... ]
> @@ -7,3 +7,5 @@ clk-rtk-y += clk-pll.o
>  clk-rtk-y += clk-regmap-gate.o
>  clk-rtk-y += clk-regmap-mux.o
>  clk-rtk-y += freq_table.o
> +
> +clk-rtk-$(CONFIG_RTK_CLK_PLL_MMC) += clk-pll-mmc.o

[Severity: Low]
When CONFIG_RTK_CLK_COMMON is set to 'y' and CONFIG_RTK_CLK_PLL_MMC is set to
'm', does Kbuild drop clk-pll-mmc.o from the build entirely?

Since clk-rtk is a built-in object (obj-y) when CONFIG_RTK_CLK_COMMON=y,
conditionally appending to it via clk-rtk-m += clk-pll-mmc.o will cause
Kbuild to ignore the module object. This can lead to undefined reference
build errors when attempting to link against rtk_clk_pll_mmc_ops.

[ ... ]

> diff --git a/drivers/clk/realtek/clk-pll-mmc.c b/drivers/clk/realtek/clk-pll-mmc.c
> new file mode 100644
> --- /dev/null
> +++ b/drivers/clk/realtek/clk-pll-mmc.c
[ ... ]
> +static int clk_pll_mmc_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
> +{
> +	u32 val;
> +
> +	if (!req->best_parent_rate)
> +		return -EINVAL;
> +
> +	val = DIV_ROUND_CLOSEST(req->rate * 4, req->best_parent_rate);
> +	req->rate = req->best_parent_rate * val / 4;
> +
> +	return 0;
> +}

[Severity: Medium]
Is there a risk of integer overflow here on 32-bit platforms if req->rate
exceeds ~1.07 GHz? The calculation req->rate * 4 operates on an unsigned long.

Also, does val need to be bounds-checked against the hardware's supported
tuning limits? If an extreme rate is requested, the framework might approve it
but it could map to unsupported hardware configurations later on, since val
is never clamped here.

[ ... ]

> +static int clk_pll_mmc_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate)
> +{
> +	struct clk_pll_mmc *clkm = to_clk_pll_mmc(hw);
> +	u32 val = PLL_MMC_SSC_DIV_N_VAL;
> +	int ret;

[Severity: High]
Does this function intentionally ignore the rate and parent_rate parameters?

Because val is initialized to a hardcoded constant (PLL_MMC_SSC_DIV_N_VAL,
which is 27), the hardware is strictly locked to a single static configuration
and the dynamic rate arguments are bypassed.

Additionally, this hardcoded value causes the subsequent switch statement
to unconditionally take the `case 20 ... 30:` branch, making the rest of
the frequency ranges dead code.

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

  reply	other threads:[~2026-06-10  8:19 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
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 [this message]
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=20260610081906.9FC081F00893@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 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.