[PATCH v2 0/3] Fix clk-divider rates above 4.29 GHz on 64-bit

From: Carlo Caione

Date: Thu Nov 12 2026 - 04:44:04 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.

[1] https://lore.kernel.org/linux-clk/20230519190522.194729-3-sebastian.reichel@xxxxxxxxxxxxx/

---
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 (3):
clk: divider: Fix the divisor for rates above 4.29 GHz
clk: divider: Fix round-closest for rates above the parent rate
clk: divider: test: Add tests for rates above 4.29 GHz

drivers/clk/clk-divider.c | 21 +++-
drivers/clk/clk-divider_test.c | 244 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 260 insertions(+), 5 deletions(-)
---
base-commit: ab94dbf302331eed3679e262e1d8d1a73f308640
change-id: 20261102-upstream-clk-divider-large-rates-872467864e39

Best regards,
--
Carlo Caione <ccaione@xxxxxxxxxxxx>