Skip to content

Commit facf949

Browse files
mripardbebarino
authored andcommitted
clk: Skip clamping when rounding if there's no boundaries
Commit 948fb09 ("clk: Always clamp the rounded rate") recently started to clamp the request rate in the clk_rate_request passed as an argument of clk_core_determine_round_nolock() with the min_rate and max_rate fields of that same request. While the clk_rate_requests created by the framework itself always have those fields set, some drivers will create it themselves and don't always fill min_rate and max_rate. In such a case, we end up clamping the rate with a minimum and maximum of 0, thus always rounding the rate to 0. Let's skip the clamping if both min_rate and max_rate are set to 0 and complain so that it gets fixed. Fixes: 948fb09 ("clk: Always clamp the rounded rate") Signed-off-by: Maxime Ripard <[email protected]> Link: https://lore.kernel.org/r/[email protected] Tested-by: Linux Kernel Functional Testing <[email protected]> Tested-by: Naresh Kamboju <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent d773882 commit facf949

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

drivers/clk/clk.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,19 @@ static int clk_core_determine_round_nolock(struct clk_core *core,
13411341
if (!core)
13421342
return 0;
13431343

1344-
req->rate = clamp(req->rate, req->min_rate, req->max_rate);
1344+
/*
1345+
* Some clock providers hand-craft their clk_rate_requests and
1346+
* might not fill min_rate and max_rate.
1347+
*
1348+
* If it's the case, clamping the rate is equivalent to setting
1349+
* the rate to 0 which is bad. Skip the clamping but complain so
1350+
* that it gets fixed, hopefully.
1351+
*/
1352+
if (!req->min_rate && !req->max_rate)
1353+
pr_warn("%s: %s: clk_rate_request has initialized min or max rate.\n",
1354+
__func__, core->name);
1355+
else
1356+
req->rate = clamp(req->rate, req->min_rate, req->max_rate);
13451357

13461358
/*
13471359
* At this point, core protection will be disabled

0 commit comments

Comments
 (0)