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 <[email protected]>

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/[email protected]?part=1

Reply via email to