[PATCH] clk: sunxi-ng: h616: register CPU PLL notifier before mux notifier
From: Ilya Titov
Date: Mon Nov 09 2026 - 04:13:54 EST
Currently the CPU mux notifier is registered first, so on
POST_RATE_CHANGE the CPU is switched back to PLL_CPUX before the PLL
notifier re-locks it. The CPU then runs from the PLL while it is still
settling. The comment for ccu_pll_notifier_cb() says it must be
registered first, and the other sunxi-ng drivers (A33, H3, R40, A64,
A100) do it in that order.
We see random hangs and oopses on T507 based boards when cpufreq
switches frequency often. In the oopses and JTAG dumps we captured, CPU0
was always in ccu_mux_notifier_cb() or ccu_pll_notifier_cb(). Other
CPUs were usually stuck on dsb after tlbi, waiting for CPU0.
Running a random walk over all OPPs with some load on other cores, two
boards hung 20+ times in about 3 days. With the PLL notifier registered
first there were no hangs in the same time.
Fixes: 087b4083d3f9 ("clk: sunxi-ng: h616: Reparent CPU clock during frequency changes")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Ilya Titov <ilya.titov@xxxxxxxxxxxxxx>
---
drivers/clk/sunxi-ng/ccu-sun50i-h616.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-h616.c b/drivers/clk/sunxi-ng/ccu-sun50i-h616.c
index 955c614830fa..00b7811f3a84 100644
--- a/drivers/clk/sunxi-ng/ccu-sun50i-h616.c
+++ b/drivers/clk/sunxi-ng/ccu-sun50i-h616.c
@@ -1235,13 +1235,16 @@ static int sun50i_h616_ccu_probe(struct platform_device *pdev)
if (ret)
return ret;
+ /*
+ * Re-lock the CPU PLL after any rate changes. Must be registered
+ * before the mux notifier, so CPU goes back to a locked PLL.
+ */
+ ccu_pll_notifier_register(&sun50i_h616_pll_cpu_nb);
+
/* Reparent CPU during CPU PLL rate changes */
ccu_mux_notifier_register(pll_cpux_clk.common.hw.clk,
&sun50i_h616_cpu_nb);
- /* Re-lock the CPU PLL after any rate changes */
- ccu_pll_notifier_register(&sun50i_h616_pll_cpu_nb);
-
/* Reparent GPU during GPU PLL rate changes */
ccu_mux_notifier_register(pll_gpu_clk.common.hw.clk,
&sun50i_h616_gpu_nb);
--
2.54.0 (Apple Git-157)