Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52DFA606A323 for ; Sun, 29 Nov 2026 10:49:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oM26tzO+ Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD2BB10E4B2; Sun, 29 Nov 2026 10:49:36 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7C4D110E22C for ; Sun, 29 Nov 2026 10:49:30 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 0AF7943D1D; Sun, 29 Nov 2026 10:49:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCDC71F00896; Sun, 29 Nov 2026 10:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795949369; bh=Y8YKwDW928kEQTljeXAtsWAXfe1PHwxuMzIz+nDqx0Y=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=oM26tzO+kUWYE0nw1IAUj8MSwDjzO4R9bvIn3NPfwoC3IDme8LdZrZn/hFMjcSqwN +v9653uNboVgnTDzLAk7MIhHWmKWl8H/HVYJPlx+nn6IGAep6jBesHLb8PgbAFQej9 aSD9mgZm8/QTgt4mEkbX70ZvTcmyc42foQ/c8gNp/Kyx5h+SncQ7iv2kgMOBUh6lkQ ILvTZUNs/TgLh5/3sD5YDVmAOKh+x81+LFg1lVj+2ZfDAAty88fm3VJbo13KOQ8C1O pyz6RDXFhShoOTD2Ww7p8M9brNLXyx2QStQJzK2bzc9qqFMk2Pcdz0Q8+BjiIDQoVg hoh+H7sJR364g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] drm/msm/dsi: phy_28nm: return exact PLL-achievable VCO rate in determine_rate To: "Vladimir Bely" Cc: dri-devel@lists.freedesktop.org In-Reply-To: <20261129103004.357862-1-vlwwwwww@gmail.com> References: <20261129103004.357862-1-vlwwwwww@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 10:49:29 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/msm/dsi: upward VCO rounding in dsi_pll_28nm_calc_vco_rate() breaks RCG/PLL -- commit 04136cd645856db1e70c20fc070ead60e3649cdf Author: Vladimir Bely drm/msm/dsi: phy_28nm: return exact PLL-achievable VCO rate in determine_ra= te This commit updates dsi_pll_28nm_clk_determine_rate() and dsi_pll_28nm_clk_set_rate() to compute the 16-bit fractional-N divider and resulting VCO rate via a shared dsi_pll_28nm_calc_vco_rate() helper, and enables closest-rate rounding on analog_postdiv and byte_mux. > diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c b/drivers/gpu/drm= /msm/dsi/phy/dsi_phy_28nm.c > index d00e415b9a991..2d4a29b546c18 100644 > --- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c > +++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c > @@ -114,31 +115,101 @@ static void pll_28nm_software_reset(struct dsi_pll= _28nm *pll_28nm) > /* > * Clock Callbacks > */ > +static unsigned long dsi_pll_28nm_calc_vco_rate(struct dsi_pll_28nm *pll= _28nm, > + unsigned long rate, > + u32 *div_fb, u32 *frac_n, > + bool *frac_n_mode) > +{ > + unsigned long min_rate =3D pll_28nm->phy->cfg->min_pll_rate; > + unsigned long max_rate =3D pll_28nm->phy->cfg->max_pll_rate; > + unsigned long actual; > + u32 ref_clk, div, frac; > + > + rate =3D clamp_t(unsigned long, rate, min_rate, max_rate); > + > + if (rate % VCO_REF_CLK_RATE =3D=3D 0) { > + if (frac_n_mode) > + *frac_n_mode =3D false; > + if (div_fb) > + *div_fb =3D rate / VCO_REF_CLK_RATE; > + if (frac_n) > + *frac_n =3D 0; > + return rate; > + } > + > + ref_clk =3D VCO_REF_CLK_RATE * 2; > + div =3D rate / ref_clk; > + frac =3D DIV_ROUND_CLOSEST_ULL((u64)(rate % ref_clk) << 16, ref_clk); [ ... ] > @@ -650,7 +704,7 @@ static int pll_28nm_register(struct dsi_pll_28nm *pll= _28nm, struct clk_hw **prov > &pll_28nm->clk_hw, CLK_SET_RATE_PARENT, > pll_28nm->phy->pll_base + > REG_DSI_28nm_PHY_PLL_POSTDIV1_CFG, > - 0, 4, 0, NULL); > + 0, 4, CLK_DIVIDER_ROUND_CLOSEST, NULL); > if (IS_ERR(analog_postdiv)) > return PTR_ERR(analog_postdiv); > =20 > @@ -675,7 +729,8 @@ static int pll_28nm_register(struct dsi_pll_28nm *pll= _28nm, struct clk_hw **prov > &pll_28nm->clk_hw, > indirect_path_div2, > }), 2, CLK_SET_RATE_PARENT, pll_28nm->phy->pll_base + > - REG_DSI_28nm_PHY_PLL_VREG_CFG, 1, 1, 0, NULL); > + REG_DSI_28nm_PHY_PLL_VREG_CFG, 1, 1, > + CLK_MUX_ROUND_CLOSEST, NULL); > if (IS_ERR(byte_mux)) > return PTR_ERR(byte_mux); [Severity: High] Can rounding frac up with DIV_ROUND_CLOSEST_ULL() in dsi_pll_28nm_calc_vco_rate(), combined with CLK_DIVIDER_ROUND_CLOSEST and CLK_MUX_ROUND_CLOSEST, cause the downstream byte and pixel RCGs to pick the wrong dividers when the VCO rate rounds above the requested rate? Whenever rate % ref_clk lies in the upper half of an SDM step, dsi_pll_28nm_calc_vco_rate() returns an actual VCO rate up to 292 Hz above the requested rate. With closest-rate rounding enabled on analog_postdiv and byte_mux, dsiNpllbyte can return parent_rate > rate to the downstream byte RCG: drivers/clk/qcom/clk-rcg2.c:clk_byte2_determine_rate() { p =3D req->best_parent_hw; req->best_parent_rate =3D parent_rate =3D clk_hw_round_rate(p, rate); div =3D DIV_ROUND_UP((2 * parent_rate), rate) - 1; div =3D min_t(u32, div, mask); req->rate =3D calc_rate(parent_rate, 0, 0, 0, div); } When parent_rate exceeds rate by even 1 Hz, DIV_ROUND_UP(2 * parent_rate, rate) - 1 jumps from 1 (1:1 bypass) to 2 (a 1.5x pre-divider), so clk_round_rate(msm_host->byte_clk, ...) drops msm_host->byte_clk_rate to 2/3 of the target panel byte clock (for example, on s6d7aa0_lsl080al02_mode where byte_clk_rate is 55986750 Hz, VCO rounds up by 140 Hz to 447894140 Hz, dsi0pllbyte returns 55986767 Hz, and the byte RCG drops to 37324511 Hz). In addition, dsiNpll (REG_DSI_28nm_PHY_PLL_POSTDIV3_CFG) is registered in pll_28nm_register() without CLK_DIVIDER_ROUND_CLOSEST. When the VCO is rounded up even by 1 Hz above M * pixel_clk_rate, dsiNpll's _div_round_up() increments the POSTDIV3 divider from M to M + 1, causing clk_pixel_determine_rate() to miss the 100 kHz delta window and fail clk_set_rate(msm_host->pixel_clk, ...) with -EINVAL. Truncating frac downward instead of using DIV_ROUND_CLOSEST_ULL() keeps the achieved VCO rate at or below the target rate while still matching recalc_rate() once clk_round_rate() has quantized byte_clk_rate. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129103004.3578= 62-1-vlwwwwww@gmail.com?part=3D1