From: Quentin Schulz <quentin.schulz@cherry.de>
To: Chaoyi Chen <kernel@airkyi.com>,
Alexey Charkov <alchark@flipper.net>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney@redhat.com>,
Heiko Stuebner <heiko@sntech.de>,
Sebastian Reichel <sebastian.reichel@collabora.com>,
Finley Xiao <finley.xiao@rock-chips.com>,
Elaine Zhang <zhangqing@rock-chips.com>,
Detlev Casanova <detlev.casanova@collabora.com>,
Sugar Zhang <sugar.zhang@rock-chips.com>,
YouMin Chen <cym@rock-chips.com>,
Wyon Bi <bivvy.bi@rock-chips.com>
Cc: Dragan Simic <dsimic@manjaro.org>, Liang Chen <cl@rock-chips.com>,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] clk: rockchip: pll: Fix the fractional part denominator on RK3588/RK3576
Date: Thu, 23 Jul 2026 12:44:54 +0200 [thread overview]
Message-ID: <fecf49e0-e13c-41e6-92eb-ef56c9afa0be@cherry.de> (raw)
In-Reply-To: <5676B227B50EB88B+ff62bc9e-5175-481a-93f8-c1de7f68eba2@airkyi.com>
Hi Chaoyi,
On 7/23/26 12:32 PM, Chaoyi Chen wrote:
> Hello Alexey,
>
> On 7/23/2026 6:21 PM, Alexey Charkov wrote:
>> According to the TRM, the fractional PLL coefficient should be divided by
>> 65536 rather than 65535 to obtain the output rate.
>>
>> Fix the denominator and add a comment with the TRM provided clock formulae
>> for future reference.
>>
>> See RK3576 TRM Part 1 V1.2 section 2.13.1.4 Setting Guide on P, M, S and K
>> or equivalently RK3588 TRM part 1 V1.0 section 2.17.1.4 Setting Guide on P,
>> M, S and K.
>>
>> Fractional PLL rates don't seem to be used by any current mainline
>> consumers, so this is purely a correctness fix. It will also be important
>> to properly support DisplayPort output going forward, as the video output
>> controller derives its pixel clock from system PLLs with no dedicated PHY
>> PLL option for DP unlike HDMI, and some display modes are only achievable
>> with fractional PLL rates.
>>
>> Fixes: 8f6594494b1c ("clk: rockchip: add pll type for RK3588")
>> Signed-off-by: Alexey Charkov <alchark@flipper.net>
>> ---
>> drivers/clk/rockchip/clk-pll.c | 9 ++++++++-
>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c
>> index 6b853800cb6b..bf8acf7cee0d 100644
>> --- a/drivers/clk/rockchip/clk-pll.c
>> +++ b/drivers/clk/rockchip/clk-pll.c
>> @@ -900,6 +900,13 @@ static void rockchip_rk3588_pll_get_params(struct rockchip_clk_pll *pll,
>> rate->k = ((pllcon >> RK3588_PLLCON2_K_SHIFT) & RK3588_PLLCON2_K_MASK);
>> }
>>
>> +/*
>> + * 2250 MHz <= Fvco <= 4500 MHz
>> + * For Fvco > 3 GHz: period jitter +-1% frac PLL, +-0.75% int PLL
>> + * For Fvco < 3 GHz: period jitter +-2% frac PLL, +-1.50% int PLL
>> + * Fvco = ((m + k / 65536) * Fin) / p
>> + * Fout = ((m + k / 65536) * Fin) / (p * 2^s)
>> + */
>> static unsigned long rockchip_rk3588_pll_recalc_rate(struct clk_hw *hw, unsigned long prate)
>> {
>> struct rockchip_clk_pll *pll = to_rockchip_clk_pll(hw);
>> @@ -915,7 +922,7 @@ static unsigned long rockchip_rk3588_pll_recalc_rate(struct clk_hw *hw, unsigned
>> /* fractional mode */
>> u64 frac_rate64 = prate * cur.k;
>>
>> - postdiv = cur.p * 65535;
>> + postdiv = cur.p * 65536;
>
>
> How about using 65536ULL? Will the multiplication here overflow?
>
cur.p is an unsigned int. p comes from the HW register directly and it's
masked with 0x3f so it can be max 63 * 65536 which is well below
UINT_MAX and also below U64_MAX so should be fine. It could overflow if
it's set wrong in the static table we have in the driver, but then in
any case we would write something that cannot work in registers (as it's
masked when being written and wouldn't match the value set in the table).
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
Thanks!
Quentin
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
next prev parent reply other threads:[~2026-07-23 10:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 10:21 [PATCH v2 0/2] Fix RK3576/RK3588 fractional PLL rate calculation Alexey Charkov
2026-07-23 10:21 ` [PATCH v2 1/2] clk: rockchip: pll: Fix the fractional part denominator on RK3588/RK3576 Alexey Charkov
2026-07-23 10:32 ` Chaoyi Chen
2026-07-23 10:44 ` Quentin Schulz [this message]
2026-07-23 10:21 ` [PATCH v2 2/2] clk: rockchip: Fractional PLL coefficient on RK3588/RK3576 is two's complement Alexey Charkov
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=fecf49e0-e13c-41e6-92eb-ef56c9afa0be@cherry.de \
--to=quentin.schulz@cherry.de \
--cc=alchark@flipper.net \
--cc=bivvy.bi@rock-chips.com \
--cc=bmasney@redhat.com \
--cc=cl@rock-chips.com \
--cc=cym@rock-chips.com \
--cc=detlev.casanova@collabora.com \
--cc=dsimic@manjaro.org \
--cc=finley.xiao@rock-chips.com \
--cc=heiko@sntech.de \
--cc=kernel@airkyi.com \
--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=sboyd@kernel.org \
--cc=sebastian.reichel@collabora.com \
--cc=sugar.zhang@rock-chips.com \
--cc=zhangqing@rock-chips.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