All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Adrian Ng Ho Yin" <adrian.ho.yin.ng@altera.com>,
	linux-clk@vger.kernel.org
Subject: Re: [PATCH v3 3/3] clk: socfpga: stratix10: register the SP timer clocks early
Date: Tue, 13 Oct 2026 07:19:30 +0000	[thread overview]
Message-ID: <sashiko-outbox-169178@kernel.org> (raw)
In-Reply-To: <7de51d5f9c716c03fabab77d1a2b4dba3af745fd.1791871090.git.adrian.ho.yin.ng@altera.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] clk: socfpga: data race in early provider hws array modification
--

commit dfd4eb57c5dabe82235a8f50e5c912f34f5c229f
Author: Adrian Ng Ho Yin <adrian.ho.yin.ng@altera.com>

clk: socfpga: stratix10: register the SP timer clocks early

This commit changes the Stratix10 clock manager to register the l4_sp_clk
and its parents early via CLK_OF_DECLARE_DRIVER(). The remaining clocks
are deferred and registered later when the platform driver probes. The clock
manager structure, including the hardware clock array, is reused between
the early and late init phases.

> diff --git a/drivers/clk/socfpga/clk-s10.c b/drivers/clk/socfpga/clk-s10.c
> --- a/drivers/clk/socfpga/clk-s10.c
> +++ b/drivers/clk/socfpga/clk-s10.c

[ ... ]

> +static int s10_clkmgr_init(struct platform_device *pdev)
> +{
> +	struct stratix10_clock_data *clk_data;
> +	int i, ret;
> +
> +	if (!s10_clk_data) {
> +		ret = s10_clkmgr_setup(pdev->dev.of_node);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	clk_data = s10_clk_data;
>  
> +	s10_clk_register_c_perip(s10_main_perip_c_clks,
> +				 ARRAY_SIZE(s10_main_perip_c_clks), clk_data);

[Severity: Medium]
Does this introduce a data race with concurrent clock consumers?

Because s10_clkmgr_early_init() previously exposed the clock provider array
by calling of_clk_add_hw_provider(), the array can now be read locklessly
by other threads via of_clk_hw_onecell_get() while consumer drivers probe.

When s10_clk_register_c_perip() runs here, it writes newly registered clock
pointers directly into the array:

s10_clk_register_c_perip()
    data->clk_data.hws[clks[i].id] = hw_clk;

Modifying this array using standard C assignments without annotations like
WRITE_ONCE() or a lock while it is exposed to readers constitutes an
unannotated data race under the Linux Kernel Memory Model. This could 
potentially lead to compiler tearing or KCSAN splats.

[ ... ]

> +	for (i = 0; i < STRATIX10_NUM_CLKS; i++)
> +		if (clk_data->clk_data.hws[i] == ERR_PTR(-EPROBE_DEFER))
> +			clk_data->clk_data.hws[i] = ERR_PTR(-ENOENT);

[Severity: Medium]
Could modifying these deferral pointers concurrently cause issues for readers?

The same exposed clk_data->clk_data.hws array is modified directly without
WRITE_ONCE(). A concurrent reader accessing the array via
of_clk_hw_onecell_get() could observe partial updates or inconsistent states.

> +
> +	return s10_clkmgr_add_provider(pdev->dev.of_node);
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791871090.git.adrian.ho.yin.ng@altera.com?part=3

      reply	other threads:[~2026-10-13  7:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13  7:07 [PATCH v3 0/3] clk: socfpga: register the SP timer clocks early Adrian Ng Ho Yin
2026-10-13  7:07 ` [PATCH v3 1/3] clk: socfpga: agilex: " Adrian Ng Ho Yin
2026-10-13  7:18   ` sashiko-bot
2026-10-13  7:07 ` [PATCH v3 2/3] clk: socfpga: agilex5: " Adrian Ng Ho Yin
2026-10-13  7:19   ` sashiko-bot
2026-10-13  7:07 ` [PATCH v3 3/3] clk: socfpga: stratix10: " Adrian Ng Ho Yin
2026-10-13  7:19   ` sashiko-bot [this message]

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-169178@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=adrian.ho.yin.ng@altera.com \
    --cc=linux-clk@vger.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.