clk: spacemit: k3: add 2.0 GHz PLL3 and PLL4 rates
Subsystems (3)
PATCH 1/1 clk: spacemit: k3: add 2.0 GHz PLL3 and PLL4 rates
Starting with version k3-br-v1.0.7, the vendor U-Boot configures the C0 and C1 CPU clock domains (X100 cores) to 2.0 GHz instead of 2.2 GHz. PLL3 feeds C0 and PLL4 feeds C1, but their rate tables currently contain only the 2.2 GHz overclocking operating point. This causes the linux kernel to hang at boot.
Add the 2.0 GHz configuration in both tables to fix the issue. Tested with both k3-br-v1.0.5 (X100 running at 2.2 GHz) and k3-br-v1.0.7 (X100 cores running at 2.0 GHz).
--- drivers/clk/spacemit/ccu-k3.c | 2 ++ 1 file changed, 2 insertions(+)
The related U-Boot change is available at:
https://github.com/spacemit-com/uboot-2022.10/commit/274f664150dade144df265baf7dc8e15dd9cce52
drivers/clk/spacemit/ccu-k3.c +2 -0
@@ -30,10 +30,12 @@ static const struct ccu_pll_rate_tbl pll2_rate_tbl[] = { };static const struct ccu_pll_rate_tbl pll3_rate_tbl[] = { +CCU_PLLA_RATE (2000000000UL ,0x0b292aaa ,0x0000ab00 ,0xa0558686 ),CCU_PLLA_RATE (2200000000UL ,0x0b2d3555 ,0x00005500 ,0xa0558787 ), };static const struct ccu_pll_rate_tbl pll4_rate_tbl[] = { +CCU_PLLA_RATE (2000000000UL ,0x0b292aaa ,0x0000ab00 ,0xa0558686 ),CCU_PLLA_RATE (2200000000UL ,0x0b2d3555 ,0x00005500 ,0xa0558787 ), };
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Dangerous Clock Initialization Causing Kernel Panic on Unmatched Rates --
commit 3c3a6a2413682e8647573306b4c79569d6255e7d
Author: Aurelien Jarno <[email protected]>
clk: spacemit: k3: add 2.0 GHz PLL3 and PLL4 rates
Starting with version k3-br-v1.0.7, the vendor U-Boot configures the C0 and C1 CPU clock domains (X100 cores) to 2.0 GHz instead of 2.2 GHz. PLL3 feeds C0 and PLL4 feeds C1, but their rate tables currently contain only the 2.2 GHz overclocking operating point. This causes the linux kernel to hang at boot.
drivers/clk/spacemit/ccu-k3.c static const struct ccu_pll_rate_tbl pll2_rate_tbl[] = { · line 33
Quoted 9 lines
drivers/clk/spacemit/ccu-k3.c +1
-0@@ -30,10 +30,12 @@ static const struct ccu_pll_rate_tbl pll2_rate_tbl[] = { };static const struct ccu_pll_rate_tbl pll3_rate_tbl[] = { +CCU_PLLA_RATE (2000000000UL ,0x0b292aaa ,0x0000ab00 ,0xa0558686 ),
[Severity: High]
This isn't a bug introduced by this patch, but this patch only masks the issue for U-Boot versions currently using 2.0 GHz by ensuring a match is found. The underlying structural flaw remains: unconditionally disabling a potentially vital clock during init just because its rate is unmatched is dangerous.
If the bootloader configures a PLL to a frequency not explicitly defined in the driver's static rate table, ccu_plla_lookup_matched_entry() returns a null pointer. When this occurs, the initialization logic falls back to unconditionally calling ccu_plla_disable() directly, bypassing framework-level protections:
drivers/clk/spacemit/ccu_pll.c:ccu_plla_init() {
...
if (ccu_plla_lookup_matched_entry(pll))
return 0;
ccu_plla_disable(hw);
ccu_plla_update_param(pll, &pll->config.rate_tbl[0]);
...
}This exhibits the same unsafe fallback logic for standard PLLs in ccu_pll_init(), blindly shutting off the clock if it doesn't recognize the hardware's configuration:
drivers/clk/spacemit/ccu_pll.c:ccu_pll_init() {
...
if (ccu_pll_lookup_matched_entry(pll))
return 0;
ccu_pll_disable(hw);
ccu_pll_update_param(pll, &pll->config.rate_tbl[0]);
...
}Should the initialization logic be updated to handle unknown rates without abruptly disabling vital clocks like the CPU clock?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 14 lines · Aurelien Jarno
Starting with version k3-br-v1.0.7, the vendor U-Boot configures the C0 and C1 CPU clock domains (X100 cores) to 2.0 GHz instead of 2.2 GHz. PLL3 feeds C0 and PLL4 feeds C1, but their rate tables currently contain only the 2.2 GHz overclocking operating point. This causes the linux kernel to hang at boot.
Add the 2.0 GHz configuration in both tables to fix the issue. Tested with both k3-br-v1.0.5 (X100 running at 2.2 GHz) and k3-br-v1.0.7 (X100 cores running at 2.0 GHz).
Cc Troy Mitchell <[email protected]>Fixes e371a77255b8 ("clk: spacemit: k3: add the clock tree")Signed-off-by Aurelien Jarno <[email protected]>
Quoted 6 lines
--- drivers/clk/spacemit/ccu-k3.c | 2 ++ 1 file changed, 2 insertions(+)The related U-Boot change is available at:
https://github.com/spacemit-com/uboot-2022.10/commit/274f664150dade144df265baf7dc8e15dd9cce52
FYI, this is the Sashiko review:
https://lore.kernel.org/[email protected]
While I agree we can fix the SpacemiT clock driver, we'll need to add this rate anyway, and it immediately fixes the issue. Fixing the clock driver is more work and this will take more time to fix.
Regards
Aurelien
Signature · 2 lines
Aurelien Jarno GPG: 4096R/1DDD8C9B [email protected] http://aurel32.net
Troy Mitchell
reviewerQuoted 22 lines · Aurelien Jarno
Quoted 14 lines · Aurelien Jarno
Starting with version k3-br-v1.0.7, the vendor U-Boot configures the C0 and C1 CPU clock domains (X100 cores) to 2.0 GHz instead of 2.2 GHz. PLL3 feeds C0 and PLL4 feeds C1, but their rate tables currently contain only the 2.2 GHz overclocking operating point. This causes the linux kernel to hang at boot.
Add the 2.0 GHz configuration in both tables to fix the issue. Tested with both k3-br-v1.0.5 (X100 running at 2.2 GHz) and k3-br-v1.0.7 (X100 cores running at 2.0 GHz).
Cc Troy Mitchell <[email protected]>Fixes e371a77255b8 ("clk: spacemit: k3: add the clock tree")Signed-off-by Aurelien Jarno <[email protected]>Quoted 6 lines
--- drivers/clk/spacemit/ccu-k3.c | 2 ++ 1 file changed, 2 insertions(+)The related U-Boot change is available at:
https://github.com/spacemit-com/uboot-2022.10/commit/274f664150dade144df265baf7dc8e15dd9cce52
Quoted 6 lines
FYI, this is the Sashiko review:
https://lore.kernel.org/[email protected]While I agree we can fix the SpacemiT clock driver, we'll need to add this rate anyway, and it immediately fixes the issue. Fixing the clock driver is more work and this will take more time to fix.
This is indeed an issue that needs to be fixed, but not right now.
It isn't directly related to adding the frequency table either, so I chose to submit the frequency table separately first to get it merged as soon as possible.
Signature · 1 line
Troy Mitchell