Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH v2] clk: tenstorrent: Use prepare/unprepare ops for Atlantis PLL
@ 2026-11-27 13:29 Lee Jones
  2026-11-28 18:28 ` Anirudh Srinivasan
  2026-11-29  5:52 ` Drew Fustini
  0 siblings, 2 replies; 3+ messages in thread
From: Lee Jones @ 2026-11-27 13:29 UTC (permalink / raw)
  To: lee, Drew Fustini, Joel Stanley, Anirudh Srinivasan, Stephen Boyd,
	Brian Masney, Jerome Brunet, linux-riscv, linux-clk, linux-kernel
  Cc: stable

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().

Convert atlantis_clk_pll_ops to use .prepare, .unprepare, and
.is_prepared instead of .enable, .disable, and .is_enabled so that the
PLL lock wait executes under the sleeping prepare_lock rather than
atomic enable_lock.

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>
---
v1 => v2:
 - Switch from .enable/.disable/.is_enabled to .prepare/.unprepare/.is_prepared so PLL lock polling runs under the sleeping prepare_lock instead of enable_lock, per Brian Masney's review.
 - Keep regmap_read_poll_timeout() rather than switching to the atomic variant.
 - Drop Anirudh Srinivasan's v1 Reviewed-by tag due to the implementation change.
 - Drop the other patches from v1 that were already applied or superseded.

 drivers/clk/tenstorrent/atlantis-prcm.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/tenstorrent/atlantis-prcm.c b/drivers/clk/tenstorrent/atlantis-prcm.c
index eccc8015da23..ee7044e3f1df 100644
--- a/drivers/clk/tenstorrent/atlantis-prcm.c
+++ b/drivers/clk/tenstorrent/atlantis-prcm.c
@@ -269,7 +269,7 @@ static const struct clk_ops atlantis_clk_fixed_factor_ops = {
 	.recalc_rate = atlantis_clk_fixed_factor_recalc_rate,
 };
 
-static int atlantis_clk_pll_is_enabled(struct clk_hw *hw)
+static int atlantis_clk_pll_is_prepared(struct clk_hw *hw)
 {
 	struct atlantis_clk_pll *pll = hw_to_atlantis_pll(hw);
 	u32 val, en_val, cg_val;
@@ -284,7 +284,7 @@ static int atlantis_clk_pll_is_enabled(struct clk_hw *hw)
 	       !(val & PLL_CFG_BYPASS_BIT);
 }
 
-static int atlantis_clk_pll_enable(struct clk_hw *hw)
+static int atlantis_clk_pll_prepare(struct clk_hw *hw)
 {
 	struct atlantis_clk_pll *pll = hw_to_atlantis_pll(hw);
 	u32 val, en_val, cg_val;
@@ -332,7 +332,7 @@ static int atlantis_clk_pll_enable(struct clk_hw *hw)
 				  pll->config.cg_reg_enable);
 }
 
-static void atlantis_clk_pll_disable(struct clk_hw *hw)
+static void atlantis_clk_pll_unprepare(struct clk_hw *hw)
 {
 	struct atlantis_clk_pll *pll = hw_to_atlantis_pll(hw);
 
@@ -378,10 +378,10 @@ static unsigned long atlantis_clk_pll_recalc_rate(struct clk_hw *hw,
 }
 
 static const struct clk_ops atlantis_clk_pll_ops = {
-	.enable = atlantis_clk_pll_enable,
-	.disable = atlantis_clk_pll_disable,
+	.prepare = atlantis_clk_pll_prepare,
+	.unprepare = atlantis_clk_pll_unprepare,
 	.recalc_rate = atlantis_clk_pll_recalc_rate,
-	.is_enabled = atlantis_clk_pll_is_enabled,
+	.is_prepared = atlantis_clk_pll_is_prepared,
 };
 
 static int atlantis_clk_gate_shared_enable(struct clk_hw *hw)
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] clk: tenstorrent: Use prepare/unprepare ops for Atlantis PLL
  2026-11-27 13:29 [PATCH v2] clk: tenstorrent: Use prepare/unprepare ops for Atlantis PLL Lee Jones
@ 2026-11-28 18:28 ` Anirudh Srinivasan
  2026-11-29  5:52 ` Drew Fustini
  1 sibling, 0 replies; 3+ messages in thread
From: Anirudh Srinivasan @ 2026-11-28 18:28 UTC (permalink / raw)
  To: Lee Jones
  Cc: Drew Fustini, Joel Stanley, Stephen Boyd, Brian Masney,
	Jerome Brunet, linux-riscv, linux-clk, linux-kernel, stable

Hi Lee,

On Fri, Nov 27, 2026 at 7:30 AM Lee Jones <lee@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().
>
> Convert atlantis_clk_pll_ops to use .prepare, .unprepare, and
> .is_prepared instead of .enable, .disable, and .is_enabled so that the
> PLL lock wait executes under the sleeping prepare_lock rather than
> atomic enable_lock.
>
> 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>
> ---
> v1 => v2:
>  - Switch from .enable/.disable/.is_enabled to .prepare/.unprepare/.is_prepared so PLL lock polling runs under the sleeping prepare_lock instead of enable_lock, per Brian Masney's review.
>  - Keep regmap_read_poll_timeout() rather than switching to the atomic variant.
>  - Drop Anirudh Srinivasan's v1 Reviewed-by tag due to the implementation change.
>  - Drop the other patches from v1 that were already applied or superseded.
>
>  drivers/clk/tenstorrent/atlantis-prcm.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

This patch fixes the follow error reported by enabling
CONFIG_DEBUG_ATOMIC_SLEEP.

[    0.295960] BUG: sleeping function called from invalid context at
drivers/clk/tenstorrent/atlantis-prcm.c:329
[    0.296056] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid:
1, name: swapper/0
[    0.296089] preempt_count: 1, expected: 0
[    0.296484] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted
7.2.0-00071-g9a0518d4d70d #2 PREEMPTLAZY
[    0.296651] Hardware name: Tenstorrent Atlantis RISC-V Machine (DT)

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] clk: tenstorrent: Use prepare/unprepare ops for Atlantis PLL
  2026-11-27 13:29 [PATCH v2] clk: tenstorrent: Use prepare/unprepare ops for Atlantis PLL Lee Jones
  2026-11-28 18:28 ` Anirudh Srinivasan
@ 2026-11-29  5:52 ` Drew Fustini
  1 sibling, 0 replies; 3+ messages in thread
From: Drew Fustini @ 2026-11-29  5:52 UTC (permalink / raw)
  To: Lee Jones
  Cc: Joel Stanley, Anirudh Srinivasan, Stephen Boyd, Brian Masney,
	Jerome Brunet, linux-riscv, linux-clk, linux-kernel, stable

On Fri, Nov 27, 2026 at 01:29:36PM +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().
> 
> Convert atlantis_clk_pll_ops to use .prepare, .unprepare, and
> .is_prepared instead of .enable, .disable, and .is_enabled so that the
> PLL lock wait executes under the sleeping prepare_lock rather than
> atomic enable_lock.
> 
> 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>
> ---
> v1 => v2:
>  - Switch from .enable/.disable/.is_enabled to .prepare/.unprepare/.is_prepared so PLL lock polling runs under the sleeping prepare_lock instead of enable_lock, per Brian Masney's review.
>  - Keep regmap_read_poll_timeout() rather than switching to the atomic variant.
>  - Drop Anirudh Srinivasan's v1 Reviewed-by tag due to the implementation change.
>  - Drop the other patches from v1 that were already applied or superseded.

Reviewed-by: Drew Fustini <fustini@kernel.org>

Brian - should I take this through tenstorrent-clk-for-next, or are you
planning to apply it?

Thanks,
Drew

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-29  5:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 13:29 [PATCH v2] clk: tenstorrent: Use prepare/unprepare ops for Atlantis PLL Lee Jones
2026-11-28 18:28 ` Anirudh Srinivasan
2026-11-29  5:52 ` Drew Fustini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox