All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: protect against division by zero.
Date: Wed, 22 Aug 2018 22:24:01 -0700	[thread overview]
Message-ID: <20180823052401.GE2124@intel.com> (raw)
In-Reply-To: <046ae3f5-67c4-e22f-791c-9deae679c253@linux.intel.com>

On Thu, Aug 23, 2018 at 07:11:16AM +0200, Maarten Lankhorst wrote:
> Op 23-08-18 om 02:51 schreef Rodrigo Vivi:
> > Static analyzer tools thinks it is possible to have a division by zero
> > here.
> >
> > I don't believe we would really reach this path without any crtc enabled,
> > but may be good to protect against some unexpected path or behavior.
> >
> > Fixes: cf1f697acb04 ("drm/i915/skl: distribute DDB based on panel resolution")
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Mahesh Kumar <mahesh1.kumar@intel.com>
> > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > ---
> >  drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> > index d99e5fabe93c..fac6e159a640 100644
> > --- a/drivers/gpu/drm/i915/intel_pm.c
> > +++ b/drivers/gpu/drm/i915/intel_pm.c
> > @@ -3878,6 +3878,12 @@ skl_ddb_get_pipe_allocation_limits(struct drm_device *dev,
> >  			pipe_width = hdisplay;
> >  	}
> >  
> > +	if (WARN_ON(total_width == 0)) {
> > +		alloc->start = 0;
> > +		alloc->end = 0;
> > +		return;
> > +	}
> > +
> >  	alloc->start = ddb_size * width_before_pipe / total_width;
> >  	alloc->end = ddb_size * (width_before_pipe + pipe_width) / total_width;
> >  }
> 
> It's actually quite impossible.. only way I can imagine if hw is already borked.
> 
> It must be the case that we will set cstate->active, which implies cstate->enable,
> which implies a valid mode is set at least on the current crtc.

yeap... that's what I thought... but I decided to check just in case I missed something.

> 
> I don't think static analysis tools could deduce it, but definitely a false positive.

I'll mart that so...

> 
> Also too generic commit message oneliner?

it just reflects the amount of confidence I had on the need of this ;)

just dropping it then.

thanks for the confirmation

> 
> ~Maarten
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

      reply	other threads:[~2018-08-23  5:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-23  0:51 [PATCH] drm/i915: protect against division by zero Rodrigo Vivi
2018-08-23  1:14 ` ✗ Fi.CI.BAT: failure for " Patchwork
2018-08-23  2:15 ` ✓ Fi.CI.BAT: success " Patchwork
2018-08-23  3:28 ` ✓ Fi.CI.IGT: " Patchwork
2018-08-23  5:11 ` [PATCH] " Maarten Lankhorst
2018-08-23  5:24   ` Rodrigo Vivi [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=20180823052401.GE2124@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.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.