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 A3390606A336 for ; Sun, 29 Nov 2026 11:40:28 +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=lwyoN3y3 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DB4E310E785; Sun, 29 Nov 2026 11:40:22 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id C1D9110E785 for ; Sun, 29 Nov 2026 11:40:16 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 7DBA94383F; Sun, 29 Nov 2026 11:40:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A33E1F0089C; Sun, 29 Nov 2026 11:40:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795952416; bh=sqKHxvfOXcfHbbXrXPTmQLPrC9qYSJoL6Ex9AIWuW/U=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=lwyoN3y3e6EoclgNo1c6RUPo6JfCPsPHIre2uLxsvdQ148ytf2RRSLgAR9qY+RRAr ra1dJn+NWkMwJsfr6B67hP2WkynEKRYc30O6gWsPAxuR1vcVubIHJj412D9FjCd8hR zRDzN8ZKdldGA4syGX+es1AIzBptAD8xI4pNRrKIXR1wmlJcKvNyEOeUPun/X5IpIh 9fYrA0YV+kU0MeoLVL2QuHoG7hAJjKdNCNX58gutvJneTu9M2hfeMgn8xbikgr7INo 55bk6byyoRUww69/kdEaHjvcn2nyhcJdP9jjW9yuMuRJ/FobK1TcHcCuGle+IaZkpv Llckyf/1Ue2ZA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] 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: <20261129112408.533583-1-vlwwwwww@gmail.com> References: <20261129112408.533583-1-vlwwwwww@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 11:40:15 +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: byte divider remainder inflation breaks pixel clock rounding -- commit 29c58c6743bba124f527b7bc99228a489fbd21db Author: Vladimir Bely drm/msm/dsi: phy_28nm: return exact PLL-achievable VCO rate in determine_ra= te This commit quantizes the 28nm DSI PHY PLL VCO rate downward to the fractional-N SDM grid in determine_rate() and set_rate(), and replaces the byte-clock path dividers with custom clk_ops that propagate integer-division remainders upstream. > 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..61258f76a215e 100644 > --- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c > +++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c [ ... ] > @@ -615,6 +682,121 @@ static int dsi_28nm_pll_restore_state(struct msm_ds= i_phy *phy) > return 0; > } > =20 > +static unsigned long dsi_pll_28nm_fixed_div_recalc_rate(struct clk_hw *h= w, > + unsigned long parent_rate) > +{ > + struct dsi_pll_28nm_fixed_div *fdiv =3D to_pll_28nm_fixed_div(hw); > + > + return parent_rate / fdiv->div; > +} > + > +static int dsi_pll_28nm_fixed_div_determine_rate(struct clk_hw *hw, > + struct clk_rate_request *req) > +{ > + struct dsi_pll_28nm_fixed_div *fdiv =3D to_pll_28nm_fixed_div(hw); > + struct clk_hw *parent =3D clk_hw_get_parent(hw); > + unsigned long parent_req; > + > + if (!parent) > + return -EINVAL; > + > + /* Include remainder so floor(parent / div) stays idempotent */ > + if (req->rate > (ULONG_MAX - (fdiv->div - 1)) / fdiv->div) > + parent_req =3D ULONG_MAX; > + else > + parent_req =3D req->rate * fdiv->div + fdiv->div - 1; > + > + req->best_parent_rate =3D clk_hw_round_rate(parent, parent_req); > + req->rate =3D req->best_parent_rate / fdiv->div; > + > + return 0; > +} > + > +static int dsi_pll_28nm_fixed_div_set_rate(struct clk_hw *hw, > + unsigned long rate, > + unsigned long parent_rate) > +{ > + return 0; > +} > + > +static const struct clk_ops dsi_pll_28nm_fixed_div_ops =3D { > + .recalc_rate =3D dsi_pll_28nm_fixed_div_recalc_rate, > + .determine_rate =3D dsi_pll_28nm_fixed_div_determine_rate, > + .set_rate =3D dsi_pll_28nm_fixed_div_set_rate, > +}; > + > +static unsigned long dsi_pll_28nm_postdiv1_recalc_rate(struct clk_hw *hw, > + unsigned long parent_rate) > +{ > + struct dsi_pll_28nm_postdiv1 *pdiv =3D to_pll_28nm_postdiv1(hw); > + u32 div =3D (readl(pdiv->reg) & 0xf) + 1; > + > + return parent_rate / div; > +} > + > +static int dsi_pll_28nm_postdiv1_determine_rate(struct clk_hw *hw, > + struct clk_rate_request *req) > +{ > + struct clk_hw *parent =3D clk_hw_get_parent(hw); > + unsigned long best_rate =3D 0, best_parent =3D 0; > + unsigned long rate =3D req->rate ?: 1; > + u32 d; > + > + if (!parent) > + return -EINVAL; > + > + for (d =3D 1; d <=3D 16; d++) { > + unsigned long parent_req, p_rate, now; > + > + if (rate > (ULONG_MAX - (d - 1)) / d) > + parent_req =3D ULONG_MAX; > + else > + parent_req =3D rate * d + d - 1; > + > + p_rate =3D clk_hw_round_rate(parent, parent_req); > + now =3D p_rate / d; > + if (now <=3D rate && now > best_rate) { > + best_rate =3D now; > + best_parent =3D p_rate; > + } > + } [Severity: High] Can adding the division remainder (rate * div + div - 1) across dsiNpllbyte, dsiNindirect_path_div2_clk, and dsiNanalog_postdiv_clk push the selected VCO rate above the ideal pixel-clock multiple and cause clk_set_rate(msm_host->pixel_clk, ...) to fail with -EINVAL? On the first clk_round_rate(msm_host->byte_clk, B_0) call on the indirect path, dsiNpllbyte (div =3D 4) and dsiNindirect_path_div2_clk (div =3D 2) inflate B_0 to rate =3D 8 * B_0 + 7 at dsiNanalog_postdiv_clk, which then requests parent_req =3D 8 * d * B_0 + (8 * d - 1) from the VCO and compares now =3D p_rate / d against the inflated rate =3D 8 * B_0 + 7. Whenever an = SDM step falls in [8 * d * B_0 + 1, 8 * d * B_0 + 8 * d - 1] (for example, a 4-lane RGB888 panel at 32018 kHz pixel clock / B_0 =3D 24013500 Hz, where d =3D 3 hits an exact SDM step at 576324023 Hz, 23 Hz above 18 * 32018000 H= z), the VCO locks slightly above M * pixel_clk_rate while floor(p_rate / (8 * d= )) still truncates back to B_0. Because dsiNpll (POSTDIV3) is registered as a default clk_divider with flags =3D 0, _div_round_up() rounds the POSTDIV3 divider up from M to M + 1 when clk_pixel_determine_rate() queries it, missing pixel_clk_rate by several MHz and failing every frac_table_pixel entry with -EINVAL during modeset. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129112408.5335= 83-1-vlwwwwww@gmail.com?part=3D1