Commit 59cdb63d authored by Daniel Vetter's avatar Daniel Vetter

drm/i915: kill dev_priv->rps.lock

Now that the rps interrupt locking isn't clearly separated (at elast
conceptually) from all the other interrupt locking having a different
lock stopped making sense: It protects much more than just the rps
workqueue it started out with. But with the addition of VECS the
separation started to blurr and resulted in some more complex locking
for the ring interrupt refcount.

With this we can (again) unifiy the ringbuffer irq refcounts without
causing a massive confusion, but that's for the next patch.

v2: Explain better why the rps.lock once made sense and why no longer,
requested by Ben.
Reviewed-by: default avatarBen Widawsky <ben@bwidawsk.net>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 2adbee62
...@@ -1607,7 +1607,6 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) ...@@ -1607,7 +1607,6 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
spin_lock_init(&dev_priv->irq_lock); spin_lock_init(&dev_priv->irq_lock);
spin_lock_init(&dev_priv->gpu_error.lock); spin_lock_init(&dev_priv->gpu_error.lock);
spin_lock_init(&dev_priv->rps.lock);
spin_lock_init(&dev_priv->backlight.lock); spin_lock_init(&dev_priv->backlight.lock);
mutex_init(&dev_priv->dpio_lock); mutex_init(&dev_priv->dpio_lock);
......
...@@ -743,12 +743,12 @@ struct i915_suspend_saved_registers { ...@@ -743,12 +743,12 @@ struct i915_suspend_saved_registers {
}; };
struct intel_gen6_power_mgmt { struct intel_gen6_power_mgmt {
/* work and pm_iir are protected by dev_priv->irq_lock */
struct work_struct work; struct work_struct work;
struct delayed_work vlv_work;
u32 pm_iir; u32 pm_iir;
/* lock - irqsave spinlock that protectects the work_struct and
* pm_iir. */ /* On vlv we need to manually drop to Vmin with a delayed work. */
spinlock_t lock; struct delayed_work vlv_work;
/* The below variables an all the rps hw state are protected by /* The below variables an all the rps hw state are protected by
* dev->struct mutext. */ * dev->struct mutext. */
......
...@@ -719,13 +719,13 @@ static void gen6_pm_rps_work(struct work_struct *work) ...@@ -719,13 +719,13 @@ static void gen6_pm_rps_work(struct work_struct *work)
u32 pm_iir, pm_imr; u32 pm_iir, pm_imr;
u8 new_delay; u8 new_delay;
spin_lock_irq(&dev_priv->rps.lock); spin_lock_irq(&dev_priv->irq_lock);
pm_iir = dev_priv->rps.pm_iir; pm_iir = dev_priv->rps.pm_iir;
dev_priv->rps.pm_iir = 0; dev_priv->rps.pm_iir = 0;
pm_imr = I915_READ(GEN6_PMIMR); pm_imr = I915_READ(GEN6_PMIMR);
/* Make sure not to corrupt PMIMR state used by ringbuffer code */ /* Make sure not to corrupt PMIMR state used by ringbuffer code */
I915_WRITE(GEN6_PMIMR, pm_imr & ~GEN6_PM_RPS_EVENTS); I915_WRITE(GEN6_PMIMR, pm_imr & ~GEN6_PM_RPS_EVENTS);
spin_unlock_irq(&dev_priv->rps.lock); spin_unlock_irq(&dev_priv->irq_lock);
if ((pm_iir & GEN6_PM_RPS_EVENTS) == 0) if ((pm_iir & GEN6_PM_RPS_EVENTS) == 0)
return; return;
...@@ -887,11 +887,11 @@ static void gen6_rps_irq_handler(struct drm_i915_private *dev_priv, ...@@ -887,11 +887,11 @@ static void gen6_rps_irq_handler(struct drm_i915_private *dev_priv,
* The mask bit in IMR is cleared by dev_priv->rps.work. * The mask bit in IMR is cleared by dev_priv->rps.work.
*/ */
spin_lock(&dev_priv->rps.lock); spin_lock(&dev_priv->irq_lock);
dev_priv->rps.pm_iir |= pm_iir; dev_priv->rps.pm_iir |= pm_iir;
I915_WRITE(GEN6_PMIMR, dev_priv->rps.pm_iir); I915_WRITE(GEN6_PMIMR, dev_priv->rps.pm_iir);
POSTING_READ(GEN6_PMIMR); POSTING_READ(GEN6_PMIMR);
spin_unlock(&dev_priv->rps.lock); spin_unlock(&dev_priv->irq_lock);
queue_work(dev_priv->wq, &dev_priv->rps.work); queue_work(dev_priv->wq, &dev_priv->rps.work);
} }
...@@ -964,12 +964,12 @@ static void hsw_pm_irq_handler(struct drm_i915_private *dev_priv, ...@@ -964,12 +964,12 @@ static void hsw_pm_irq_handler(struct drm_i915_private *dev_priv,
u32 pm_iir) u32 pm_iir)
{ {
if (pm_iir & GEN6_PM_RPS_EVENTS) { if (pm_iir & GEN6_PM_RPS_EVENTS) {
spin_lock(&dev_priv->rps.lock); spin_lock(&dev_priv->irq_lock);
dev_priv->rps.pm_iir |= pm_iir & GEN6_PM_RPS_EVENTS; dev_priv->rps.pm_iir |= pm_iir & GEN6_PM_RPS_EVENTS;
I915_WRITE(GEN6_PMIMR, dev_priv->rps.pm_iir); I915_WRITE(GEN6_PMIMR, dev_priv->rps.pm_iir);
/* never want to mask useful interrupts. (also posting read) */ /* never want to mask useful interrupts. (also posting read) */
WARN_ON(I915_READ_NOTRACE(GEN6_PMIMR) & ~GEN6_PM_RPS_EVENTS); WARN_ON(I915_READ_NOTRACE(GEN6_PMIMR) & ~GEN6_PM_RPS_EVENTS);
spin_unlock(&dev_priv->rps.lock); spin_unlock(&dev_priv->irq_lock);
queue_work(dev_priv->wq, &dev_priv->rps.work); queue_work(dev_priv->wq, &dev_priv->rps.work);
} }
......
...@@ -3135,9 +3135,9 @@ static void gen6_disable_rps(struct drm_device *dev) ...@@ -3135,9 +3135,9 @@ static void gen6_disable_rps(struct drm_device *dev)
* register (PMIMR) to mask PM interrupts. The only risk is in leaving * register (PMIMR) to mask PM interrupts. The only risk is in leaving
* stale bits in PMIIR and PMIMR which gen6_enable_rps will clean up. */ * stale bits in PMIIR and PMIMR which gen6_enable_rps will clean up. */
spin_lock_irq(&dev_priv->rps.lock); spin_lock_irq(&dev_priv->irq_lock);
dev_priv->rps.pm_iir = 0; dev_priv->rps.pm_iir = 0;
spin_unlock_irq(&dev_priv->rps.lock); spin_unlock_irq(&dev_priv->irq_lock);
I915_WRITE(GEN6_PMIIR, GEN6_PM_RPS_EVENTS); I915_WRITE(GEN6_PMIIR, GEN6_PM_RPS_EVENTS);
} }
...@@ -3154,9 +3154,9 @@ static void valleyview_disable_rps(struct drm_device *dev) ...@@ -3154,9 +3154,9 @@ static void valleyview_disable_rps(struct drm_device *dev)
* register (PMIMR) to mask PM interrupts. The only risk is in leaving * register (PMIMR) to mask PM interrupts. The only risk is in leaving
* stale bits in PMIIR and PMIMR which gen6_enable_rps will clean up. */ * stale bits in PMIIR and PMIMR which gen6_enable_rps will clean up. */
spin_lock_irq(&dev_priv->rps.lock); spin_lock_irq(&dev_priv->irq_lock);
dev_priv->rps.pm_iir = 0; dev_priv->rps.pm_iir = 0;
spin_unlock_irq(&dev_priv->rps.lock); spin_unlock_irq(&dev_priv->irq_lock);
I915_WRITE(GEN6_PMIIR, I915_READ(GEN6_PMIIR)); I915_WRITE(GEN6_PMIIR, I915_READ(GEN6_PMIIR));
...@@ -3321,13 +3321,13 @@ static void gen6_enable_rps(struct drm_device *dev) ...@@ -3321,13 +3321,13 @@ static void gen6_enable_rps(struct drm_device *dev)
/* requires MSI enabled */ /* requires MSI enabled */
I915_WRITE(GEN6_PMIER, I915_READ(GEN6_PMIER) | GEN6_PM_RPS_EVENTS); I915_WRITE(GEN6_PMIER, I915_READ(GEN6_PMIER) | GEN6_PM_RPS_EVENTS);
spin_lock_irq(&dev_priv->rps.lock); spin_lock_irq(&dev_priv->irq_lock);
/* FIXME: Our interrupt enabling sequence is bonghits. /* FIXME: Our interrupt enabling sequence is bonghits.
* dev_priv->rps.pm_iir really should be 0 here. */ * dev_priv->rps.pm_iir really should be 0 here. */
dev_priv->rps.pm_iir = 0; dev_priv->rps.pm_iir = 0;
I915_WRITE(GEN6_PMIMR, I915_READ(GEN6_PMIMR) & ~GEN6_PM_RPS_EVENTS); I915_WRITE(GEN6_PMIMR, I915_READ(GEN6_PMIMR) & ~GEN6_PM_RPS_EVENTS);
I915_WRITE(GEN6_PMIIR, GEN6_PM_RPS_EVENTS); I915_WRITE(GEN6_PMIIR, GEN6_PM_RPS_EVENTS);
spin_unlock_irq(&dev_priv->rps.lock); spin_unlock_irq(&dev_priv->irq_lock);
/* unmask all PM interrupts */ /* unmask all PM interrupts */
I915_WRITE(GEN6_PMINTRMSK, 0); I915_WRITE(GEN6_PMINTRMSK, 0);
...@@ -3601,10 +3601,10 @@ static void valleyview_enable_rps(struct drm_device *dev) ...@@ -3601,10 +3601,10 @@ static void valleyview_enable_rps(struct drm_device *dev)
/* requires MSI enabled */ /* requires MSI enabled */
I915_WRITE(GEN6_PMIER, GEN6_PM_RPS_EVENTS); I915_WRITE(GEN6_PMIER, GEN6_PM_RPS_EVENTS);
spin_lock_irq(&dev_priv->rps.lock); spin_lock_irq(&dev_priv->irq_lock);
WARN_ON(dev_priv->rps.pm_iir != 0); WARN_ON(dev_priv->rps.pm_iir != 0);
I915_WRITE(GEN6_PMIMR, 0); I915_WRITE(GEN6_PMIMR, 0);
spin_unlock_irq(&dev_priv->rps.lock); spin_unlock_irq(&dev_priv->irq_lock);
/* enable all PM interrupts */ /* enable all PM interrupts */
I915_WRITE(GEN6_PMINTRMSK, 0); I915_WRITE(GEN6_PMINTRMSK, 0);
......
...@@ -1055,14 +1055,14 @@ hsw_vebox_get_irq(struct intel_ring_buffer *ring) ...@@ -1055,14 +1055,14 @@ hsw_vebox_get_irq(struct intel_ring_buffer *ring)
if (!dev->irq_enabled) if (!dev->irq_enabled)
return false; return false;
spin_lock_irqsave(&dev_priv->rps.lock, flags); spin_lock_irqsave(&dev_priv->irq_lock, flags);
if (ring->irq_refcount.pm++ == 0) { if (ring->irq_refcount.pm++ == 0) {
u32 pm_imr = I915_READ(GEN6_PMIMR); u32 pm_imr = I915_READ(GEN6_PMIMR);
I915_WRITE_IMR(ring, ~ring->irq_enable_mask); I915_WRITE_IMR(ring, ~ring->irq_enable_mask);
I915_WRITE(GEN6_PMIMR, pm_imr & ~ring->irq_enable_mask); I915_WRITE(GEN6_PMIMR, pm_imr & ~ring->irq_enable_mask);
POSTING_READ(GEN6_PMIMR); POSTING_READ(GEN6_PMIMR);
} }
spin_unlock_irqrestore(&dev_priv->rps.lock, flags); spin_unlock_irqrestore(&dev_priv->irq_lock, flags);
return true; return true;
} }
...@@ -1077,14 +1077,14 @@ hsw_vebox_put_irq(struct intel_ring_buffer *ring) ...@@ -1077,14 +1077,14 @@ hsw_vebox_put_irq(struct intel_ring_buffer *ring)
if (!dev->irq_enabled) if (!dev->irq_enabled)
return; return;
spin_lock_irqsave(&dev_priv->rps.lock, flags); spin_lock_irqsave(&dev_priv->irq_lock, flags);
if (--ring->irq_refcount.pm == 0) { if (--ring->irq_refcount.pm == 0) {
u32 pm_imr = I915_READ(GEN6_PMIMR); u32 pm_imr = I915_READ(GEN6_PMIMR);
I915_WRITE_IMR(ring, ~0); I915_WRITE_IMR(ring, ~0);
I915_WRITE(GEN6_PMIMR, pm_imr | ring->irq_enable_mask); I915_WRITE(GEN6_PMIMR, pm_imr | ring->irq_enable_mask);
POSTING_READ(GEN6_PMIMR); POSTING_READ(GEN6_PMIMR);
} }
spin_unlock_irqrestore(&dev_priv->rps.lock, flags); spin_unlock_irqrestore(&dev_priv->irq_lock, flags);
} }
static int static int
......
...@@ -80,7 +80,7 @@ struct intel_ring_buffer { ...@@ -80,7 +80,7 @@ struct intel_ring_buffer {
struct { struct {
u32 gt; /* protected by dev_priv->irq_lock */ u32 gt; /* protected by dev_priv->irq_lock */
u32 pm; /* protected by dev_priv->rps.lock (sucks) */ u32 pm; /* protected by dev_priv->irq_lock */
} irq_refcount; } irq_refcount;
u32 irq_enable_mask; /* bitmask to enable ring interrupt */ u32 irq_enable_mask; /* bitmask to enable ring interrupt */
u32 trace_irq_seqno; u32 trace_irq_seqno;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment