From: Heiko Stuebner <heiko@sntech.de>
To: Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Alexey Charkov <alchark@flipper.net>
Cc: Pavel Zhovner <pavel@flipper.net>,
Sebastian Reichel <sebastian.reichel@collabora.com>,
Andy Yan <andy.yan@rock-chips.com>,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-clk@vger.kernel.org, Alexey Charkov <alchark@flipper.net>
Subject: Re: [PATCH RFC 2/4] clk: rockchip: pll: use round-nearest in determine_rate
Date: Sat, 18 Apr 2026 00:59:40 +0200 [thread overview]
Message-ID: <39479281.XM6RcZxFsP@phil> (raw)
In-Reply-To: <20260417-rk3576-dclk-v1-2-26a9d0dcb2de@flipper.net>
Hi Alexey,
Am Freitag, 17. April 2026, 17:11:45 Mitteleuropäische Sommerzeit schrieb Alexey Charkov:
> rockchip_pll_determine_rate() walks the rate table in descending order
> and picks the first entry <= the requested rate. This floor-rounding
> interacts poorly with consumers that use CLK_SET_RATE_PARENT: a divider
> iterating candidates asks the PLL for rate*div, and a tiny undershoot
> causes the PLL to snap to a much lower entry.
>
> For example, requesting 1991.04 MHz (248.88 MHz * 8) causes the PLL to
> return 1968 MHz instead of 1992 MHz — a 24 MHz table gap that produces
> a 1.2% pixel clock error when divided back down.
>
> Change to round-to-nearest: for each table entry compute the absolute
> distance from the request, and pick the entry with the smallest delta.
> The CCF's divider and composite logic handle over/undershoot preferences
> via their own ROUND_CLOSEST flags.
>
> Signed-off-by: Alexey Charkov <alchark@flipper.net>
as Sebastian said, this could cause overclocking in a number of areas.
The rate you get should always be lower or equal to the requested rate.
Additionally, such a core behaviour change, would affect 13 years of
SoCs with unknown side-effects.
If you're missing specific clock rates, you can always add them to the
list :-) . The vendor-kernel does have code that can calculate the
rate params itself, so this could give you a hint where to start.
======= just to explain =======
Though I still don't think that code should be in the mainline-kernel,
as a curated PLL rates allows more control, where that algorithm
creates parameters that are programmatically correct, but essentially
untested.
On the two Chromebook projects, they actually measured things like
clock jitter, which got us more specific params for some rates.
Heiko
next prev parent reply other threads:[~2026-04-17 22:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-17 15:11 [PATCH RFC 0/4] arm64: rockchip: The hunt for exact pixel clocks on RK3576 Alexey Charkov
2026-04-17 15:11 ` [PATCH RFC 1/4] arm64: dts: rockchip: rk3576: assign dclk_vp1_src to VPLL Alexey Charkov
2026-04-17 15:11 ` [PATCH RFC 2/4] clk: rockchip: pll: use round-nearest in determine_rate Alexey Charkov
2026-04-17 22:59 ` Heiko Stuebner [this message]
2026-04-17 15:11 ` [PATCH RFC 3/4] clk: rockchip: rk3576: allow dclk_vp1_src to propagate rate to parent PLL Alexey Charkov
2026-04-17 15:11 ` [PATCH RFC 4/4] clk: rockchip: rk3576: add ROUND_CLOSEST to dclk_vp1_src divider Alexey Charkov
2026-04-17 22:24 ` [PATCH RFC 0/4] arm64: rockchip: The hunt for exact pixel clocks on RK3576 Sebastian Reichel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=39479281.XM6RcZxFsP@phil \
--to=heiko@sntech.de \
--cc=alchark@flipper.net \
--cc=andy.yan@rock-chips.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mturquette@baylibre.com \
--cc=pavel@flipper.net \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=sebastian.reichel@collabora.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox