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]
Date:	Wed, 22 Apr 2015 22:53:05 +0200
From:	Heiko Stuebner <heiko@...ech.de>
To:	mturquette@...aro.org, sboyd@...eaurora.org
Cc:	dianders@...omium.org, linux-clk@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
	Heiko Stuebner <heiko@...ech.de>,
	Boris Brezillon <boris.brezillon@...e-electrons.com>,
	Alex Elder <elder@...aro.org>,
	Alexandre Belloni <alexandre.belloni@...e-electrons.com>,
	Stephen Warren <swarren@...dotorg.org>,
	Max Filippov <jcmvbkbc@...il.com>, kernel@...gutronix.de,
	Zhangfei Gao <zhangfei.gao@...aro.org>,
	Santosh Shilimkar <ssantosh@...nel.org>,
	Chao Xie <chao.xie@...vell.com>,
	Jason Cooper <jason@...edaemon.net>,
	Stefan Wahren <stefan.wahren@...e.com>,
	Andrew Bresticker <abrestic@...omium.org>,
	Robert Jarzmik <robert.jarzmik@...e.fr>,
	Georgi Djakov <georgi.djakov@...aro.org>,
	Sylwester Nawrocki <s.nawrocki@...sung.com>,
	Geert Uytterhoeven <geert+renesas@...der.be>,
	Barry Song <baohua@...nel.org>,
	Dinh Nguyen <dinguyen@...nsource.altera.com>,
	Viresh Kumar <viresh.linux@...il.com>,
	Gabriel FERNANDEZ <gabriel.fernandez@...com>,
	emilio@...pez.com.ar, Peter De Schrijver <pdeschrijver@...dia.com>,
	Tero Kristo <t-kristo@...com>,
	Ulf Hansson <ulf.hansson@...aro.org>,
	Pawel Moll <pawel.moll@....com>,
	Michal Simek <michal.simek@...inx.com>
Subject: [PATCH v3 1/2] clk: track the orphan status of clocks and their children

While children of orphan clocks are not carried in the orphan-list itself,
they're nevertheless orphans in their own right as they also don't have an
input-rate available. To ease tracking if a clock is an orphan or has an
orphan in its parent path introduce an orphan field into struct clk and
update it and the fields in child-clocks when a clock gets added or removed
from the orphan-list.

Suggested-by: Stephen Boyd <sboyd@...eaurora.org>
Signed-off-by: Heiko Stuebner <heiko@...ech.de>
Cc: Boris Brezillon <boris.brezillon@...e-electrons.com>
Cc: Alex Elder <elder@...aro.org>
Cc: Alexandre Belloni <alexandre.belloni@...e-electrons.com>
Cc: Stephen Warren <swarren@...dotorg.org>
Cc: Max Filippov <jcmvbkbc@...il.com>
Cc: kernel@...gutronix.de
Cc: Zhangfei Gao <zhangfei.gao@...aro.org>
Cc: Santosh Shilimkar <ssantosh@...nel.org>
Cc: Chao Xie <chao.xie@...vell.com>
Cc: Jason Cooper <jason@...edaemon.net>
Cc: Stefan Wahren <stefan.wahren@...e.com>
Cc: Andrew Bresticker <abrestic@...omium.org>
Cc: Robert Jarzmik <robert.jarzmik@...e.fr>
Cc: Georgi Djakov <georgi.djakov@...aro.org>
Cc: Sylwester Nawrocki <s.nawrocki@...sung.com>
Cc: Geert Uytterhoeven <geert+renesas@...der.be>
Cc: Barry Song <baohua@...nel.org>
Cc: Dinh Nguyen <dinguyen@...nsource.altera.com>
Cc: Viresh Kumar <viresh.linux@...il.com>
Cc: Gabriel FERNANDEZ <gabriel.fernandez@...com>
Cc: emilio@...pez.com.ar
Cc: Peter De Schrijver <pdeschrijver@...dia.com>
Cc: Tero Kristo <t-kristo@...com>
Cc: Ulf Hansson <ulf.hansson@...aro.org>
Cc: Pawel Moll <pawel.moll@....com>
Cc: Michal Simek <michal.simek@...inx.com>
---
 drivers/clk/clk.c | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index b2361d4..341904f 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -62,6 +62,7 @@ struct clk_core {
 	struct clk_core		*new_parent;
 	struct clk_core		*new_child;
 	unsigned long		flags;
+	bool			orphan;
 	unsigned int		enable_count;
 	unsigned int		prepare_count;
 	unsigned long		accuracy;
@@ -1401,18 +1402,40 @@ static int clk_fetch_parent_index(struct clk_core *clk,
 	return -EINVAL;
 }
 
+/*
+ * Update the orphan status of @clk and all its children.
+ */
+static void clk_core_update_orphan_status(struct clk_core *clk, bool is_orphan)
+{
+	struct clk_core *child;
+
+	clk->orphan = is_orphan;
+
+	hlist_for_each_entry(child, &clk->children, child_node)
+		clk_core_update_orphan_status(child, is_orphan);
+}
+
 static void clk_reparent(struct clk_core *clk, struct clk_core *new_parent)
 {
+	bool was_orphan = clk->orphan;
+
 	hlist_del(&clk->child_node);
 
 	if (new_parent) {
+		bool becomes_orphan = new_parent->orphan;
+
 		/* avoid duplicate POST_RATE_CHANGE notifications */
 		if (new_parent->new_child == clk)
 			new_parent->new_child = NULL;
 
 		hlist_add_head(&clk->child_node, &new_parent->children);
+
+		if (was_orphan != becomes_orphan)
+			clk_core_update_orphan_status(clk, becomes_orphan);
 	} else {
 		hlist_add_head(&clk->child_node, &clk_orphan_list);
+		if (!was_orphan)
+			clk_core_update_orphan_status(clk, true);
 	}
 
 	clk->parent = new_parent;
@@ -2302,13 +2325,17 @@ static int __clk_init(struct device *dev, struct clk *clk_user)
 	 * clocks and re-parent any that are children of the clock currently
 	 * being clk_init'd.
 	 */
-	if (clk->parent)
+	if (clk->parent) {
 		hlist_add_head(&clk->child_node,
 				&clk->parent->children);
-	else if (clk->flags & CLK_IS_ROOT)
+		clk->orphan = clk->parent->orphan;
+	} else if (clk->flags & CLK_IS_ROOT) {
 		hlist_add_head(&clk->child_node, &clk_root_list);
-	else
+		clk->orphan = false;
+	} else {
 		hlist_add_head(&clk->child_node, &clk_orphan_list);
+		clk->orphan = true;
+	}
 
 	/*
 	 * Set clk's accuracy.  The preferred method is to use
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ