diff mbox

[3/5] drm/i915: Fix gen3/4 vblank counter wraparound

Message ID 1383753389-12763-4-git-send-email-rodrigo.vivi@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rodrigo Vivi Nov. 6, 2013, 3:56 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

When the hardware frame counter reads 0xffffff and we're already past
vblank start, we'd return 0x1000000 as the vblank counter value. Once
we'd cross into the next frame's active portion, the vblank counter
would wrap to 0. So we're reporting two different vblank counter values
for the same frame.

Fix the problem by masking the cooked value by 0xffffff to make sure
the counter wraps already after vblank start.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
---
 drivers/gpu/drm/i915/i915_irq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Imre Deak Nov. 7, 2013, 4:16 p.m. UTC | #1
On Wed, 2013-11-06 at 13:56 -0200, Rodrigo Vivi wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> When the hardware frame counter reads 0xffffff and we're already past
> vblank start, we'd return 0x1000000 as the vblank counter value. Once
> we'd cross into the next frame's active portion, the vblank counter
> would wrap to 0. So we're reporting two different vblank counter values
> for the same frame.
> 
> Fix the problem by masking the cooked value by 0xffffff to make sure
> the counter wraps already after vblank start.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>

Reviewed-by: Imre Deak <imre.deak@intel.com>

> ---
>  drivers/gpu/drm/i915/i915_irq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 2a44816..c474dac 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -583,7 +583,7 @@ static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
>  	 * Cook up a vblank counter by also checking the pixel
>  	 * counter against vblank start.
>  	 */
> -	return ((high1 << 8) | low) + (pixel >= vbl_start);
> +	return (((high1 << 8) | low) + (pixel >= vbl_start)) & 0xffffff;
>  }
>  
>  static u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe)
Daniel Vetter Nov. 7, 2013, 4:20 p.m. UTC | #2
On Thu, Nov 07, 2013 at 06:16:47PM +0200, Imre Deak wrote:
> On Wed, 2013-11-06 at 13:56 -0200, Rodrigo Vivi wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > When the hardware frame counter reads 0xffffff and we're already past
> > vblank start, we'd return 0x1000000 as the vblank counter value. Once
> > we'd cross into the next frame's active portion, the vblank counter
> > would wrap to 0. So we're reporting two different vblank counter values
> > for the same frame.
> > 
> > Fix the problem by masking the cooked value by 0xffffff to make sure
> > the counter wraps already after vblank start.
> > 
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
> 
> Reviewed-by: Imre Deak <imre.deak@intel.com>

Queued for -next, thanks for the patch.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 2a44816..c474dac 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -583,7 +583,7 @@  static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
 	 * Cook up a vblank counter by also checking the pixel
 	 * counter against vblank start.
 	 */
-	return ((high1 << 8) | low) + (pixel >= vbl_start);
+	return (((high1 << 8) | low) + (pixel >= vbl_start)) & 0xffffff;
 }
 
 static u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe)