All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vladimir Bely" <vlwwwwww@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3] drm/msm/dsi: phy_28nm: return exact PLL-achievable VCO rate in determine_rate
Date: Sun, 29 Nov 2026 13:12:24 +0000	[thread overview]
Message-ID: <sashiko-outbox-239624@kernel.org> (raw)
In-Reply-To: <20261129125821.568347-1-vlwwwwww@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/msm/dsi: division by zero in _div_round_closest() via
  pll_28nm_register()
--

commit 52a15dbdf183d3a688367577bd32f85958b8b480
Author: Vladimir Bely <vlwwwwww@gmail.com>

drm/msm/dsi: phy_28nm: return exact PLL-achievable VCO rate in determine_rate

This commit quantizes VCO rate calculations in the 28nm DSI PHY PLL to
the SDM fractional-N grid, propagates integer-division remainders through
the byte-clock divider path, and enables CLK_DIVIDER_ROUND_CLOSEST on
dsiNpll (POSTDIV3).

> 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..abc30c76399dc 100644
> --- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c
> +++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c

[ ... ]

> @@ -646,25 +846,25 @@ static int pll_28nm_register(struct dsi_pll_28nm *pll_28nm, struct clk_hw **prov

[ ... ]

>  	snprintf(clk_name, sizeof(clk_name), "dsi%dpll", pll_28nm->phy->id);
>  	hw = devm_clk_hw_register_divider_parent_hw(dev, clk_name,
>  			&pll_28nm->clk_hw, 0, pll_28nm->phy->pll_base +
>  				REG_DSI_28nm_PHY_PLL_POSTDIV3_CFG,
> -			0, 8, 0, NULL);
> +			0, 8, CLK_DIVIDER_ROUND_CLOSEST, NULL);
>  	if (IS_ERR(hw))
>  		return PTR_ERR(hw);
>  	provided_clocks[DSI_PIXEL_PLL_CLK] = hw;

[Severity: High]
Can enabling CLK_DIVIDER_ROUND_CLOSEST on dsiNpll without
CLK_SET_RATE_PARENT or a divider table trigger a division by zero in
_div_round_closest()?

During clk_set_rate(msm_host->pixel_clk, ...), clk_pixel_determine_rate()
iterates through frac_table_pixel (such as { 2, 9 }) and calls
clk_hw_round_rate() on dsiNpll with request = 4.5 * pixel_clk_rate.  On
any mode where the VCO rate is below 4.5 * pixel_clk_rate (for example, a
4-lane RGB888 panel on the direct byte-mux path where VCO is 3 *
pixel_clk_rate), rate > parent_rate reaches _div_round_closest() with
down == 0:

drivers/clk/clk-divider.c:_div_round_closest() {
	up = DIV_ROUND_UP_ULL((u64)parent_rate, rate);
	down = parent_rate / rate;

	if (flags & CLK_DIVIDER_POWER_OF_TWO) {
		up = __roundup_pow_of_two(up);
		down = __rounddown_pow_of_two(down);
	} else if (table) {
		up = _round_up_table(table, up);
		down = _round_down_table(table, down);
	}

	up_rate = DIV_ROUND_UP_ULL((u64)parent_rate, up);
	down_rate = DIV_ROUND_UP_ULL((u64)parent_rate, down);
}

DIV_ROUND_UP_ULL((u64)parent_rate, down) then divides by zero, invoking
__div0() on 32-bit ARM platforms or a UBSAN division-by-zero splat on
every modeset and runtime DSI transfer.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261129125821.568347-1-vlwwwwww@gmail.com?part=1

      reply	other threads:[~2026-11-29 13:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 12:58 [PATCH v3] drm/msm/dsi: phy_28nm: return exact PLL-achievable VCO rate in determine_rate Vladimir Bely
2026-11-29 13:12 ` sashiko-bot [this message]

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=sashiko-outbox-239624@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vlwwwwww@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.