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  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:   Thu, 26 Nov 2020 14:40:06 +0200
From:   Abel Vesa <abel.vesa@....com>
To:     Stephen Boyd <sboyd@...nel.org>,
        Sascha Hauer <kernel@...gutronix.de>,
        Peng Fan <peng.fan@....com>,
        Fabio Estevam <fabio.estevam@....com>,
        Anson Huang <anson.huang@....com>,
        Dong Aisheng <aisheng.dong@....com>,
        Jacky Bai <ping.bai@....com>
Cc:     NXP Linux Team <linux-imx@....com>, linux-clk@...r.kernel.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        linux-arm-kernel@...ts.infradead.org, Abel Vesa <abel.vesa@....com>
Subject: [PATCH v2 2/5] clk: Add CLK_GET_PARENT_NOCACHE flag

This can be used by the clocks that have their parents changed from EL3.
This way the clk_get_parent will read the value from register instead of
using the value stored in the core framework.

Signed-off-by: Abel Vesa <abel.vesa@....com>
Suggested-by: Peng Fan <peng.fan@....com>
---
 drivers/clk/clk.c            | 31 +++++++++++++++++--------------
 include/linux/clk-provider.h |  1 +
 2 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index c77feb6..2dd4bf4 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2401,6 +2401,16 @@ int clk_set_max_rate(struct clk *clk, unsigned long rate)
 }
 EXPORT_SYMBOL_GPL(clk_set_max_rate);
 
+static struct clk_core *__clk_get_parent(struct clk_core *core)
+{
+	u8 index = 0;
+
+	if (core->num_parents > 1 && core->ops->get_parent)
+		index = core->ops->get_parent(core->hw);
+
+	return clk_core_get_parent_by_index(core, index);
+}
+
 /**
  * clk_get_parent - return the parent of a clk
  * @clk: the clk whose parent gets returned
@@ -2415,24 +2425,17 @@ struct clk *clk_get_parent(struct clk *clk)
 		return NULL;
 
 	clk_prepare_lock();
-	/* TODO: Create a per-user clk and change callers to call clk_put */
-	parent = !clk->core->parent ? NULL : clk->core->parent->hw->clk;
+	if (clk->core && (clk->core->flags & CLK_GET_PARENT_NOCACHE))
+		parent = __clk_get_parent(clk->core)->hw->clk;
+	else
+		/* TODO: Create a per-user clk and change callers to call clk_put */
+		parent = !clk->core->parent ? NULL : clk->core->parent->hw->clk;
 	clk_prepare_unlock();
 
 	return parent;
 }
 EXPORT_SYMBOL_GPL(clk_get_parent);
 
-static struct clk_core *__clk_init_parent(struct clk_core *core)
-{
-	u8 index = 0;
-
-	if (core->num_parents > 1 && core->ops->get_parent)
-		index = core->ops->get_parent(core->hw);
-
-	return clk_core_get_parent_by_index(core, index);
-}
-
 static void clk_core_reparent(struct clk_core *core,
 				  struct clk_core *new_parent)
 {
@@ -3352,7 +3355,7 @@ static void clk_core_reparent_orphans_nolock(void)
 	 * parent.
 	 */
 	hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) {
-		struct clk_core *parent = __clk_init_parent(orphan);
+		struct clk_core *parent = __clk_get_parent(orphan);
 
 		/*
 		 * We need to use __clk_set_parent_before() and _after() to
@@ -3453,7 +3456,7 @@ static int __clk_core_init(struct clk_core *core)
 			goto out;
 	}
 
-	parent = core->parent = __clk_init_parent(core);
+	parent = core->parent = __clk_get_parent(core);
 
 	/*
 	 * Populate core->parent if parent has already been clk_core_init'd. If
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 81ba1aa..f871991b 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -32,6 +32,7 @@
 #define CLK_OPS_PARENT_ENABLE	BIT(12)
 /* duty cycle call may be forwarded to the parent clock */
 #define CLK_DUTY_CYCLE_PARENT	BIT(13)
+#define CLK_GET_PARENT_NOCACHE	BIT(14) /* read the parent from reg */
 
 struct clk;
 struct clk_hw;
-- 
2.7.4

Powered by blists - more mailing lists