[PATCH 1/2] clk: divider: Fix the divisor for rates above 4.29 GHz

From: Carlo Caione

Date: Mon Nov 02 2026 - 16:07:50 EST


From: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>

DIV_ROUND_UP_ULL() takes a 32-bit divisor, so on 64-bit platforms a
requested rate above 4.29 GHz is truncated. A divider fed by a 5.94 GHz
PLL then computes a divisor of 7, not 1, for 5.94 GHz.

Use DIV64_U64_ROUND_UP(), which takes a 64-bit divisor.

Fixes: 9556f9dad8f5 ("clk: divider: handle integer overflow when dividing large clock rates")
Signed-off-by: Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>
Signed-off-by: Carlo Caione <ccaione@xxxxxxxxxxxx>
---
drivers/clk/clk-divider.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index f68216c65d3d..a446abdedcd7 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -227,7 +227,7 @@ static int _div_round_up(const struct clk_div_table *table,
unsigned long parent_rate, unsigned long rate,
unsigned long flags)
{
- int div = DIV_ROUND_UP_ULL((u64)parent_rate, rate);
+ int div = DIV64_U64_ROUND_UP(parent_rate, rate);

if (flags & CLK_DIVIDER_POWER_OF_TWO)
div = __roundup_pow_of_two(div);
@@ -244,7 +244,7 @@ static int _div_round_closest(const struct clk_div_table *table,
int up, down;
unsigned long up_rate, down_rate;

- up = DIV_ROUND_UP_ULL((u64)parent_rate, rate);
+ up = DIV64_U64_ROUND_UP(parent_rate, rate);
down = parent_rate / rate;

if (flags & CLK_DIVIDER_POWER_OF_TWO) {
@@ -423,7 +423,7 @@ int divider_get_val(unsigned long rate, unsigned long parent_rate,
{
unsigned int div, value;

- div = DIV_ROUND_UP_ULL((u64)parent_rate, rate);
+ div = DIV64_U64_ROUND_UP(parent_rate, rate);

if (!_is_valid_div(table, div, flags))
return -EINVAL;

--
2.56.0