Skip to content

Commit 0ae6712

Browse files
MarijnS95bebarino
authored andcommitted
clk: qcom: rcg2: Rectify clk_gfx3d rate rounding without mux division
In case the mux is not divided parent_req was mistakenly not assigned to leading __clk_determine_rate to determine the best frequency setting for a requested rate of 0, resulting in the msm8996 platform not booting. Rectify this by refactoring the logic to unconditionally assign to parent_req.rate with the clock rate the caller is expecting. Fixes: 7cbb78a ("clk: qcom: rcg2: Stop hardcoding gfx3d pingpong parent numbers") Reported-by: Konrad Dybcio <konrad.dybcio@somainline.org> Tested-by: Konrad Dybcio <konrad.dybcio@somainline.org> Reviewed-By: AngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org> Link: https://lore.kernel.org/r/20210302234106.3418665-1-marijn.suijten@somainline.org Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent c9b86db commit 0ae6712

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

drivers/clk/qcom/clk-rcg2.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,8 @@ static int clk_gfx3d_determine_rate(struct clk_hw *hw,
730730
struct clk_rate_request parent_req = { };
731731
struct clk_rcg2_gfx3d *cgfx = to_clk_rcg2_gfx3d(hw);
732732
struct clk_hw *xo, *p0, *p1, *p2;
733-
unsigned long request, p0_rate;
733+
unsigned long p0_rate;
734+
u8 mux_div = cgfx->div;
734735
int ret;
735736

736737
p0 = cgfx->hws[0];
@@ -750,22 +751,23 @@ static int clk_gfx3d_determine_rate(struct clk_hw *hw,
750751
return 0;
751752
}
752753

753-
request = req->rate;
754-
if (cgfx->div > 1)
755-
parent_req.rate = request = request * cgfx->div;
754+
if (mux_div == 0)
755+
mux_div = 1;
756+
757+
parent_req.rate = req->rate * mux_div;
756758

757759
/* This has to be a fixed rate PLL */
758760
p0_rate = clk_hw_get_rate(p0);
759761

760-
if (request == p0_rate) {
762+
if (parent_req.rate == p0_rate) {
761763
req->rate = req->best_parent_rate = p0_rate;
762764
req->best_parent_hw = p0;
763765
return 0;
764766
}
765767

766768
if (req->best_parent_hw == p0) {
767769
/* Are we going back to a previously used rate? */
768-
if (clk_hw_get_rate(p2) == request)
770+
if (clk_hw_get_rate(p2) == parent_req.rate)
769771
req->best_parent_hw = p2;
770772
else
771773
req->best_parent_hw = p1;
@@ -780,8 +782,7 @@ static int clk_gfx3d_determine_rate(struct clk_hw *hw,
780782
return ret;
781783

782784
req->rate = req->best_parent_rate = parent_req.rate;
783-
if (cgfx->div > 1)
784-
req->rate /= cgfx->div;
785+
req->rate /= mux_div;
785786

786787
return 0;
787788
}

0 commit comments

Comments
 (0)