lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241121-ge-ian-debug-imx8-clk-tree-v1-3-0f1b722588fe@bootlin.com>
Date: Thu, 21 Nov 2024 18:41:13 +0100
From: Miquel Raynal <miquel.raynal@...tlin.com>
To: Abel Vesa <abelvesa@...nel.org>, Peng Fan <peng.fan@....com>, 
 Michael Turquette <mturquette@...libre.com>, 
 Stephen Boyd <sboyd@...nel.org>, Shawn Guo <shawnguo@...nel.org>, 
 Sascha Hauer <s.hauer@...gutronix.de>, 
 Pengutronix Kernel Team <kernel@...gutronix.de>, 
 Fabio Estevam <festevam@...il.com>, Ying Liu <victor.liu@....com>, 
 Marek Vasut <marex@...x.de>
Cc: Laurent Pinchart <laurent.pinchart@...asonboard.com>, 
 linux-clk@...r.kernel.org, imx@...ts.linux.dev, 
 linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org, 
 dri-devel@...ts.freedesktop.org, Abel Vesa <abel.vesa@...aro.org>, 
 Herve Codina <herve.codina@...tlin.com>, 
 Luca Ceresoli <luca.ceresoli@...tlin.com>, 
 Thomas Petazzoni <thomas.petazzoni@...tlin.com>, Ian Ray <ian.ray@...com>, 
 Miquel Raynal <miquel.raynal@...tlin.com>
Subject: [PATCH 3/5] clk: Split clk_calc_subtree()

This helper does two different things:
- it calculates the new clock frequency
    - as part of this task, it also handles a possible parent change
- it walks the clock subtree to further update frequencies as well (but
  the parent changes are no longer relevant there).

In order to ease the understanding of the next step, let's split this
helper into:
- clk_calc_core_and_subtree() which performs the top clock update (with
  the parents handling) and then calls...
- clk_calc_subtree() (which calls itself recursively) in order to
  perform the subtree updates.

There is no functional change intended.

Signed-off-by: Miquel Raynal <miquel.raynal@...tlin.com>
---
 drivers/clk/clk.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index f171539bbb842f57698249a475c62f3f5719ccd1..adfc5bfb93b5a65b6f58c52ca2c432d651f7dd7d 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2268,8 +2268,18 @@ static int __clk_speculate_rates(struct clk_core *core,
 	return ret;
 }
 
-static void clk_calc_subtree(struct clk_core *core, unsigned long new_rate,
-			     struct clk_core *new_parent, u8 p_index)
+static void clk_calc_subtree(struct clk_core *core)
+{
+	struct clk_core *child;
+
+	core->new_rate = clk_recalc(core, core->parent->new_rate);
+
+	hlist_for_each_entry(child, &core->children, child_node)
+		clk_calc_subtree(child);
+}
+
+static void clk_calc_core_and_subtree(struct clk_core *core, unsigned long new_rate,
+				      struct clk_core *new_parent, u8 p_index)
 {
 	struct clk_core *child;
 
@@ -2281,10 +2291,8 @@ static void clk_calc_subtree(struct clk_core *core, unsigned long new_rate,
 	if (new_parent && new_parent != core->parent)
 		new_parent->new_child = core;
 
-	hlist_for_each_entry(child, &core->children, child_node) {
-		child->new_rate = clk_recalc(child, new_rate);
-		clk_calc_subtree(child, child->new_rate, NULL, 0);
-	}
+	hlist_for_each_entry(child, &core->children, child_node)
+		clk_calc_subtree(child);
 }
 
 /*
@@ -2368,7 +2376,7 @@ static struct clk_core *clk_calc_new_rates(struct clk_core *core,
 		top = clk_calc_new_rates(parent, best_parent_rate);
 
 out:
-	clk_calc_subtree(core, new_rate, parent, p_index);
+	clk_calc_core_and_subtree(core, new_rate, parent, p_index);
 
 	return top;
 }

-- 
2.47.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ