clk: sunxi-ng: a31: Fix CLK_OUT_* clock ops
Subsystems (3)
PATCH 1/1 clk: sunxi-ng: a31: Fix CLK_OUT_* clock ops
When support for the A31/A31s CCU was first added, the clock ops for the CLK_OUT_* clocks was set to the wrong type. The clocks are MP-type, but the ops was set for div (M) clocks. This went unnoticed until now. This was because while they are different clocks, their data structures aligned in a way that ccu_div_ops would access the second ccu_div_internal and ccu_mux_internal structures, which were valid, if not incorrect.
Furthermore, the use of these CLK_OUT_* was for feeding a precise 32.768 kHz clock signal to the WiFi chip. This was achievable by using the parent with the same clock rate and no divider. So the incorrect divider setting did not affect this usage.
Commit 946797aa3f08 ("clk: sunxi-ng: Support fixed post-dividers on MP style clocks") added a new field to the ccu_mp structure, which broke the aforementioned alignment. Now the system crashes as div_ops tries to look up a nonexistent table.
---
Philipp, can you give this a test and report if this fixes thing? I don't have any A31/A31s boards online to test this.
--- drivers/clk/sunxi-ng/ccu-sun6i-a31.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/sunxi-ng/ccu-sun6i-a31.c +3 -3
@@ -762,7 +762,7 @@ static struct ccu_mp out_a_clk = { .features = CCU_FEATURE_FIXED_PREDIV, .hw.init =CLK_HW_INIT_PARENTS ("out-a" , clk_out_parents, - &ccu_div_ops, + &ccu_mp_ops, 0), }, };
@@ -783,7 +783,7 @@ static struct ccu_mp out_b_clk = { .features = CCU_FEATURE_FIXED_PREDIV, .hw.init =CLK_HW_INIT_PARENTS ("out-b" , clk_out_parents, - &ccu_div_ops, + &ccu_mp_ops, 0), }, };
@@ -804,7 +804,7 @@ static struct ccu_mp out_c_clk = { .features = CCU_FEATURE_FIXED_PREDIV, .hw.init =CLK_HW_INIT_PARENTS ("out-c" , clk_out_parents, - &ccu_div_ops, + &ccu_mp_ops, 0), }, };
Signature · 1 line
2.16.1
Quoted 17 lines · Chen-Yu Tsai
When support for the A31/A31s CCU was first added, the clock ops for the CLK_OUT_* clocks was set to the wrong type. The clocks are MP-type, but the ops was set for div (M) clocks. This went unnoticed until now. This was because while they are different clocks, their data structures aligned in a way that
ccu_div_opswould access the secondccu_div_internalandccu_mux_internalstructures, which were valid, if not incorrect.Furthermore, the use of these CLK_OUT_* was for feeding a precise 32.768 kHz clock signal to the WiFi chip. This was achievable by using the parent with the same clock rate and no divider. So the incorrect divider setting did not affect this usage.
Commit
946797aa3f08("clk: sunxi-ng: Support fixed post-dividers on MP style clocks") added a new field to theccu_mpstructure, which broke the aforementioned alignment. Now the system crashes asdiv_opstries to look up a nonexistent table.
Quoted 4 lines
Reported-by Philipp Rossak <[email protected]>Fixes c6e6c96d8fa6 ("clk: sunxi-ng: Add A31/A31s clocks")Cc <[email protected]>Signed-off-by Chen-Yu Tsai <[email protected]>
Quoted 5 lines
---
Philipp, can you give this a test and report if this fixes thing? I don't have any A31/A31s boards online to test this.
Thanks!
That fixes that bug!
Philipp
Quoted 36 lines
--- drivers/clk/sunxi-ng/ccu-sun6i-a31.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/clk/sunxi-ng/ccu-sun6i-a31.c +3
-3@@ -762,7 +762,7 @@ static struct ccu_mp out_a_clk = { .features = CCU_FEATURE_FIXED_PREDIV, .hw.init =CLK_HW_INIT_PARENTS ("out-a" , clk_out_parents, - &ccu_div_ops, + &ccu_mp_ops, 0), }, };@@ -783,7 +783,7 @@ static struct ccu_mp out_b_clk = { .features = CCU_FEATURE_FIXED_PREDIV, .hw.init =CLK_HW_INIT_PARENTS ("out-b" , clk_out_parents, - &ccu_div_ops, + &ccu_mp_ops, 0), }, };@@ -804,7 +804,7 @@ static struct ccu_mp out_c_clk = { .features = CCU_FEATURE_FIXED_PREDIV, .hw.init =CLK_HW_INIT_PARENTS ("out-c" , clk_out_parents, - &ccu_div_ops, + &ccu_mp_ops, 0), }, };
Quoted 28 lines · Philipp Rossak
Quoted 18 lines · Chen-Yu Tsai
When support for the A31/A31s CCU was first added, the clock ops for the CLK_OUT_* clocks was set to the wrong type. The clocks are MP-type, but the ops was set for div (M) clocks. This went unnoticed until now. This was because while they are different clocks, their data structures aligned in a way that
ccu_div_opswould access the secondccu_div_internalandccu_mux_internalstructures, which were valid, if not incorrect.Furthermore, the use of these CLK_OUT_* was for feeding a precise 32.768 kHz clock signal to the WiFi chip. This was achievable by using the parent with the same clock rate and no divider. So the incorrect divider setting did not affect this usage.
Commit
946797aa3f08("clk: sunxi-ng: Support fixed post-dividers on MP style clocks") added a new field to theccu_mpstructure, which broke the aforementioned alignment. Now the system crashes asdiv_opstries to look up a nonexistent table.Quoted 4 lines
Reported-by Philipp Rossak <[email protected]>Fixes c6e6c96d8fa6 ("clk: sunxi-ng: Add A31/A31s clocks")Cc <[email protected]>Signed-off-by Chen-Yu Tsai <[email protected]>Tested-by Philipp Rossak <[email protected]>Quoted 1 line
Quoted 7 lines
Quoted 5 lines
---
Philipp, can you give this a test and report if this fixes thing? I don't have any A31/A31s boards online to test this.
Thanks!
That fixes that bug!
Thanks.
It looks like this has been applied by Maxime.