[PATCH v2] drm/i915/dsi: Fix overflow issue in pclk parsing

Hogander, Jouni jouni.hogander at intel.com
Thu Aug 7 12:10:07 UTC 2025


On Thu, 2025-08-07 at 10:13 +0300, Jani Nikula wrote:
> On Thu, 07 Aug 2025, Jouni Högander <jouni.hogander at intel.com> wrote:
> > Parsed divider p will overflow and is considered being valid in
> > case
> > pll_ctl == 0.
> > 
> > Fix this by checking divider p before decreasing it. Also small
> > improvement
> > is made by using fls() instead of custom loop.
> > 
> > v2: use fls() and check parsed divider
> > 
> > Signed-off-by: Jouni Högander <jouni.hogander at intel.com>
> 
> Thanks, I think fls() is cleaner.
> 
> Reviewed-by: Jani Nikula <jani.nikula at intel.com>

Thank you Jani for the review. This is now pushed to drm-intel-next.

BR,

Jouni Högander

> 
> 
> > ---
> >  drivers/gpu/drm/i915/display/vlv_dsi_pll.c | 8 +++-----
> >  1 file changed, 3 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/vlv_dsi_pll.c
> > b/drivers/gpu/drm/i915/display/vlv_dsi_pll.c
> > index b52463fdec47..83afe1315e96 100644
> > --- a/drivers/gpu/drm/i915/display/vlv_dsi_pll.c
> > +++ b/drivers/gpu/drm/i915/display/vlv_dsi_pll.c
> > @@ -142,11 +142,9 @@ static int vlv_dsi_pclk(struct intel_encoder
> > *encoder,
> >  	pll_div &= DSI_PLL_M1_DIV_MASK;
> >  	pll_div = pll_div >> DSI_PLL_M1_DIV_SHIFT;
> >  
> > -	while (pll_ctl) {
> > -		pll_ctl = pll_ctl >> 1;
> > -		p++;
> > -	}
> > -	p--;
> > +	p = fls(pll_ctl);
> > +	if (p)
> > +		p--;
> >  
> >  	if (!p) {
> >  		drm_err(display->drm, "wrong P1 divisor\n");
> 



More information about the Intel-gfx mailing list