drm/i915: kill dev_priv->pm.regsave
authorPaulo Zanoni <paulo.r.zanoni@intel.com>
Fri, 7 Mar 2014 23:12:32 +0000 (20:12 -0300)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 1 Apr 2014 21:31:06 +0000 (23:31 +0200)
Now that we don't keep the hotplug interrupts enabled anymore, we can
kill the regsave struct and just cal the normal IRQ preinstall,
postinstall and uninstall functions. This makes it easier to add
runtime PM support to non-HSW platforms.

The only downside is in case we get a request to update interrupts
while they are disabled, won't be able to update the regsave struct.
But this should never happen anyway, so we're not losing too much.

v2: - Rebase.
v3: - Rebase.
v4: - Rebase.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Reviewed-by: Imre Deak <imre.deak@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_irq.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_drv.h

index 828886009ef40cd3aa758d063de978891b25fe07..9b635f5db989b5a38a2ec3f93da252e74b37f1b1 100644 (file)
@@ -1212,23 +1212,13 @@ struct ilk_wm_values {
  * goes back to false exactly before we reenable the IRQs. We use this variable
  * to check if someone is trying to enable/disable IRQs while they're supposed
  * to be disabled. This shouldn't happen and we'll print some error messages in
- * case it happens, but if it actually happens we'll also update the variables
- * inside struct regsave so when we restore the IRQs they will contain the
- * latest expected values.
+ * case it happens.
  *
  * For more, read the Documentation/power/runtime_pm.txt.
  */
 struct i915_runtime_pm {
        bool suspended;
        bool irqs_disabled;
-
-       struct {
-               uint32_t deimr;
-               uint32_t sdeimr;
-               uint32_t gtimr;
-               uint32_t gtier;
-               uint32_t gen6_pmimr;
-       } regsave;
 };
 
 enum intel_pipe_crc_source {
index 75f19979b8f71f506dca12b4a908f76dcee74946..327d584e4353da62e4175cf08de07d899eedb3ee 100644 (file)
@@ -136,11 +136,8 @@ ironlake_enable_display_irq(struct drm_i915_private *dev_priv, u32 mask)
 {
        assert_spin_locked(&dev_priv->irq_lock);
 
-       if (dev_priv->pm.irqs_disabled) {
-               WARN(1, "IRQs disabled\n");
-               dev_priv->pm.regsave.deimr &= ~mask;
+       if (WARN_ON(dev_priv->pm.irqs_disabled))
                return;
-       }
 
        if ((dev_priv->irq_mask & mask) != 0) {
                dev_priv->irq_mask &= ~mask;
@@ -154,11 +151,8 @@ ironlake_disable_display_irq(struct drm_i915_private *dev_priv, u32 mask)
 {
        assert_spin_locked(&dev_priv->irq_lock);
 
-       if (dev_priv->pm.irqs_disabled) {
-               WARN(1, "IRQs disabled\n");
-               dev_priv->pm.regsave.deimr |= mask;
+       if (WARN_ON(dev_priv->pm.irqs_disabled))
                return;
-       }
 
        if ((dev_priv->irq_mask & mask) != mask) {
                dev_priv->irq_mask |= mask;
@@ -179,13 +173,8 @@ static void ilk_update_gt_irq(struct drm_i915_private *dev_priv,
 {
        assert_spin_locked(&dev_priv->irq_lock);
 
-       if (dev_priv->pm.irqs_disabled) {
-               WARN(1, "IRQs disabled\n");
-               dev_priv->pm.regsave.gtimr &= ~interrupt_mask;
-               dev_priv->pm.regsave.gtimr |= (~enabled_irq_mask &
-                                               interrupt_mask);
+       if (WARN_ON(dev_priv->pm.irqs_disabled))
                return;
-       }
 
        dev_priv->gt_irq_mask &= ~interrupt_mask;
        dev_priv->gt_irq_mask |= (~enabled_irq_mask & interrupt_mask);
@@ -217,13 +206,8 @@ static void snb_update_pm_irq(struct drm_i915_private *dev_priv,
 
        assert_spin_locked(&dev_priv->irq_lock);
 
-       if (dev_priv->pm.irqs_disabled) {
-               WARN(1, "IRQs disabled\n");
-               dev_priv->pm.regsave.gen6_pmimr &= ~interrupt_mask;
-               dev_priv->pm.regsave.gen6_pmimr |= (~enabled_irq_mask &
-                                                    interrupt_mask);
+       if (WARN_ON(dev_priv->pm.irqs_disabled))
                return;
-       }
 
        new_val = dev_priv->pm_irq_mask;
        new_val &= ~interrupt_mask;
@@ -363,14 +347,8 @@ static void ibx_display_interrupt_update(struct drm_i915_private *dev_priv,
 
        assert_spin_locked(&dev_priv->irq_lock);
 
-       if (dev_priv->pm.irqs_disabled &&
-           (interrupt_mask & SDE_HOTPLUG_MASK_CPT)) {
-               WARN(1, "IRQs disabled\n");
-               dev_priv->pm.regsave.sdeimr &= ~interrupt_mask;
-               dev_priv->pm.regsave.sdeimr |= (~enabled_irq_mask &
-                                                interrupt_mask);
+       if (WARN_ON(dev_priv->pm.irqs_disabled))
                return;
-       }
 
        I915_WRITE(SDEIMR, sdeimr);
        POSTING_READ(SDEIMR);
@@ -4126,57 +4104,20 @@ void intel_hpd_init(struct drm_device *dev)
 }
 
 /* Disable interrupts so we can allow runtime PM. */
-void hsw_runtime_pm_disable_interrupts(struct drm_device *dev)
+void intel_runtime_pm_disable_interrupts(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
-       unsigned long irqflags;
-
-       spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
-
-       dev_priv->pm.regsave.deimr = I915_READ(DEIMR);
-       dev_priv->pm.regsave.sdeimr = I915_READ(SDEIMR);
-       dev_priv->pm.regsave.gtimr = I915_READ(GTIMR);
-       dev_priv->pm.regsave.gtier = I915_READ(GTIER);
-       dev_priv->pm.regsave.gen6_pmimr = I915_READ(GEN6_PMIMR);
-
-       ironlake_disable_display_irq(dev_priv, 0xffffffff);
-       ibx_disable_display_interrupt(dev_priv, 0xffffffff);
-       ilk_disable_gt_irq(dev_priv, 0xffffffff);
-       snb_disable_pm_irq(dev_priv, 0xffffffff);
 
+       dev->driver->irq_uninstall(dev);
        dev_priv->pm.irqs_disabled = true;
-
-       spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
 }
 
 /* Restore interrupts so we can recover from runtime PM. */
-void hsw_runtime_pm_restore_interrupts(struct drm_device *dev)
+void intel_runtime_pm_restore_interrupts(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
-       unsigned long irqflags;
-       uint32_t val;
-
-       spin_lock_irqsave(&dev_priv->irq_lock, irqflags);
-
-       val = I915_READ(DEIMR);
-       WARN(val != 0xffffffff, "DEIMR is 0x%08x\n", val);
-
-       val = I915_READ(SDEIMR);
-       WARN(val != 0xffffffff, "SDEIMR is 0x%08x\n", val);
-
-       val = I915_READ(GTIMR);
-       WARN(val != 0xffffffff, "GTIMR is 0x%08x\n", val);
-
-       val = I915_READ(GEN6_PMIMR);
-       WARN(val != 0xffffffff, "GEN6_PMIMR is 0x%08x\n", val);
 
        dev_priv->pm.irqs_disabled = false;
-
-       ironlake_enable_display_irq(dev_priv, ~dev_priv->pm.regsave.deimr);
-       ibx_enable_display_interrupt(dev_priv, ~dev_priv->pm.regsave.sdeimr);
-       ilk_enable_gt_irq(dev_priv, ~dev_priv->pm.regsave.gtimr);
-       snb_enable_pm_irq(dev_priv, ~dev_priv->pm.regsave.gen6_pmimr);
-       I915_WRITE(GTIER, dev_priv->pm.regsave.gtier);
-
-       spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);
+       dev->driver->irq_preinstall(dev);
+       dev->driver->irq_postinstall(dev);
 }
index fe1d6e41c42a81afa1ddac03e0dd0e936a3e710a..6d252501c7241384c94b7328ee5e2738c0030ca4 100644 (file)
@@ -7050,7 +7050,7 @@ void hsw_enable_pc8(struct drm_i915_private *dev_priv)
        }
 
        lpt_disable_clkout_dp(dev);
-       hsw_runtime_pm_disable_interrupts(dev);
+       intel_runtime_pm_disable_interrupts(dev);
        hsw_disable_lcpll(dev_priv, true, true);
 }
 
@@ -7064,7 +7064,7 @@ void hsw_disable_pc8(struct drm_i915_private *dev_priv)
        DRM_DEBUG_KMS("Disabling package C8+\n");
 
        hsw_restore_lcpll(dev_priv);
-       hsw_runtime_pm_restore_interrupts(dev);
+       intel_runtime_pm_restore_interrupts(dev);
        lpt_init_pch_refclk(dev);
 
        if (dev_priv->pch_id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) {
index 7b21571bb9280feba2b0823dcd306d3b63b62ec9..42762b798cb060a93df0008e3c7641831cc1d7b2 100644 (file)
@@ -627,8 +627,8 @@ void ilk_enable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
 void ilk_disable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
 void snb_enable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
 void snb_disable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
-void hsw_runtime_pm_disable_interrupts(struct drm_device *dev);
-void hsw_runtime_pm_restore_interrupts(struct drm_device *dev);
+void intel_runtime_pm_disable_interrupts(struct drm_device *dev);
+void intel_runtime_pm_restore_interrupts(struct drm_device *dev);
 
 
 /* intel_crt.c */