Message ID | 20210922125419.4125779-2-maxime@cerno.tech (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/vc4: hdmi: Remove CPU hangs, take 2 | expand |
On Wed, 2021-09-22 at 14:54 +0200, Maxime Ripard wrote: > The driver currently tries to pick the closest rate that is lower than > the rate being requested. > > This causes an issue with clk_set_min_rate() since it actively checks > for the rounded rate to be above the minimum that was just set. > > Let's change the logic a bit to pick the closest rate to the requested > rate, no matter if it's actually higher or lower. > > Fixes: 6d18b8adbe67 ("clk: bcm2835: Support for clock parent selection") > Signed-off-by: Maxime Ripard <maxime@cerno.tech> > --- Reviewed-by: Nicolas Saenz Julienne <nsaenz@kernel.org> Tested-by: Nicolas Saenz Julienne <nsaenz@kernel.org> # boot and basic functionality Regards, Nicolas
Quoting Maxime Ripard (2021-09-22 05:54:15) > The driver currently tries to pick the closest rate that is lower than > the rate being requested. > > This causes an issue with clk_set_min_rate() since it actively checks > for the rounded rate to be above the minimum that was just set. > > Let's change the logic a bit to pick the closest rate to the requested > rate, no matter if it's actually higher or lower. > > Fixes: 6d18b8adbe67 ("clk: bcm2835: Support for clock parent selection") > Signed-off-by: Maxime Ripard <maxime@cerno.tech> > --- Acked-by: Stephen Boyd <sboyd@kernel.org>
On Wed, 22 Sep 2021 14:54:15 +0200, Maxime Ripard wrote: > The driver currently tries to pick the closest rate that is lower than > the rate being requested. > > This causes an issue with clk_set_min_rate() since it actively checks > for the rounded rate to be above the minimum that was just set. > > Let's change the logic a bit to pick the closest rate to the requested > rate, no matter if it's actually higher or lower. > > [...] Applied to drm/drm-misc (drm-misc-fixes). Thanks! Maxime
diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index a254512965eb..bf97b2b2a63f 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -1216,7 +1216,7 @@ static int bcm2835_clock_determine_rate(struct clk_hw *hw, rate = bcm2835_clock_choose_div_and_prate(hw, i, req->rate, &div, &prate, &avgrate); - if (rate > best_rate && rate <= req->rate) { + if (abs(req->rate - rate) < abs(req->rate - best_rate)) { best_parent = parent; best_prate = prate; best_rate = rate;
The driver currently tries to pick the closest rate that is lower than the rate being requested. This causes an issue with clk_set_min_rate() since it actively checks for the rounded rate to be above the minimum that was just set. Let's change the logic a bit to pick the closest rate to the requested rate, no matter if it's actually higher or lower. Fixes: 6d18b8adbe67 ("clk: bcm2835: Support for clock parent selection") Signed-off-by: Maxime Ripard <maxime@cerno.tech> --- drivers/clk/bcm/clk-bcm2835.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)