[PATCH v3 0/4] Fix clk-divider rates above 4.29 GHz on 64-bit
From: Carlo Caione
Date: Thu Nov 19 2026 - 15:50:26 EST
On 64-bit platforms, the clk-divider truncates requested rates above
4.29 GHz when computing a divisor. Fix it and add KUnit tests.
Sebastian Reichel fixed this in 2023 [1], but later versions moved to a
new generic macro and were never applied. Patch 1 builds on his v1 and
rounds up with (parent_rate - 1) / rate + 1, which does not overflow
with clk_round_rate(clk, ULONG_MAX). Patch 2 fixes a division by zero
found by the new tests. Patch 3 stops truncating divisors to int.
[1] https://lore.kernel.org/linux-clk/20230519190522.194729-3-sebastian.reichel@xxxxxxxxxxxxx/
---
Changes in v3:
- Add review tags to patches 1 and 2
- New patch 3: don't truncate divisors to int (Brian, Jerome)
- Patch 4: also test divisors above INT_MAX
- Patch 4: round with clk_round_rate(), clk_hw_round_rate() needs the
prepare lock (Brian)
- Patch 4: run the power-of-two ULONG_MAX test on 32-bit too (Brian)
- Link to v2: https://patch.msgid.link/20261112-upstream-clk-divider-large-rates-v2-0-18f3bb888b0c@xxxxxxxxxxxx
Changes in v2:
- Patch 1: round up with (parent_rate - 1) / rate + 1, as
DIV64_U64_ROUND_UP() overflows with clk_round_rate(clk, ULONG_MAX)
(Jerome, David)
- New patch 2: fix a division by zero in round-closest dividers
- Patch 3: also test the maximum rate (Brian) and rates above the parent
- Link to v1: https://patch.msgid.link/20261102-upstream-clk-divider-large-rates-v1-0-eb17035bfad2@xxxxxxxxxxxx
---
Carlo Caione (4):
clk: divider: Fix the divisor for rates above 4.29 GHz
clk: divider: Fix round-closest for rates above the parent rate
clk: divider: Don't truncate divisors to int
clk: divider: test: Add tests for rates above 4.29 GHz
drivers/clk/clk-divider.c | 93 ++++++----
drivers/clk/clk-divider_test.c | 394 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 449 insertions(+), 38 deletions(-)
---
base-commit: ab94dbf302331eed3679e262e1d8d1a73f308640
change-id: 20261102-upstream-clk-divider-large-rates-872467864e39
Best regards,
--
Carlo Caione <ccaione@xxxxxxxxxxxx>