2f5eb060191f8e374c42f0e6987b88dbc05e2dfd
[openwrt/staging/hauke.git] /
1 From dc4310d9d45e72360b8fdf46d514b6d29c92e808 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Sat, 2 Apr 2022 13:52:55 +0200
4 Subject: [PATCH] clk: Switch from __clk_determine_rate to
5 clk_core_round_rate_nolock
6
7 clk_mux_determine_rate_flags() will call into __clk_determine_rate()
8 with a clk_hw pointer, while it has access to the clk_core pointer
9 already.
10
11 This leads to back and forth between clk_hw and clk_core, while
12 __clk_determine_rate will only call clk_core_round_rate_nolock() with
13 the clk_core pointer it retrieved from the clk_hw.
14
15 Let's simplify things a bit by calling into clk_core_round_rate_nolock
16 directly.
17
18 Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com> # imx8mp
19 Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> # exynos4210, meson g12b
20 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
21 ---
22 drivers/clk/clk.c | 13 ++++++++++---
23 1 file changed, 10 insertions(+), 3 deletions(-)
24
25 --- a/drivers/clk/clk.c
26 +++ b/drivers/clk/clk.c
27 @@ -542,6 +542,9 @@ static bool mux_is_better_rate(unsigned
28 return now <= rate && now > best;
29 }
30
31 +static int clk_core_round_rate_nolock(struct clk_core *core,
32 + struct clk_rate_request *req);
33 +
34 int clk_mux_determine_rate_flags(struct clk_hw *hw,
35 struct clk_rate_request *req,
36 unsigned long flags)
37 @@ -555,8 +558,12 @@ int clk_mux_determine_rate_flags(struct
38 if (core->flags & CLK_SET_RATE_NO_REPARENT) {
39 parent = core->parent;
40 if (core->flags & CLK_SET_RATE_PARENT) {
41 - ret = __clk_determine_rate(parent ? parent->hw : NULL,
42 - &parent_req);
43 + if (!parent) {
44 + req->rate = 0;
45 + return 0;
46 + }
47 +
48 + ret = clk_core_round_rate_nolock(parent, &parent_req);
49 if (ret)
50 return ret;
51
52 @@ -579,7 +586,7 @@ int clk_mux_determine_rate_flags(struct
53
54 if (core->flags & CLK_SET_RATE_PARENT) {
55 parent_req = *req;
56 - ret = __clk_determine_rate(parent->hw, &parent_req);
57 + ret = clk_core_round_rate_nolock(parent, &parent_req);
58 if (ret)
59 continue;
60 } else {