Linux clock framework development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Joseph Telaak" <joseph@telaak.dev>
Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v5 3/6] clk: siflower: Add SF19A2890 clock manager driver
Date: Tue, 24 Nov 2026 04:58:02 +0000	[thread overview]
Message-ID: <sashiko-outbox-230534@kernel.org> (raw)
In-Reply-To: <20261123-sf19a2890-sysm-v5-3-4ba44a0db17d@telaak.dev>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] clk: siflower: broken late clock publication and defaults in
  sf19a2890
--

commit 99941c15178fb0fa3ccc19a6c27f477a30815152
Author: Joseph Telaak <joseph@telaak.dev>

clk: siflower: Add SF19A2890 clock manager driver

This commit adds a clock driver for the Siflower SF19A2890 SoC, registering
the CPU clock and its parent PLLs early via CLK_OF_DECLARE_DRIVER and the
remaining mux/divider clocks from a platform driver.

Link: https://github.com/981213/linux/commit/0466d6303c25

> diff --git a/drivers/clk/siflower/clk-sf19a2890.c b/drivers/clk/siflower/clk-sf19a2890.c
> new file mode 100644
> index 0000000000000..3ccb768331ad3
> --- /dev/null
> +++ b/drivers/clk/siflower/clk-sf19a2890.c

[ ... ]

> +static void __init sf19a2890_clk_early_init(struct device_node *node)
> +{
> +	struct clk_hw_onecell_data *data;
> +	void __iomem *base;
> +	unsigned int i;
> +	int ret;
> +
> +	data = kzalloc_flex(*data, hws, CLK_SF19A2890_NR_CLKS);
> +	if (!data)
> +		return;
> +
> +	data->num = CLK_SF19A2890_NR_CLKS;
> +	/* The clocks registered at probe defer until then */
> +	for (i = 0; i < data->num; i++)
> +		data->hws[i] = ERR_PTR(-EPROBE_DEFER);
> +
> +	base = of_iomap(node, 0);
> +	if (!base) {
> +		pr_err("failed to map the registers\n");
> +		goto err_free;
> +	}
> +
> +	for (i = 0; i < ARRAY_SIZE(sf19a2890_early_clks); i++) {
> +		unsigned int id = sf19a2890_early_clks[i];
> +		struct clk_hw *hw = sf19a2890_hws[id];
> +
> +		hw_to_sf_clk_common(hw)->base = base;
> +		ret = of_clk_hw_register(node, hw);
> +		if (ret) {
> +			pr_err("failed to register clock %u: %d\n", id, ret);
> +			goto err_unregister;
> +		}
> +		data->hws[id] = hw;
> +	}
> +
> +	ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, data);
> +	if (ret) {
> +		pr_err("failed to add the clock provider: %d\n", ret);
> +		goto err_unregister;
> +	}
> +
> +	sf19a2890_clk_data = data;
> +	sf19a2890_clk_base = base;
> +	return;
> +
> +err_unregister:
> +	while (i--)
> +		clk_hw_unregister(data->hws[sf19a2890_early_clks[i]]);
> +	iounmap(base);
> +err_free:
> +	kfree(data);
> +}
> +
> +CLK_OF_DECLARE_DRIVER(sf19a2890_clk, "siflower,sf19a2890-clk", sf19a2890_clk_early_init);
> +
> +static void sf19a2890_clk_unpublish(void *data)
> +{
> +	struct clk_hw **hw = data;
> +
> +	*hw = ERR_PTR(-EPROBE_DEFER);
> +}
> +
> +static int sf19a2890_clk_probe(struct platform_device *pdev)
> +{
> +	struct clk_hw_onecell_data *data = sf19a2890_clk_data;
> +	struct device *dev = &pdev->dev;
> +	unsigned int i;
> +	int ret;
> +
> +	if (!data)
> +		return -ENODEV;
> +
> +	for (i = 0; i < data->num; i++) {
> +		struct clk_hw *hw = sf19a2890_hws[i];
> +
> +		/* Registered early */
> +		if (!IS_ERR(data->hws[i]))
> +			continue;
> +
> +		hw_to_sf_clk_common(hw)->base = sf19a2890_clk_base;
> +		ret = devm_clk_hw_register(dev, hw);
> +		if (ret)
> +			return dev_err_probe(dev, ret, "failed to register clock %u\n", i);
> +
> +		data->hws[i] = hw;

[Severity: Medium]
As reported by Brian Masney on v4 [1], can setting data->hws[i] = hw after
devm_clk_hw_register() and registering the OF provider while late clocks
are still ERR_PTR(-EPROBE_DEFER) break orphan reparenting and
assigned-clocks defaults?

devm_clk_hw_register() runs clk_core_reparent_orphans_nolock() before
returning.  Because data->hws[i] is still ERR_PTR(-EPROBE_DEFER) during
that call, any already-registered orphan clock parented by the last clock
(CLK_MUXDIV_NPU_PE) cannot resolve its parent via the OF provider and
remains orphaned.

In addition, of_clk_add_hw_provider() in sf19a2890_clk_early_init() calls
of_clk_set_defaults(node, true) while the 17 late clocks are still
ERR_PTR(-EPROBE_DEFER).  If the clock controller DT node specifies
assigned-clocks for any late clock, of_clk_add_hw_provider() fails with
-EPROBE_DEFER and tears down all early clocks including the CPU clock;
even when early init succeeds, sf19a2890_clk_probe() never re-runs
of_clk_set_defaults() after registering the late clocks.

[1] https://lore.kernel.org/r/179545199778.209212.13754058672210050271.b4-review@b4

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-sf19a2890-sysm-v5-0-4ba44a0db17d@telaak.dev?part=3

  reply	other threads:[~2026-11-24  4:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  4:41 [PATCH v5 0/6] clk: Add the Siflower SF19A2890 clock manager and peripheral clock and reset managers Joseph Telaak via B4 Relay
2026-11-24  4:41 ` [PATCH v5 1/6] MIPS: Add support for Siflower MIPS SoCs Joseph Telaak via B4 Relay
2026-11-24  4:41 ` [PATCH v5 2/6] dt-bindings: clock: Add Siflower SF19A2890 clock manager Joseph Telaak via B4 Relay
2026-11-24  4:41 ` [PATCH v5 3/6] clk: siflower: Add SF19A2890 clock manager driver Joseph Telaak via B4 Relay
2026-11-24  4:58   ` sashiko-bot [this message]
2026-11-24  4:41 ` [PATCH v5 4/6] dt-bindings: clock: Add Siflower SF19A2890 peripheral clock/reset managers Joseph Telaak via B4 Relay
2026-11-24  4:41 ` [PATCH v5 5/6] clk: siflower: Add SF19A2890 peripheral clock driver Joseph Telaak via B4 Relay
2026-11-24  4:41 ` [PATCH v5 6/6] reset: Add Siflower SF19A2890 peripheral reset driver Joseph Telaak via B4 Relay
2026-11-24  4:52   ` 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=sashiko-outbox-230534@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=joseph@telaak.dev \
    --cc=linux-clk@vger.kernel.org \
    --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