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

Anirudh Srinivasan asrinivasan at oss.tenstorrent.com
Mon Nov 23 11:23:16 PST 2026


Hi Lee,

On Mon, Nov 23, 2026 at 10:49 AM Lee Jones <lee at kernel.org> 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 at vger.kernel.org
> Signed-off-by: Lee Jones <lee at kernel.org>
> ---
>  drivers/clk/tenstorrent/atlantis-prcm.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)

Thanks, I was able to reproduce the bug on the tt-atlantis qemu
machine by using a kernel built with CONFIG_DEBUG_ATOMIC_SLEEP=y,
CONFIG_DEBUG_PREEMPT=y,  CONFIG_PROVE_LOCKING=y.

[    1.895417] BUG: sleeping function called from invalid context at
drivers/clk/tenstorrent/atlantis-prcm.c:329
[    1.896093] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid:
1, name: swapper/0
[    1.896616] preempt_count: 1, expected: 0
[    1.896990] 3 locks held by swapper/0/1:
[    1.897251]  #0: ff600001808a7938 (&dev->mutex){....}-{4:4}, at:
__driver_attach+0x68/0x11e
[    1.898561]  #1: ffffffff81d70bb8 (prepare_lock){+.+.}-{4:4}, at:
clk_prepare_lock+0x1c/0x80
[    1.899134]  #2: ffffffff81d70b30 (enable_lock){....}-{3:3}, at:
clk_enable_lock+0xb0/0xd8
[    1.899750] irq event stamp: 25978
[    1.899968] hardirqs last  enabled at (25977): [<ffffffff80d12254>]
_raw_spin_unlock_irqrestore+0x4e/0x70
[    1.900552] hardirqs last disabled at (25978): [<ffffffff80767d00>]
clk_enable_lock+0xa0/0xd8
[    1.901195] softirqs last  enabled at (25724): [<ffffffff80053e72>]
handle_softirqs+0x54e/0x590
[    1.901798] softirqs last disabled at (25717): [<ffffffff80054132>]
__irq_exit_rcu+0x1f0/0x25c
[    1.902422] Preemption disabled at:
[    1.902447] [<ffffffff80767d10>] clk_enable_lock+0xb0/0xd8
[    1.903375] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted
7.2.0-00071-g9a0518d4d70d #3 PREEMPTLAZY
[    1.903558] Hardware name: Tenstorrent Atlantis RISC-V Machine (DT)
[    1.903643] Call Trace:
[    1.903687] [<ffffffff8001927a>] dump_backtrace+0x1c/0x24
[    1.903718] [<ffffffff800024ba>] show_stack+0x28/0x34
[    1.903734] [<ffffffff80011262>] dump_stack_lvl+0x60/0x88
[    1.903750] [<ffffffff8001129e>] dump_stack+0x14/0x1c
[    1.903766] [<ffffffff80084b76>] __might_resched+0x23a/0x26c
[    1.903786] [<ffffffff80084be6>] __might_sleep+0x3e/0x62
[    1.903801] [<ffffffff8077fb02>] atlantis_clk_pll_enable+0xd0/0x1aa
[    1.903818] [<ffffffff8076d10a>] clk_core_enable+0x92/0x2fe
[    1.903835] [<ffffffff8076e130>] __clk_register+0x5c4/0x874
[    1.903851] [<ffffffff8076e558>] devm_clk_hw_register+0x44/0x96
[    1.903867] [<ffffffff8077f812>] atlantis_prcm_probe+0xbe/0x18c
[    1.903883] [<ffffffff80806eda>] platform_probe+0x46/0x78
[    1.903899] [<ffffffff80804946>] really_probe+0x86/0x234
[    1.903914] [<ffffffff80804b58>] __driver_probe_device+0x64/0x104
[    1.903930] [<ffffffff80804cba>] driver_probe_device+0x2c/0x98
[    1.903946] [<ffffffff80804e22>] __driver_attach+0x70/0x11e
[    1.903961] [<ffffffff80802908>] bus_for_each_dev+0x60/0xae
[    1.903976] [<ffffffff80804488>] driver_attach+0x1a/0x22
[    1.903991] [<ffffffff80803c36>] bus_add_driver+0xce/0x1d6
[    1.904006] [<ffffffff80805a5a>] driver_register+0x3e/0xd8
[    1.904022] [<ffffffff80806c0c>] __platform_driver_register+0x1e/0x26
[    1.904038] [<ffffffff80e31bc8>] atlantis_prcm_driver_init+0x22/0x2a
[    1.904057] [<ffffffff8001296e>] do_one_initcall+0x76/0x39a
[    1.904073] [<ffffffff80e01416>] kernel_init_freeable+0x2b4/0x33e
[    1.904088] [<ffffffff80d065d4>] kernel_init+0x1e/0x13a
[    1.904103] [<ffffffff8001440e>] ret_from_fork_kernel+0x20/0x3b0
[    1.904119] [<ffffffff80d13c22>] ret_from_fork_kernel_asm+0x16/0x18

This patch fixes the issue.

Reviewed-by: Anirudh Srinivasan <asrinivasan at oss.tenstorrent.com>

Regards
Anirudh Srinivasan



More information about the linux-riscv mailing list