This is a note to let you know that I've just added the patch titled clk: bcm-2835: Pick the closest clock rate to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: clk-bcm-2835-pick-the-closest-clock-rate.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 190694d1bd3d0a23ec15f9e74fa1e8fc8e7b85de Author: Maxime Ripard <maxime@xxxxxxxxxx> Date: Wed Sep 22 14:54:15 2021 +0200 clk: bcm-2835: Pick the closest clock rate [ Upstream commit 5517357a4733d7cf7c17fc79d0530cfa47add372 ] 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@xxxxxxxxxx> Acked-by: Stephen Boyd <sboyd@xxxxxxxxxx> Reviewed-by: Nicolas Saenz Julienne <nsaenz@xxxxxxxxxx> Tested-by: Nicolas Saenz Julienne <nsaenz@xxxxxxxxxx> # boot and basic functionality Tested-by: Michael Stapelberg <michael@xxxxxxxxxxxxx> Link: https://patchwork.freedesktop.org/patch/msgid/20210922125419.4125779-2-maxime@xxxxxxxxxx Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index 1ac803e14fa3e..a919ee9c3fcb8 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -1217,7 +1217,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;