* [PATCH] clk: tenstorrent: Fix refcount leak on shared gate clk enable failure
@ 2026-09-24 15:31 Anirudh Srinivasan
2026-09-25 2:09 ` Drew Fustini
0 siblings, 1 reply; 2+ messages in thread
From: Anirudh Srinivasan @ 2026-09-24 15:31 UTC (permalink / raw)
To: Drew Fustini, Joel Stanley, Stephen Boyd, Brian Masney, Jerome Brunet
Cc: Drew Fustini, Brian Masney, linux-riscv, linux-clk, linux-kernel,
Sashiko, Anirudh Srinivasan
atlantis_clk_gate_shared_enable() increments the refcount for the number
of clks requesting the shared gate clk to be enabled always. It should
only do this when the enable for the gate took effect in hardware. It's
possible to end up in a situation where the gate enable failed, but the
refcount is incremented anyway, so subsequent requests by other clks
that share the same refcount get ignored and the gate enable is never
retried.
Update this function so that the refcount is not incremented when the
gate clk enable fails in hardware.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/AS8P251MB00013BD9A093C06D2D60E10EC8B42%40AS8P251MB0001.EURP251.PROD.OUTLOOK.COM
Fixes: 23c8ebc95284 ("clk: tenstorrent: Add Atlantis clock controller driver")
Signed-off-by: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
---
drivers/clk/tenstorrent/atlantis-prcm.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/clk/tenstorrent/atlantis-prcm.c b/drivers/clk/tenstorrent/atlantis-prcm.c
index 6d4386eeb7dae..c8663b973749c 100644
--- a/drivers/clk/tenstorrent/atlantis-prcm.c
+++ b/drivers/clk/tenstorrent/atlantis-prcm.c
@@ -397,22 +397,21 @@ static int atlantis_clk_gate_shared_enable(struct clk_hw *hw)
scoped_guard(spinlock_irqsave, gate->config.refcount_lock)
{
- need_enable = (*gate->config.share_count)++ == 0;
+ need_enable = (*gate->config.share_count) == 0;
if (need_enable) {
regmap_set_bits(gate->common.regmap,
gate->config.reg_offset,
gate->config.enable);
- }
- }
- if (need_enable) {
- if (!regmap_test_bits(gate->common.regmap,
- gate->config.reg_offset,
- gate->config.enable)) {
- pr_warn("%s: gate enable %d failed to enable\n",
- clk_hw_get_name(hw), gate->config.enable);
- return -EIO;
+ if (!regmap_test_bits(gate->common.regmap,
+ gate->config.reg_offset,
+ gate->config.enable)) {
+ pr_warn("%s: gate enable %d failed to enable\n",
+ clk_hw_get_name(hw), gate->config.enable);
+ return -EIO;
+ }
}
+ (*gate->config.share_count)++;
}
return 0;
---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260924-atlantis_gate_shared_enable_fix-c8d0c8db63ad
Best regards,
--
Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] clk: tenstorrent: Fix refcount leak on shared gate clk enable failure
2026-09-24 15:31 [PATCH] clk: tenstorrent: Fix refcount leak on shared gate clk enable failure Anirudh Srinivasan
@ 2026-09-25 2:09 ` Drew Fustini
0 siblings, 0 replies; 2+ messages in thread
From: Drew Fustini @ 2026-09-25 2:09 UTC (permalink / raw)
To: Anirudh Srinivasan
Cc: Drew Fustini, Joel Stanley, Stephen Boyd, Brian Masney,
Jerome Brunet, Brian Masney, linux-riscv, linux-clk,
linux-kernel, Sashiko
On Thu, Sep 24, 2026 at 10:31:51AM -0500, Anirudh Srinivasan wrote:
> atlantis_clk_gate_shared_enable() increments the refcount for the number
> of clks requesting the shared gate clk to be enabled always. It should
> only do this when the enable for the gate took effect in hardware. It's
> possible to end up in a situation where the gate enable failed, but the
> refcount is incremented anyway, so subsequent requests by other clks
> that share the same refcount get ignored and the gate enable is never
> retried.
>
> Update this function so that the refcount is not incremented when the
> gate clk enable fails in hardware.
>
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Link: https://sashiko.dev/#/patchset/AS8P251MB00013BD9A093C06D2D60E10EC8B42%40AS8P251MB0001.EURP251.PROD.OUTLOOK.COM
> Fixes: 23c8ebc95284 ("clk: tenstorrent: Add Atlantis clock controller driver")
> Signed-off-by: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
> ---
> drivers/clk/tenstorrent/atlantis-prcm.c | 19 +++++++++----------
> 1 file changed, 9 insertions(+), 10 deletions(-)
Reviewed-by: Drew Fustini (Tenstorrent) <fustini@kernel.org>
I will apply this to tenstorrent-clk-for-next.
Thanks,
Drew
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-25 2:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-24 15:31 [PATCH] clk: tenstorrent: Fix refcount leak on shared gate clk enable failure Anirudh Srinivasan
2026-09-25 2:09 ` Drew Fustini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®