Skip to content

Commit 7e91ed7

Browse files
committed
clk: sunxi-ng: h6: Reparent CPUX during PLL CPUX rate change
While PLL CPUX clock rate change when CPU is running from it works in vast majority of cases, now and then it causes instability. This leads to system crashes and other undefined behaviour. After a lot of testing (30+ hours) while also doing a lot of frequency switches, we can't observe any instability issues anymore when doing reparenting to stable clock like 24 MHz oscillator. Fixes: 524353e ("clk: sunxi-ng: add support for the Allwinner H6 CCU") Reported-by: Chad Wagner <[email protected]> Link: https://forum.libreelec.tv/thread/27295-orange-pi-3-lts-freezes/ Tested-by: Chad Wagner <[email protected]> Reviewed-by: Chen-Yu Tsai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jernej Skrabec <[email protected]>
1 parent 4cece76 commit 7e91ed7

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

drivers/clk/sunxi-ng/ccu-sun50i-h6.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,11 +1181,18 @@ static const u32 usb2_clk_regs[] = {
11811181
SUN50I_H6_USB3_CLK_REG,
11821182
};
11831183

1184+
static struct ccu_mux_nb sun50i_h6_cpu_nb = {
1185+
.common = &cpux_clk.common,
1186+
.cm = &cpux_clk.mux,
1187+
.delay_us = 1,
1188+
.bypass_index = 0, /* index of 24 MHz oscillator */
1189+
};
1190+
11841191
static int sun50i_h6_ccu_probe(struct platform_device *pdev)
11851192
{
11861193
void __iomem *reg;
1194+
int i, ret;
11871195
u32 val;
1188-
int i;
11891196

11901197
reg = devm_platform_ioremap_resource(pdev, 0);
11911198
if (IS_ERR(reg))
@@ -1252,7 +1259,15 @@ static int sun50i_h6_ccu_probe(struct platform_device *pdev)
12521259
val |= BIT(24);
12531260
writel(val, reg + SUN50I_H6_HDMI_CEC_CLK_REG);
12541261

1255-
return devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_h6_ccu_desc);
1262+
ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_h6_ccu_desc);
1263+
if (ret)
1264+
return ret;
1265+
1266+
/* Reparent CPU during PLL CPUX rate changes */
1267+
ccu_mux_notifier_register(pll_cpux_clk.common.hw.clk,
1268+
&sun50i_h6_cpu_nb);
1269+
1270+
return 0;
12561271
}
12571272

12581273
static const struct of_device_id sun50i_h6_ccu_ids[] = {

0 commit comments

Comments
 (0)