drm/i915: Read FORCEWAKE registers with I915_READ_FW()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 22 Oct 2015 12:34:57 +0000 (15:34 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 26 Oct 2015 14:28:21 +0000 (16:28 +0200)
Change FORCEWAKE & co. reads for the error state to use I915_READ_FW().
Reading a FORCEWAKE register using a function that can frob forcewake
just seems wrong.

There is a check to skip grabbing the forcewake for accessing FORCEWAKE
in intel_uncore.c, but there's no such check for FORCEWAKE_MT. So no
idea what is currently happening with FORCEWAKE_MT reads. FORCEWAKE_VLV
is fortunately outside the forcewake range anyway, so no actual issue
with that one.

So let's just make the rule that you can't access FORCEWAKE registers with
the normal I915_READ() stuff, and we can drop the extra FORCEWAKE check
from NEEDS_FORCEWAKE(). While at it use NEEDS_FORCEWAKE() on BDW, where
it was skipped for whatever bikeshed reason that I've already forgotten.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1445517300-28173-3-git-send-email-ville.syrjala@linux.intel.com
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
drivers/gpu/drm/i915/i915_gpu_error.c
drivers/gpu/drm/i915/intel_uncore.c

index f3dc67b33d947abbdb1a68a0581c8ebfd8d1bba5..793f2de2f910723d859aef11e922486c68600613 100644 (file)
@@ -1200,7 +1200,7 @@ static void i915_capture_reg_state(struct drm_i915_private *dev_priv,
        if (IS_VALLEYVIEW(dev)) {
                error->gtier[0] = I915_READ(GTIER);
                error->ier = I915_READ(VLV_IER);
-               error->forcewake = I915_READ(FORCEWAKE_VLV);
+               error->forcewake = I915_READ_FW(FORCEWAKE_VLV);
        }
 
        if (IS_GEN7(dev))
@@ -1212,14 +1212,14 @@ static void i915_capture_reg_state(struct drm_i915_private *dev_priv,
        }
 
        if (IS_GEN6(dev)) {
-               error->forcewake = I915_READ(FORCEWAKE);
+               error->forcewake = I915_READ_FW(FORCEWAKE);
                error->gab_ctl = I915_READ(GAB_CTL);
                error->gfx_mode = I915_READ(GFX_MODE);
        }
 
        /* 2: Registers which belong to multiple generations */
        if (INTEL_INFO(dev)->gen >= 7)
-               error->forcewake = I915_READ(FORCEWAKE_MT);
+               error->forcewake = I915_READ_FW(FORCEWAKE_MT);
 
        if (INTEL_INFO(dev)->gen >= 6) {
                error->derrmr = I915_READ(DERRMR);
index 8dfeac967eda119150bd38a4f644c6239835b04a..dca0979c92607a89f186b500d8838ab27900e7cb 100644 (file)
@@ -513,8 +513,7 @@ void assert_forcewakes_inactive(struct drm_i915_private *dev_priv)
 }
 
 /* We give fast paths for the really cool registers */
-#define NEEDS_FORCE_WAKE(reg) \
-        ((reg) < 0x40000 && (reg) != FORCEWAKE)
+#define NEEDS_FORCE_WAKE(reg) ((reg) < 0x40000)
 
 #define REG_RANGE(reg, start, end) ((reg) >= (start) && (reg) < (end))
 
@@ -918,7 +917,7 @@ static void \
 gen8_write##x(struct drm_i915_private *dev_priv, off_t reg, u##x val, bool trace) { \
        GEN6_WRITE_HEADER; \
        hsw_unclaimed_reg_debug(dev_priv, reg, false, true); \
-       if (reg < 0x40000 && !is_gen8_shadowed(dev_priv, reg)) \
+       if (NEEDS_FORCE_WAKE(reg) && !is_gen8_shadowed(dev_priv, reg)) \
                __force_wake_get(dev_priv, FORCEWAKE_RENDER); \
        __raw_i915_write##x(dev_priv, reg, val); \
        hsw_unclaimed_reg_debug(dev_priv, reg, false, false); \