Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Miquel Raynal" <miquel.raynal@bootlin.com>
Cc: devicetree@vger.kernel.org, linux-clk@vger.kernel.org,
	conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v5 8/9] clk: nuvoton: ma35d1: get HXT/LXT from DT
Date: Tue, 29 Sep 2026 14:56:17 +0000	[thread overview]
Message-ID: <20260929145618.187A21F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260929-perso-ma35d1-upstream-clk-v5-8-68533e935ee4@bootlin.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] clk: nuvoton: missing IS_ERR check causes permanent probe deferral
- [Medium] clk: nuvoton: hardcoded parent strings cause orphaned gate clocks
--

commit 6ea21fa12153954a64270097e3f0cfbc24e8a162
Author: Miquel Raynal <miquel.raynal@bootlin.com>

clk: nuvoton: ma35d1: get HXT/LXT from DT

This commit updates the driver to get the HXT and LXT crystal oscillator
inputs from the device tree using devm_clk_get_optional(). It points the
internal clock table to the discovered clk_hw instances instead of always
registering fixed rate clocks. It falls back to fixed rate clocks for
older device trees.

> diff --git a/drivers/clk/nuvoton/clk-ma35d1.c b/drivers/clk/nuvoton/clk-ma35d1.c
> index ceebcbd8c18b3..81a412b1706e4 100644
> --- a/drivers/clk/nuvoton/clk-ma35d1.c
> +++ b/drivers/clk/nuvoton/clk-ma35d1.c

[ ... ]

> @@ -240,10 +256,10 @@ static int ma35d1_clocks_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> -	hws[HXT] = ma35d1_clk_fixed("hxt", 24000000);
> +	hws[HXT] = ma35d1_clk_xtal(dev, "hxt", 24000000);

[Severity: High]
Does this code silently ignore probe deferrals?

The ma35d1_clk_xtal() function in drivers/clk/nuvoton/clk-ma35d1.c calls
devm_clk_get_optional(), which can return ERR_PTR(-EPROBE_DEFER) if the
external clock provider hasn't probed yet.

Because ma35d1_clocks_probe() assigns this directly to hws[HXT] without an
IS_ERR() check, the probe function will complete successfully and return 0
instead of deferring.

The error pointer then permanently resides in the provider's onecell data,
and downstream consumers requesting these clocks will face infinite probe
deferrals.

>  	hws[HXT_GATE] = ma35d1_clk_gate(dev, "hxt_gate", "hxt",
>  					clk_base + REG_CLK_PWRCTL, 0);

[Severity: Medium]
Will this hardcoded parent string lead to an orphaned gate clock?

Since the driver dynamically fetches external clocks from the DT in
ma35d1_clocks_probe(), the Common Clock Framework will resolve the string
"hxt" against the provider's global clock name.

If a device tree supplies an external clock with a different global name
such as "clk_hxt", the framework will fail to match it and the gate clock
will be orphaned.

Should this pass the resolved clk_hw_get_name(hws[HXT]) instead of relying
on exact string matches against DT nodes to ensure reliable linkage?

> -	hws[LXT] = ma35d1_clk_fixed("lxt", 32768);
> +	hws[LXT] = ma35d1_clk_xtal(dev, "lxt", 32768);

[Severity: High]
Does this face the same probe deferral regression as HXT?

In ma35d1_clocks_probe(), without an IS_ERR() check, an ERR_PTR from
ma35d1_clk_xtal() allows the function to silently succeed despite missing
dependencies, permanently storing the error pointer in hws[LXT].

>  	hws[LXT_GATE] = ma35d1_clk_gate(dev, "lxt_gate", "lxt",
>  					clk_base + REG_CLK_PWRCTL, 1);

[Severity: Medium]
Can this string cause the same orphan regression as HXT_GATE?

Passing the literal string "lxt" to ma35d1_clk_gate() as the parent name
could fail to match if the external DT clock has a different global name.

>  	hws[HIRC] = ma35d1_clk_fixed("hirc", 12000000);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260929-perso-ma35d1-upstream-clk-v5-0-68533e935ee4@bootlin.com?part=8

  reply	other threads:[~2026-09-29 14:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 14:44 [PATCH v5 0/9] clk: nuvoton: ma35d1: Fix mux parenting and peripheral clock rates Miquel Raynal
2026-09-29 14:44 ` [PATCH v5 1/9] clk: nuvoton: ma35d1: Keep the clock count in the driver Miquel Raynal
2026-09-29 14:44 ` [PATCH v5 2/9] dt-bindings: clock: ma35d1: Document the missing crystal inputs Miquel Raynal
2026-09-30 11:55   ` Krzysztof Kozlowski
2026-09-29 14:44 ` [PATCH v5 3/9] dt-bindings: clock: ma35d1: Drop CLK_MAX_IDX define Miquel Raynal
2026-09-29 14:44 ` [PATCH v5 4/9] dt-bindings: clock: ma35d1: Add missing WDT/WWDT parent clocks Miquel Raynal
2026-09-29 14:44 ` [PATCH v5 5/9] clk: nuvoton: " Miquel Raynal
2026-09-29 14:44 ` [PATCH v5 6/9] clk: nuvoton: ma35d1: Use clk_hw pointers as mux parents Miquel Raynal
2026-09-29 14:44 ` [PATCH v5 7/9] clk: nuvoton: ma35d1: Avoid possible error pointer dereferencing Miquel Raynal
2026-09-29 14:44 ` [PATCH v5 8/9] clk: nuvoton: ma35d1: get HXT/LXT from DT Miquel Raynal
2026-09-29 14:56   ` sashiko-bot [this message]
2026-09-29 20:36     ` Miquel Raynal
2026-09-30  7:39       ` Jerome Brunet
2026-09-30  9:12         ` Miquel Raynal
2026-09-29 14:44 ` [PATCH v5 9/9] arm64: dts: nuvoton: ma35d1: Add LXT crystal and correct HXT name Miquel Raynal
2026-09-29 15:01   ` sashiko-bot
2026-09-29 20:48     ` Miquel Raynal

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=20260929145618.187A21F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=miquel.raynal@bootlin.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