[PATCH] clk: allow to skip clk_core_req_round_rate_nolock()

From: Jan Dakinevich
Date: Fri Jan 26 2024 - 15:15:16 EST


Calling of clk_core_req_round_rate_nolock() can be time-consuming in a
case of deep hierarchy with multiple dividers/parents. But if the clock
already has exactly the same rate as desired, there is no need to
determine how it could be rounded.

Signed-off-by: Jan Dakinevich <jan.dakinevich@xxxxxxxxxxxxxxxxx>
---
drivers/clk/clk.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 2253c154a824..04f0ddced932 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2423,6 +2423,12 @@ static int clk_core_set_rate_nolock(struct clk_core *core,
if (!core)
return 0;

+ /* skip calculation of rounded rate if the clock already has exactly
+ * the same rate as desired
+ */
+ if (req_rate == clk_core_get_rate_nolock(core))
+ return 0;
+
rate = clk_core_req_round_rate_nolock(core, req_rate);

/* bail early if nothing to do */
--
2.34.1