drm/i915: Potential gen3 vblank interrupt fixes
Subsystems (2)
cover drm/i915: Potential gen3 vblank interrupt fixes
From: Ville Syrjälä <[email protected]>
The AGBBUSY# bit in INSTPM caught my eye while reading the code and having the spec open at the same time. This series makes the code match the spec, and also closes a potential race condition (which may or may not be real, depending on how the hardware works).
Ville Syrjälä (2):
drm/i915: Frob AGPBUSY# bit before enabling the vblank interrupt drm/i915: Flip the sense of AGPBUSY_DIS bit
drivers/gpu/drm/i915/i915_irq.c | 14 +++++++++----- drivers/gpu/drm/i915/i915_reg.h | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-)
Signature · 6 lines
1.8.3.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/2 drm/i915: Frob AGPBUSY# bit before enabling the vblank interrupt
From: Ville Syrjälä <[email protected]>
Not sure what would happen if an interrupt is generated between enabling the interrupt in PIPESTAT and frobbing the AGPBUSY# bit in INSTPM. Would the already pending interrupt cause exit from C3 or not? Let's not play such guessing games, and simply flip AGPBUSY# bit before enabling the interrupt. Do the opposite when disabling the interrupt, just for symmetry.
--- drivers/gpu/drm/i915/i915_irq.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +9 -5
@@ -2261,6 +2261,11 @@ static int i915_enable_vblank(struct drm_device *dev, int pipe)return -EINVAL ;spin_lock_irqsave (&dev_priv->irq_lock, irqflags); + +/* maintain vblank delivery even in deep C-states */ +if (dev_priv->info->gen ==3 ) +I915_WRITE (INSTPM ,_MASKED_BIT_DISABLE (INSTPM_AGPBUSY_DIS )); +if (INTEL_INFO (dev)->gen >=4 )i915_enable_pipestat (dev_priv, pipe,PIPE_START_VBLANK_INTERRUPT_ENABLE );
@@ -2268,9 +2273,6 @@ static int i915_enable_vblank(struct drm_device *dev, int pipe)i915_enable_pipestat (dev_priv, pipe,PIPE_VBLANK_INTERRUPT_ENABLE ); -/* maintain vblank delivery even in deep C-states */ -if (dev_priv->info->gen ==3 ) -I915_WRITE (INSTPM ,_MASKED_BIT_DISABLE (INSTPM_AGPBUSY_DIS ));spin_unlock_irqrestore (&dev_priv->irq_lock, irqflags);return 0 ;
@@ -2341,12 +2343,14 @@ static void i915_disable_vblank(struct drm_device *dev, int pipe)unsigned long irqflags;spin_lock_irqsave (&dev_priv->irq_lock, irqflags); -if (dev_priv->info->gen ==3 ) -I915_WRITE (INSTPM ,_MASKED_BIT_ENABLE (INSTPM_AGPBUSY_DIS ));i915_disable_pipestat (dev_priv, pipe,PIPE_VBLANK_INTERRUPT_ENABLE |PIPE_START_VBLANK_INTERRUPT_ENABLE ); + +if (dev_priv->info->gen ==3 ) +I915_WRITE (INSTPM ,_MASKED_BIT_ENABLE (INSTPM_AGPBUSY_DIS )); +spin_unlock_irqrestore (&dev_priv->irq_lock, irqflags); }
Signature · 6 lines
1.8.3.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 drm/i915: Flip the sense of AGPBUSY_DIS bit
In reply to [email protected]From: Ville Syrjälä <[email protected]>
My Gen3 Bspec lists the AGPBUSY# bit in INSTPM as an enable bit rather than a disable bit. Our code has the opposite idea. Make the code match the spec.
Might fix some gen3 C3 related interrupt delivery problems. Untested due to lack of hardware.
--- drivers/gpu/drm/i915/i915_irq.c | 4 ++-- drivers/gpu/drm/i915/i915_reg.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +2 -2
@@ -2264,7 +2264,7 @@ static int i915_enable_vblank(struct drm_device *dev, int pipe)/* maintain vblank delivery even in deep C-states */ if (dev_priv->info->gen ==3 ) -I915_WRITE (INSTPM ,_MASKED_BIT_DISABLE (INSTPM_AGPBUSY_DIS )); +I915_WRITE (INSTPM ,_MASKED_BIT_ENABLE (INSTPM_AGPBUSY_EN ));if (INTEL_INFO (dev)->gen >=4 ) i915_enable_pipestat(dev_priv, pipe,
@@ -2349,7 +2349,7 @@ static void i915_disable_vblank(struct drm_device *dev, int pipe) PIPE_START_VBLANK_INTERRUPT_ENABLE);if (dev_priv->info->gen ==3 ) -I915_WRITE (INSTPM ,_MASKED_BIT_ENABLE (INSTPM_AGPBUSY_DIS )); +I915_WRITE (INSTPM ,_MASKED_BIT_DISABLE (INSTPM_AGPBUSY_EN ));spin_unlock_irqrestore (&dev_priv->irq_lock, irqflags); }
drivers/gpu/drm/i915/i915_reg.h +1 -1
@@ -838,7 +838,7 @@#define I915_ERROR_INSTRUCTION (1<<0)#define INSTPM 0x020c0#define INSTPM_SELF_EN (1<<12)/* 915GM only */ -#define INSTPM_AGPBUSY_DIS (1<<11)/* gen3: when disabled, pending interrupts +#define INSTPM_AGPBUSY_EN (1<<11)/* gen3: when disabled, pending interrupts will not assert AGPBUSY# and will only be delivered when out of C3. */ #define INSTPM_FORCE_ORDERING (1<<7)/* GEN6+ */
Signature · 6 lines
1.8.3.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
[PATCH 3/2] drm/i915: Add a refcount for the AGPBUSY# bit
In reply to [email protected]From: Ville Syrjälä <[email protected]>
We can have multiple pipes, but only one AGPBUSY# bit. So we need a reference correctly figure out whether the bits needs to be set.
--- drivers/gpu/drm/i915/i915_drv.h | 3 +++ drivers/gpu/drm/i915/i915_irq.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
@@ -1442,6 +1442,9 @@ typedef struct drm_i915_private {u32 hpd_event_bits;struct timer_list hotplug_reenable_timer; +/* AGPBUSY# wakeup mechanism needed? Gen3 only. */ +unsigned int agpbusy_ref; +int num_plane;struct i915_fbc fbc;
drivers/gpu/drm/i915/i915_irq.c +2 -2
@@ -2263,7 +2263,7 @@ static int i915_enable_vblank(struct drm_device *dev, int pipe)spin_lock_irqsave (&dev_priv->irq_lock, irqflags);/* maintain vblank delivery even in deep C-states */ -if (dev_priv->info->gen ==3 ) +if (dev_priv->info->gen ==3 && dev_priv->agpbusy_ref++ ==0 )I915_WRITE (INSTPM ,_MASKED_BIT_ENABLE (INSTPM_AGPBUSY_EN ));if (INTEL_INFO (dev)->gen >=4 )
@@ -2348,7 +2348,7 @@ static void i915_disable_vblank(struct drm_device *dev, int pipe)PIPE_VBLANK_INTERRUPT_ENABLE | PIPE_START_VBLANK_INTERRUPT_ENABLE); -if (dev_priv->info->gen ==3 ) +if (dev_priv->info->gen ==3 && --dev_priv->agpbusy_ref ==0 )I915_WRITE (INSTPM ,_MASKED_BIT_DISABLE (INSTPM_AGPBUSY_EN ));spin_unlock_irqrestore (&dev_priv->irq_lock, irqflags);
Signature · 6 lines
1.8.3.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx