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-next>] [day] [month] [year] [list]
Message-Id: <20231026063941.1882023-1-peng.fan@oss.nxp.com>
Date:   Thu, 26 Oct 2023 14:39:41 +0800
From:   "Peng Fan (OSS)" <peng.fan@....nxp.com>
To:     sboyd@...nel.org, abelvesa@...nel.org, mturquette@...libre.com
Cc:     clement.leger@...tlin.com, sudeep.holla@....com,
        cristian.marussi@....com, kernel@...gutronix.de,
        geert+renesas@...der.be, pure.logic@...us-software.ie,
        a.fatoum@...gutronix.de, aford173@...il.com, absahu@...eaurora.org,
        linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org,
        Peng Fan <peng.fan@....com>
Subject: [PATCH] clk: clk-conf: bypass setting rate/parent if already same

From: Peng Fan <peng.fan@....com>

If the original rate and parent is already the same as what users
wanna to configure through assigned clock rate and parent, there
is no need to configure them again which may cause more cpu cycles
or more SCMI RPC calls.

So check the rate and parent first, and bypass when the original
rate and parent are same as requested by device tree node.

Signed-off-by: Peng Fan <peng.fan@....com>
---
 drivers/clk/clk-conf.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk-conf.c b/drivers/clk/clk-conf.c
index 1a4e6340f95c..c9ff4fcc8875 100644
--- a/drivers/clk/clk-conf.c
+++ b/drivers/clk/clk-conf.c
@@ -65,7 +65,11 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier)
 			goto err;
 		}
 
-		rc = clk_set_parent(clk, pclk);
+		if (__clk_get_hw(pclk) != __clk_get_hw(clk_get_parent(clk)))
+			rc = clk_set_parent(clk, pclk);
+		else
+			rc = 0;
+
 		if (rc < 0)
 			pr_err("clk: failed to reparent %s to %s: %d\n",
 			       __clk_get_name(clk), __clk_get_name(pclk), rc);
@@ -112,7 +116,10 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier)
 				return PTR_ERR(clk);
 			}
 
-			rc = clk_set_rate(clk, rate);
+			if (clk_get_rate(clk) != rate)
+				rc = clk_set_rate(clk, rate);
+			else
+				rc = 0;
 			if (rc < 0)
 				pr_err("clk: couldn't set %s clk rate to %u (%d), current rate: %lu\n",
 				       __clk_get_name(clk), rate, rc,
-- 
2.37.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ