Re: [PATCH 08/10] clk: tenstorrent: Poll atomically in atlantis_clk_pll_enable()

From: Brian Masney

Date: Tue Nov 24 2026 - 13:32:06 EST


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@xxxxxxxxxxxxxxx
> Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
> ---
> 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