Skip to content

Commit

Permalink
drm/i915: Fix erroneous conversion to u8
Browse files Browse the repository at this point in the history
adj was defined as u8. The issue is last_adj can be negative and adj is
initialized with:

  adj = dev_priv->rps.last_adj;

and we were also happily doing things like:

  if (adj < 0)

(thank static analysers!)

v2: Make new_delay an int in case we overflow the u8 in the intermediate
    computations. new_delay will get clamped at the end anyway. (Ville)

Cc: Deepak S <deepak.s@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
  • Loading branch information
Damien Lespiau authored and Daniel Vetter committed Aug 8, 2014
1 parent 2c0827c commit 4fa7904
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/gpu/drm/i915/i915_irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,10 +1327,10 @@ static u32 vlv_c0_residency(struct drm_i915_private *dev_priv,
* @dev_priv: DRM device private
*
*/
static u32 vlv_calc_delay_from_C0_counters(struct drm_i915_private *dev_priv)
static int vlv_calc_delay_from_C0_counters(struct drm_i915_private *dev_priv)
{
u32 residency_C0_up = 0, residency_C0_down = 0;
u8 new_delay, adj;
int new_delay, adj;

dev_priv->rps.ei_interrupt_count++;

Expand Down

0 comments on commit 4fa7904

Please sign in to comment.