All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: Prevent unbounded wm results in g4x_compute_wm()
Date: Tue, 7 Nov 2017 15:55:09 +0200	[thread overview]
Message-ID: <20171107135509.GS10981@intel.com> (raw)
In-Reply-To: <20171107125623.26300-1-chris@chris-wilson.co.uk>

On Tue, Nov 07, 2017 at 12:56:23PM +0000, Chris Wilson wrote:
> Smatch warns of
> 
> drivers/gpu/drm/i915/intel_pm.c:1161 g4x_compute_wm() warn: signedness bug returning '(-33554430)'
> 
> which is a result of it believing that wm may be INT_MAX following
> g4x_tlb_miss_wa(). Just declaring g4x_tlb_miss_wa() as returning an
> unsigned integer is not sufficient, we need to tell smatch that wm itself
> is unsigned for it to not worry. So mark up the locals we expect to be
> non-negative, and so silence smatch.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_pm.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index 6e1358d4e764..403097606322 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -928,7 +928,7 @@ static void pineview_update_wm(struct intel_crtc *unused_crtc)
>   *  and the size of 8 whole lines. This adjustment is always performed
>   *  in the actual pixel depth regardless of whether FBC is enabled or not."
>   */
> -static int g4x_tlb_miss_wa(int fifo_size, int width, int cpp)
> +static unsigned int g4x_tlb_miss_wa(int fifo_size, int width, int cpp)
>  {
>  	int tlb_miss = fifo_size * 64 - width * cpp * 8;

Yep. This should be the only part where we depend on signed math,
so the patch lgtm.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

I'd like to see the vlv code changed in the same way though,
for consistency.

>  
> @@ -1105,8 +1105,8 @@ static uint16_t g4x_compute_wm(const struct intel_crtc_state *crtc_state,
>  	struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
>  	const struct drm_display_mode *adjusted_mode =
>  		&crtc_state->base.adjusted_mode;
> -	int clock, htotal, cpp, width, wm;
> -	int latency = dev_priv->wm.pri_latency[level] * 10;
> +	unsigned int latency = dev_priv->wm.pri_latency[level] * 10;
> +	unsigned int clock, htotal, cpp, width, wm;
>  
>  	if (latency == 0)
>  		return USHRT_MAX;
> @@ -1145,7 +1145,7 @@ static uint16_t g4x_compute_wm(const struct intel_crtc_state *crtc_state,
>  		   level == G4X_WM_LEVEL_NORMAL) {
>  		wm = intel_wm_method1(clock, cpp, latency);
>  	} else {
> -		int small, large;
> +		unsigned int small, large;
>  
>  		small = intel_wm_method1(clock, cpp, latency);
>  		large = intel_wm_method2(clock, htotal, width, cpp, latency);
> @@ -1158,7 +1158,7 @@ static uint16_t g4x_compute_wm(const struct intel_crtc_state *crtc_state,
>  
>  	wm = DIV_ROUND_UP(wm, 64) + 2;
>  
> -	return min_t(int, wm, USHRT_MAX);
> +	return min_t(unsigned int, wm, USHRT_MAX);
>  }
>  
>  static bool g4x_raw_plane_wm_set(struct intel_crtc_state *crtc_state,
> -- 
> 2.15.0

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-11-07 13:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07 12:56 [PATCH] drm/i915: Prevent unbounded wm results in g4x_compute_wm() Chris Wilson
2017-11-07 12:59 ` Chris Wilson
2017-11-07 13:53   ` Dan Carpenter
2017-11-07 13:20 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-11-07 13:55 ` Ville Syrjälä [this message]
2017-11-07 14:03 ` [PATCH v2] " Chris Wilson
2017-11-07 14:08   ` Chris Wilson
2017-11-07 14:22 ` ✓ Fi.CI.IGT: success for " Patchwork
2017-11-07 14:36 ` ✓ Fi.CI.BAT: success for drm/i915: Prevent unbounded wm results in g4x_compute_wm() (rev2) Patchwork
2017-11-07 15:20 ` ✓ Fi.CI.IGT: " Patchwork
2017-11-07 20:23   ` Chris Wilson

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=20171107135509.GS10981@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /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.