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: <20231002-ccf-set-multiple-v1-3-2df5e9eb3738@skidata.com>
Date:   Mon, 02 Oct 2023 11:23:34 +0200
From:   Benjamin Bara <bbara93@...il.com>
To:     Maxime Ripard <mripard@...nel.org>,
        Michael Turquette <mturquette@...libre.com>,
        Stephen Boyd <sboyd@...nel.org>
Cc:     Frank Oltmanns <frank@...manns.dev>,
        Adam Ford <aford173@...il.com>, linux-clk@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Benjamin Bara <benjamin.bara@...data.com>
Subject: [PATCH RFC 3/4] clk: introduce req_rate_tmp

From: Benjamin Bara <benjamin.bara@...data.com>

A clock currently has a req_rate, which is required by the consumer, and
a next_rate, which is the outcoming rate of the ongoing clk_set_rate()
call. This commit introduces req_rate_tmp, which is a temporary required
rate for the ongoing change. This means, the clock is an ancestor of the
change trigger and a descendant of the top-most clock to change. This
helps us to identify if the clock is changed "by accident" (new_rate
set, req_rate_tmp not set).

Signed-off-by: Benjamin Bara <benjamin.bara@...data.com>
---
 drivers/clk/clk.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 5f183cba300c..3e7dd97b71c3 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -68,6 +68,7 @@ struct clk_core {
 	u8			new_parent_index;
 	unsigned long		rate;
 	unsigned long		req_rate;
+	unsigned long		req_rate_tmp;
 	unsigned long		new_rate;
 	struct clk_core		*new_parent;
 	struct clk_core		*new_child;
@@ -2168,6 +2169,7 @@ static void clk_reset_temp_rates(struct clk_core *core)
 	struct clk_core *child;
 
 	core->new_rate = CLK_RATE_UNSET;
+	core->req_rate_tmp = CLK_RATE_UNSET;
 
 	hlist_for_each_entry(child, &core->children, child_node) {
 		clk_reset_temp_rates(child);
@@ -2256,8 +2258,17 @@ static struct clk_core *clk_calc_new_rates(struct clk_core *core,
 
 out:
 	/* only set new_rates if we found a valid change path */
-	if (top)
+	if (top) {
+		/*
+		 * The current clock is an ancestor of the trigger and therefore
+		 * is a clock which needs to be changed in this run. Clocks
+		 * with new_rate set but req_rate_tmp unset are changed "by
+		 * accident". On these clocks, the new_rate potentially
+		 * conflicts with req_rate.
+		 */
+		core->req_rate_tmp = new_rate;
 		clk_calc_subtree(core, new_rate, parent, p_index);
+	}
 
 	return top;
 }
@@ -3917,7 +3928,7 @@ static int __clk_core_init(struct clk_core *core)
 	else
 		rate = 0;
 	core->rate = rate;
-	core->req_rate = CLK_RATE_UNSET;
+	core->req_rate = core->req_rate_tmp = CLK_RATE_UNSET;
 	core->new_rate = CLK_RATE_UNSET;
 
 	/*

-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ