public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: allow to skip clk_core_req_round_rate_nolock()
@ 2024-01-26 20:14 Jan Dakinevich
  2024-02-20 17:34 ` Jan Dakinevich
  2024-02-22 23:20 ` Stephen Boyd
  0 siblings, 2 replies; 6+ messages in thread
From: Jan Dakinevich @ 2024-01-26 20:14 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, linux-clk, linux-kernel
  Cc: kernel, Jan Dakinevich

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@salutedevices.com>
---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-09 21:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-26 20:14 [PATCH] clk: allow to skip clk_core_req_round_rate_nolock() Jan Dakinevich
2024-02-20 17:34 ` Jan Dakinevich
2024-02-22 23:20 ` Stephen Boyd
2024-02-23 21:47   ` Jan Dakinevich
2024-02-29  2:16     ` Stephen Boyd
2024-03-09 21:20       ` Jan Dakinevich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox