Skip to contentSkip to conversation

clk: sunxi: Fix M factor computation for APB1

PATCH In review Stéphan Rafin 2 participants 2 messages Nov 3, 2016 – Nov 4, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: sunxi: Fix M factor computation for APB1

commit cfa636886033 ("clk: sunxi: factors: Consolidate get_factors parameters into a struct") introduced a regression for m factor computation in sun4i_get_apb1_factors function.

The old code reassigned the "parent_rate" parameter to the targeted divisor value and was buggy for the returned frequency but not for the computed factors. Now, returned frequency is good but m factor is incorrectly computed (its max value 31 is always set resulting in a significantly slower frequency than the requested one...)

This patch simply restores the original proper computation for m while keeping the good changes for returned rate.

---
 drivers/clk/sunxi/clk-sunxi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/sunxi/clk-sunxi.c +1 -1
index 838b22a..f2c9274 100644
@@ -373,7 +373,7 @@ static void sun4i_get_apb1_factors(struct factors_request *req)
 	else
 		calcp = 3;
 
-	calcm = (req->parent_rate >> calcp) - 1;
+	calcm = (div >> calcp) - 1;
 
 	req->rate = (req->parent_rate >> calcp) / (calcm + 1);
 	req->m = calcm;
Signature · 1 line
2.6.6
#1 lore raw
Quoted 10 lines · St?phan Rafin

commit cfa636886033 ("clk: sunxi: factors: Consolidate get_factors parameters into a struct") introduced a regression for m factor computation in sun4i_get_apb1_factors function.

The old code reassigned the "parent_rate" parameter to the targeted divisor value and was buggy for the returned frequency but not for the computed factors. Now, returned frequency is good but m factor is incorrectly computed (its max value 31 is always set resulting in a significantly slower frequency than the requested one...)

Quoted 4 lines

This patch simply restores the original proper computation for m while keeping the good changes for returned rate.

Applied (added a Fixes tag), thanks

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20161104/a56fa6c0/attachment.sig>