From: Brian Masney <masneyb@kernel.org>
To: Lee Jones <lee@kernel.org>
Cc: Drew Fustini <fustini@kernel.org>,
Joel Stanley <jms@oss.tenstorrent.com>,
Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
linux-riscv@lists.infradead.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 08/10] clk: tenstorrent: Poll atomically in atlantis_clk_pll_enable()
Date: Tue, 24 Nov 2026 13:31:56 -0500 [thread overview]
Message-ID: <awXYHBcmdDQ9OvlD@x1g10> (raw)
In-Reply-To: <20261123164834.3330320-9-lee@kernel.org>
Hi Lee,
On Mon, Nov 23, 2026 at 04:47:41PM +0000, Lee Jones wrote:
> The Common Clock Framework invokes .enable callbacks in atomic context
> with interrupts disabled and enable_lock held. In atlantis_clk_pll_ops,
> atlantis_clk_pll_enable() is registered as the .enable callback yet
> waits for PLL lock using regmap_read_poll_timeout() with a 500 us sleep
> interval, triggering a sleep-in-atomic bug via usleep_range().
>
> Since the PRCM regmap is backed by MMIO, use
> regmap_read_poll_timeout_atomic() instead.
>
> Fixes: 23c8ebc95284 ("clk: tenstorrent: Add Atlantis clock controller driver")
> Closes: https://sashiko.dev/#/bug/linux-980395a6-f282-478a-bf18-b5695a725735
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---
> drivers/clk/tenstorrent/atlantis-prcm.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/clk/tenstorrent/atlantis-prcm.c b/drivers/clk/tenstorrent/atlantis-prcm.c
> index eccc8015da23..d9155f133713 100644
> --- a/drivers/clk/tenstorrent/atlantis-prcm.c
> +++ b/drivers/clk/tenstorrent/atlantis-prcm.c
> @@ -313,10 +313,11 @@ static int atlantis_clk_pll_enable(struct clk_hw *hw)
> PLL_CFG_EN_BIT, PLL_CFG_EN_BIT);
>
> /* Step 3: Wait for PLL lock */
> - ret = regmap_read_poll_timeout(pll->common.regmap,
> - pll->config.reg_offset, val,
> - val & PLL_CFG_LOCK_BIT,
> - PLL_BYPASS_WAIT_US, PLL_LOCK_TIMEOUT_US);
> + ret = regmap_read_poll_timeout_atomic(pll->common.regmap,
> + pll->config.reg_offset, val,
> + val & PLL_CFG_LOCK_BIT,
> + PLL_BYPASS_WAIT_US,
> + PLL_LOCK_TIMEOUT_US);
This should actually be converted to use the enable lock instead of the
prepare lock since this will sleep with interrupts disabled. The _atomic
variant won't be needed there.
Brian
WARNING: multiple messages have this Message-ID (diff)
From: Brian Masney <masneyb@kernel.org>
To: Lee Jones <lee@kernel.org>
Cc: Drew Fustini <fustini@kernel.org>,
Joel Stanley <jms@oss.tenstorrent.com>,
Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
linux-riscv@lists.infradead.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 08/10] clk: tenstorrent: Poll atomically in atlantis_clk_pll_enable()
Date: Tue, 24 Nov 2026 13:31:56 -0500 [thread overview]
Message-ID: <awXYHBcmdDQ9OvlD@x1g10> (raw)
In-Reply-To: <20261123164834.3330320-9-lee@kernel.org>
Hi Lee,
On Mon, Nov 23, 2026 at 04:47:41PM +0000, Lee Jones wrote:
> The Common Clock Framework invokes .enable callbacks in atomic context
> with interrupts disabled and enable_lock held. In atlantis_clk_pll_ops,
> atlantis_clk_pll_enable() is registered as the .enable callback yet
> waits for PLL lock using regmap_read_poll_timeout() with a 500 us sleep
> interval, triggering a sleep-in-atomic bug via usleep_range().
>
> Since the PRCM regmap is backed by MMIO, use
> regmap_read_poll_timeout_atomic() instead.
>
> Fixes: 23c8ebc95284 ("clk: tenstorrent: Add Atlantis clock controller driver")
> Closes: https://sashiko.dev/#/bug/linux-980395a6-f282-478a-bf18-b5695a725735
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---
> drivers/clk/tenstorrent/atlantis-prcm.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/clk/tenstorrent/atlantis-prcm.c b/drivers/clk/tenstorrent/atlantis-prcm.c
> index eccc8015da23..d9155f133713 100644
> --- a/drivers/clk/tenstorrent/atlantis-prcm.c
> +++ b/drivers/clk/tenstorrent/atlantis-prcm.c
> @@ -313,10 +313,11 @@ static int atlantis_clk_pll_enable(struct clk_hw *hw)
> PLL_CFG_EN_BIT, PLL_CFG_EN_BIT);
>
> /* Step 3: Wait for PLL lock */
> - ret = regmap_read_poll_timeout(pll->common.regmap,
> - pll->config.reg_offset, val,
> - val & PLL_CFG_LOCK_BIT,
> - PLL_BYPASS_WAIT_US, PLL_LOCK_TIMEOUT_US);
> + ret = regmap_read_poll_timeout_atomic(pll->common.regmap,
> + pll->config.reg_offset, val,
> + val & PLL_CFG_LOCK_BIT,
> + PLL_BYPASS_WAIT_US,
> + PLL_LOCK_TIMEOUT_US);
This should actually be converted to use the enable lock instead of the
prepare lock since this will sleep with interrupts disabled. The _atomic
variant won't be needed there.
Brian
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-11-24 18:31 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 16:47 [PATCH 00/10] clk: Assorted bug fixes across clock core and drivers Lee Jones
2026-11-23 16:47 ` Lee Jones
2026-11-23 16:47 ` [PATCH 01/10] clk: imx: imx8qxp-lpcg: Prevent stack overflow when parsing clocks Lee Jones
2026-11-23 17:25 ` Frank Li
2026-11-25 0:19 ` Peng Fan
2026-11-23 16:47 ` [PATCH 02/10] clk: lmk04832: Validate child reg index in lmk04832_probe() Lee Jones
2026-11-23 16:47 ` [PATCH 03/10] clk: tegra: bpmp: Bound num_parents by MRQ_CLK_MAX_PARENTS Lee Jones
2026-11-23 16:47 ` [PATCH 04/10] clk: composite: Initialise sub-hw pointers in determine_rate() Lee Jones
2026-11-23 16:47 ` [PATCH 05/10] clk: divider: Avoid division by zero in _div_round_closest() Lee Jones
2026-11-23 17:13 ` sashiko-bot
2026-11-24 17:36 ` Brian Masney
2026-11-26 8:25 ` Lee Jones
2026-11-23 16:47 ` [PATCH 06/10] clk: gpio: Reject gate clocks with multiple parents Lee Jones
2026-11-23 16:47 ` [PATCH 07/10] clk: samsung: exynos5420: Terminate PLL rate tables with sentinels Lee Jones
2026-11-23 17:26 ` Krzysztof Kozlowski
2026-11-24 13:14 ` Lee Jones
2026-11-25 20:59 ` Peter Griffin
2026-11-26 7:09 ` Krzysztof Kozlowski
2026-11-26 7:11 ` Krzysztof Kozlowski
2026-11-23 16:47 ` [PATCH 08/10] clk: tenstorrent: Poll atomically in atlantis_clk_pll_enable() Lee Jones
2026-11-23 16:47 ` Lee Jones
2026-11-23 19:23 ` Anirudh Srinivasan
2026-11-23 19:23 ` Anirudh Srinivasan
2026-11-24 18:31 ` Brian Masney [this message]
2026-11-24 18:31 ` Brian Masney
2026-11-26 8:24 ` Lee Jones
2026-11-26 8:24 ` Lee Jones
2026-11-23 16:47 ` [PATCH 09/10] clk: cdce925: Use devm_of_clk_add_hw_provider() to avoid UAF on unbind Lee Jones
2026-11-23 16:47 ` [PATCH 10/10] clk: mmp: audio: Use devm_of_clk_add_hw_provider() to prevent UAF Lee Jones
2026-11-24 18:59 ` (subset) [PATCH 00/10] clk: Assorted bug fixes across clock core and drivers Brian Masney
2026-11-24 18:59 ` Brian Masney
2026-11-26 7:14 ` Krzysztof Kozlowski
2026-11-26 7:14 ` Krzysztof Kozlowski
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=awXYHBcmdDQ9OvlD@x1g10 \
--to=masneyb@kernel.org \
--cc=asrinivasan@oss.tenstorrent.com \
--cc=bmasney+clk@redhat.com \
--cc=fustini@kernel.org \
--cc=jbrunet+clk@baylibre.com \
--cc=jms@oss.tenstorrent.com \
--cc=lee@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=sboyd@kernel.org \
--cc=stable@vger.kernel.org \
/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.