[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220124183938.221804577@linuxfoundation.org>
Date: Mon, 24 Jan 2022 19:41:49 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Maxime Ripard <maxime@...no.tech>,
Stephen Boyd <sboyd@...nel.org>,
Nicolas Saenz Julienne <nsaenz@...nel.org>,
Michael Stapelberg <michael@...pelberg.ch>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH 4.14 034/186] clk: bcm-2835: Pick the closest clock rate
From: Maxime Ripard <maxime@...no.tech>
[ 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@...no.tech>
Acked-by: Stephen Boyd <sboyd@...nel.org>
Reviewed-by: Nicolas Saenz Julienne <nsaenz@...nel.org>
Tested-by: Nicolas Saenz Julienne <nsaenz@...nel.org> # boot and basic functionality
Tested-by: Michael Stapelberg <michael@...pelberg.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210922125419.4125779-2-maxime@cerno.tech
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
drivers/clk/bcm/clk-bcm2835.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index 98295b9703178..d6cd1cc3f8e4d 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -1233,7 +1233,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;
--
2.34.1
Powered by blists - more mailing lists