drm/i915: Fix erroneous conversion to u8
Subsystems (2)
PATCH 1/1 drm/i915: Fix erroneous conversion to u8
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!)
--- drivers/gpu/drm/i915/i915_irq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_irq.c +2 -1
@@ -1330,7 +1330,8 @@ static u32 vlv_c0_residency(struct drm_i915_private *dev_priv,static u32 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; +u8 new_delay; +int adj; dev_priv->rps.ei_interrupt_count++;
Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 23 lines · Damien Lespiau
adj was defined as u8. The issue is
last_adjcan 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!)
Cc Deepak S <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Damien Lespiau <[email protected]>--- drivers/gpu/drm/i915/i915_irq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_irq.c +0
-0
drivers/gpu/drm/i915/i915_irq.c static u32 vlv_c0_residency(struct drm_i915_private *dev_priv, · line 1334
Quoted 6 lines
drivers/gpu/drm/i915/i915_irq.c +2
-1@@ -1330,7 +1330,8 @@ static u32 vlv_c0_residency(struct drm_i915_private *dev_priv,static u32 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; +u8 new_delay; +int adj;
Might be better to make new_delay int too, so that we don't accidentally under/overflow it due to the adj acceleration thing. And the return value too. I'm feeling too lazy to think what kind of conditions that would required, so just making it all int seems easier.
Quoted 5 lines
drivers/gpu/drm/i915/i915_irq.c +0
-0dev_priv->rps.ei_interrupt_count++;Signature · 1 line
1.8.3.1
Signature · 2 lines
Ville Syrjälä Intel OTC
PATCH 1/1 drm/i915: Fix erroneous conversion to u8
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)
--- drivers/gpu/drm/i915/i915_irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +2 -2
@@ -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++;
Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 9 lines · Damien Lespiau
adj was defined as u8. The issue is
last_adjcan be negative and adj is initialized with:adj = dev_priv->rps.last_adj;and we were also happily doing things like:
if (adj < 0)
Quoted 8 lines
(thank static analysers!)
v2: Make
new_delayan int in case we overflow the u8 in the intermediate
computations.new_delaywill get clamped at the end anyway. (Ville)Cc Deepak S <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Damien Lespiau <[email protected]>
Quoted 23 lines
--- drivers/gpu/drm/i915/i915_irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/i915_irq.c +2
-2@@ -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++;Signature · 1 line
1.8.3.1
Signature · 2 lines
Ville Syrjälä Intel OTC
Daniel Vetter
AppliedQuoted 12 lines · Ville Syrjälä
Quoted 11 lines · Damien Lespiau
adj was defined as u8. The issue is
last_adjcan 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!)
Quoted 8 lines
Quoted 6 lines
v2: Make
new_delayan int in case we overflow the u8 in the intermediate
computations.new_delaywill get clamped at the end anyway. (Ville)Cc Deepak S <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Damien Lespiau <[email protected]>Reviewed-by Ville Syrjälä <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Quoted 32 lines
Quoted 24 lines
--- drivers/gpu/drm/i915/i915_irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/i915_irq.c +2
-2@@ -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++;Signature · 1 line
1.8.3.1Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch