public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: Ensure correct consumer's rate boundaries
@ 2026-01-09  3:24 Chuan Liu via B4 Relay
  2026-01-15  1:30 ` Brian Masney
  0 siblings, 1 reply; 7+ messages in thread
From: Chuan Liu via B4 Relay @ 2026-01-09  3:24 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd; +Cc: linux-clk, linux-kernel, Chuan Liu

From: Chuan Liu <chuan.liu@amlogic.com>

If we were to have two users of the same clock, doing something like:

clk_set_rate_range(user1, 1000, 2000);
clk_set_rate_range(user2, 3000, 4000);

Even when user2's call returns -EINVAL, the min_rate and max_rate of
user2 are still incorrectly updated. This causes subsequent calls by
user1 to fail when setting the clock rate, as clk_core_get_boundaries()
returns corrupted boundaries (min_rate = 3000, max_rate = 2000).

To prevent this, clk_core_check_boundaries() now rollback to the old
boundaries when the check fails.

Signed-off-by: Chuan Liu <chuan.liu@amlogic.com>
---
 drivers/clk/clk.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 85d2f2481acf..0dfb16bf3f31 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2710,13 +2710,17 @@ static int clk_set_rate_range_nolock(struct clk *clk,
 	 */
 	rate = clamp(rate, min, max);
 	ret = clk_core_set_rate_nolock(clk->core, rate);
+
+out:
 	if (ret) {
-		/* rollback the changes */
+		/*
+		 * Rollback the consumer’s old boundaries if check_boundaries or
+		 * set_rate fails.
+		 */
 		clk->min_rate = old_min;
 		clk->max_rate = old_max;
 	}
 
-out:
 	if (clk->exclusive_count)
 		clk_core_rate_protect(clk->core);
 

---
base-commit: 7f98ab9da046865d57c102fd3ca9669a29845f67
change-id: 20260107-fix_error_setting_clk_rate_range-d928da67af90

Best regards,
-- 
Chuan Liu <chuan.liu@amlogic.com>



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

end of thread, other threads:[~2026-01-19 11:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-09  3:24 [PATCH] clk: Ensure correct consumer's rate boundaries Chuan Liu via B4 Relay
2026-01-15  1:30 ` Brian Masney
2026-01-15  2:37   ` Chuan Liu
2026-01-15 13:01     ` Brian Masney
2026-01-16  9:32       ` Chuan Liu
2026-01-16 16:44         ` Brian Masney
2026-01-19 11:56           ` Chuan Liu

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