Re: [PATCH] clk: sunxi-ng: nkm: avoid 32-bit overflow in rate calculations
From: Chen-Yu Tsai
Date: Sun Nov 15 2026 - 03:33:25 EST
On Sun, 01 Nov 2026 21:33:36 +0100, Romain TISSERAND wrote:
> The N-K-M rate code computes parent * n * k / m in an unsigned long,
> which wraps on 32-bit ARM as soon as parent * n * k passes 4.29 GHz.
>
> On the A33, pll-mipi (parent pll-video at 297 MHz) with N = 14, K = 2,
> M = 14 runs at 594 MHz, but 297 MHz * 14 * 2 wraps around to
> 4021032704 and the code computes 287.2 MHz. ccu_nkm_find_best() then
> picks these factors for a 288 MHz request, and clk_get_rate() reports
> 287.2 MHz while the PLL runs at twice that. On a PocketGo S30 (A33,
> ILI9488 panel on one MIPI-DSI lane) the lane ended up at about
> 594 Mbit/s instead of 288 and the picture broke up.
>
> [...]
Applied to sunxi/clk-for-7.5 in sunxi, thanks!
[1/1] clk: sunxi-ng: nkm: avoid 32-bit overflow in rate calculations
https://git.kernel.org/sunxi/linux/c/e9d9dae0d248
Best regards,
--
Chen-Yu Tsai <wens@xxxxxxxxxx>