8821eb
From: Rob Clark <robdclark@gmail.com>
8821eb
Date: Mon, 15 Dec 2014 13:56:32 -0500
8821eb
Subject: [PATCH] drm/i915: tame the chattermouth (v2)
8821eb
8821eb
Many distro's have mechanism in place to collect and automatically file
8821eb
bugs for failed WARN()s.  And since i915 has a lot of hw state sanity
8821eb
checks which result in WARN(), it generates quite a lot of noise which
8821eb
is somewhat disconcerting to the end user.
8821eb
8821eb
Separate out the internal hw-is-in-the-state-I-expected checks into
8821eb
I915_STATE_WARN()s and allow configuration via i915.verbose_checks module
8821eb
param about whether this will generate a full blown stacktrace or just
8821eb
DRM_ERROR().  The new moduleparam defaults to true, so by default there
8821eb
is no change in behavior.  And even when disabled, you will still get
8821eb
an error message logged.
8821eb
8821eb
v2: paint the macro names blue, clarify that the default behavior
8821eb
    remains the same as before
8821eb
8821eb
Signed-off-by: Rob Clark <robdclark@gmail.com>
8821eb
Acked-by: Jani Nikula <jani.nikula@intel.com>
8821eb
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
8821eb
---
8821eb
 drivers/gpu/drm/i915/i915_drv.h      |  30 ++++++++
8821eb
 drivers/gpu/drm/i915/i915_params.c   |   5 ++
98a08a
 drivers/gpu/drm/i915/intel_display.c | 134 +++++++++++++++++------------------
98a08a
 drivers/gpu/drm/i915/intel_dp.c      |   4 +-
98a08a
 4 files changed, 104 insertions(+), 69 deletions(-)
8821eb
8821eb
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
98a08a
index 9d7a7155bf02..d04ed2b2728e 100644
8821eb
--- a/drivers/gpu/drm/i915/i915_drv.h
8821eb
+++ b/drivers/gpu/drm/i915/i915_drv.h
98a08a
@@ -60,6 +60,35 @@
98a08a
 #undef WARN_ON
98a08a
 #define WARN_ON(x)		WARN(x, "WARN_ON(" #x ")")
8821eb
 
8821eb
+/* Use I915_STATE_WARN(x) and I915_STATE_WARN_ON() (rather than WARN() and
8821eb
+ * WARN_ON()) for hw state sanity checks to check for unexpected conditions
8821eb
+ * which may not necessarily be a user visible problem.  This will either
8821eb
+ * WARN() or DRM_ERROR() depending on the verbose_checks moduleparam, to
8821eb
+ * enable distros and users to tailor their preferred amount of i915 abrt
8821eb
+ * spam.
8821eb
+ */
8821eb
+#define I915_STATE_WARN(condition, format...) ({			\
8821eb
+	int __ret_warn_on = !!(condition);				\
8821eb
+	if (unlikely(__ret_warn_on)) {					\
8821eb
+		if (i915.verbose_state_checks)				\
8821eb
+			__WARN_printf(format);				\
8821eb
+		else 							\
8821eb
+			DRM_ERROR(format);				\
8821eb
+	}								\
8821eb
+	unlikely(__ret_warn_on);					\
8821eb
+})
8821eb
+
8821eb
+#define I915_STATE_WARN_ON(condition) ({				\
8821eb
+	int __ret_warn_on = !!(condition);				\
8821eb
+	if (unlikely(__ret_warn_on)) {					\
8821eb
+		if (i915.verbose_state_checks)				\
8821eb
+			__WARN_printf("WARN_ON(" #condition ")\n");	\
8821eb
+		else 							\
8821eb
+			DRM_ERROR("WARN_ON(" #condition ")\n");		\
8821eb
+	}								\
8821eb
+	unlikely(__ret_warn_on);					\
8821eb
+})
8821eb
+
8821eb
 enum pipe {
8821eb
 	INVALID_PIPE = -1,
8821eb
 	PIPE_A = 0,
98a08a
@@ -2309,6 +2338,7 @@ struct i915_params {
8821eb
 	bool disable_vtd_wa;
8821eb
 	int use_mmio_flip;
8821eb
 	bool mmio_debug;
8821eb
+	bool verbose_state_checks;
8821eb
 };
8821eb
 extern struct i915_params i915 __read_mostly;
8821eb
 
8821eb
diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c
8821eb
index c91cb2033cc5..db07153b693f 100644
8821eb
--- a/drivers/gpu/drm/i915/i915_params.c
8821eb
+++ b/drivers/gpu/drm/i915/i915_params.c
8821eb
@@ -51,6 +51,7 @@ struct i915_params i915 __read_mostly = {
8821eb
 	.disable_vtd_wa = 0,
8821eb
 	.use_mmio_flip = 0,
8821eb
 	.mmio_debug = 0,
8821eb
+	.verbose_state_checks = 1,
8821eb
 };
8821eb
 
8821eb
 module_param_named(modeset, i915.modeset, int, 0400);
8821eb
@@ -173,3 +174,7 @@ module_param_named(mmio_debug, i915.mmio_debug, bool, 0600);
8821eb
 MODULE_PARM_DESC(mmio_debug,
8821eb
 	"Enable the MMIO debug code (default: false). This may negatively "
8821eb
 	"affect performance.");
8821eb
+
8821eb
+module_param_named(verbose_state_checks, i915.verbose_state_checks, bool, 0600);
8821eb
+MODULE_PARM_DESC(verbose_state_checks,
8821eb
+	"Enable verbose logs (ie. WARN_ON()) in case of unexpected hw state conditions.");
8821eb
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
98a08a
index e7a16f119a29..76cd2205bc9c 100644
8821eb
--- a/drivers/gpu/drm/i915/intel_display.c
8821eb
+++ b/drivers/gpu/drm/i915/intel_display.c
98a08a
@@ -1024,7 +1024,7 @@ void assert_pll(struct drm_i915_private *dev_priv,
8821eb
 	reg = DPLL(pipe);
8821eb
 	val = I915_READ(reg);
8821eb
 	cur_state = !!(val & DPLL_VCO_ENABLE);
8821eb
-	WARN(cur_state != state,
8821eb
+	I915_STATE_WARN(cur_state != state,
8821eb
 	     "PLL state assertion failure (expected %s, current %s)\n",
8821eb
 	     state_string(state), state_string(cur_state));
8821eb
 }
98a08a
@@ -1040,7 +1040,7 @@ static void assert_dsi_pll(struct drm_i915_private *dev_priv, bool state)
8821eb
 	mutex_unlock(&dev_priv->dpio_lock);
8821eb
 
8821eb
 	cur_state = val & DSI_PLL_VCO_EN;
8821eb
-	WARN(cur_state != state,
8821eb
+	I915_STATE_WARN(cur_state != state,
8821eb
 	     "DSI PLL state assertion failure (expected %s, current %s)\n",
8821eb
 	     state_string(state), state_string(cur_state));
8821eb
 }
98a08a
@@ -1071,7 +1071,7 @@ void assert_shared_dpll(struct drm_i915_private *dev_priv,
8821eb
 		return;
8821eb
 
8821eb
 	cur_state = pll->get_hw_state(dev_priv, pll, &hw_state);
8821eb
-	WARN(cur_state != state,
8821eb
+	I915_STATE_WARN(cur_state != state,
8821eb
 	     "%s assertion failure (expected %s, current %s)\n",
8821eb
 	     pll->name, state_string(state), state_string(cur_state));
8821eb
 }
98a08a
@@ -1095,7 +1095,7 @@ static void assert_fdi_tx(struct drm_i915_private *dev_priv,
8821eb
 		val = I915_READ(reg);
8821eb
 		cur_state = !!(val & FDI_TX_ENABLE);
8821eb
 	}
8821eb
-	WARN(cur_state != state,
8821eb
+	I915_STATE_WARN(cur_state != state,
8821eb
 	     "FDI TX state assertion failure (expected %s, current %s)\n",
8821eb
 	     state_string(state), state_string(cur_state));
8821eb
 }
98a08a
@@ -1112,7 +1112,7 @@ static void assert_fdi_rx(struct drm_i915_private *dev_priv,
8821eb
 	reg = FDI_RX_CTL(pipe);
8821eb
 	val = I915_READ(reg);
8821eb
 	cur_state = !!(val & FDI_RX_ENABLE);
8821eb
-	WARN(cur_state != state,
8821eb
+	I915_STATE_WARN(cur_state != state,
8821eb
 	     "FDI RX state assertion failure (expected %s, current %s)\n",
8821eb
 	     state_string(state), state_string(cur_state));
8821eb
 }
98a08a
@@ -1135,7 +1135,7 @@ static void assert_fdi_tx_pll_enabled(struct drm_i915_private *dev_priv,
8821eb
 
8821eb
 	reg = FDI_TX_CTL(pipe);
8821eb
 	val = I915_READ(reg);
8821eb
-	WARN(!(val & FDI_TX_PLL_ENABLE), "FDI TX PLL assertion failure, should be active but is disabled\n");
8821eb
+	I915_STATE_WARN(!(val & FDI_TX_PLL_ENABLE), "FDI TX PLL assertion failure, should be active but is disabled\n");
8821eb
 }
8821eb
 
8821eb
 void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
98a08a
@@ -1148,7 +1148,7 @@ void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
8821eb
 	reg = FDI_RX_CTL(pipe);
8821eb
 	val = I915_READ(reg);
8821eb
 	cur_state = !!(val & FDI_RX_PLL_ENABLE);
8821eb
-	WARN(cur_state != state,
8821eb
+	I915_STATE_WARN(cur_state != state,
8821eb
 	     "FDI RX PLL assertion failure (expected %s, current %s)\n",
8821eb
 	     state_string(state), state_string(cur_state));
8821eb
 }
98a08a
@@ -1190,7 +1190,7 @@ void assert_panel_unlocked(struct drm_i915_private *dev_priv,
8821eb
 	    ((val & PANEL_UNLOCK_MASK) == PANEL_UNLOCK_REGS))
8821eb
 		locked = false;
8821eb
 
8821eb
-	WARN(panel_pipe == pipe && locked,
8821eb
+	I915_STATE_WARN(panel_pipe == pipe && locked,
8821eb
 	     "panel assertion failure, pipe %c regs locked\n",
8821eb
 	     pipe_name(pipe));
8821eb
 }
98a08a
@@ -1206,7 +1206,7 @@ static void assert_cursor(struct drm_i915_private *dev_priv,
8821eb
 	else
8821eb
 		cur_state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE;
8821eb
 
8821eb
-	WARN(cur_state != state,
8821eb
+	I915_STATE_WARN(cur_state != state,
8821eb
 	     "cursor on pipe %c assertion failure (expected %s, current %s)\n",
8821eb
 	     pipe_name(pipe), state_string(state), state_string(cur_state));
8821eb
 }
98a08a
@@ -1236,7 +1236,7 @@ void assert_pipe(struct drm_i915_private *dev_priv,
8821eb
 		cur_state = !!(val & PIPECONF_ENABLE);
8821eb
 	}
8821eb
 
8821eb
-	WARN(cur_state != state,
8821eb
+	I915_STATE_WARN(cur_state != state,
8821eb
 	     "pipe %c assertion failure (expected %s, current %s)\n",
8821eb
 	     pipe_name(pipe), state_string(state), state_string(cur_state));
8821eb
 }
98a08a
@@ -1251,7 +1251,7 @@ static void assert_plane(struct drm_i915_private *dev_priv,
8821eb
 	reg = DSPCNTR(plane);
8821eb
 	val = I915_READ(reg);
8821eb
 	cur_state = !!(val & DISPLAY_PLANE_ENABLE);
8821eb
-	WARN(cur_state != state,
8821eb
+	I915_STATE_WARN(cur_state != state,
8821eb
 	     "plane %c assertion failure (expected %s, current %s)\n",
8821eb
 	     plane_name(plane), state_string(state), state_string(cur_state));
8821eb
 }
98a08a
@@ -1271,7 +1271,7 @@ static void assert_planes_disabled(struct drm_i915_private *dev_priv,
8821eb
 	if (INTEL_INFO(dev)->gen >= 4) {
8821eb
 		reg = DSPCNTR(pipe);
8821eb
 		val = I915_READ(reg);
8821eb
-		WARN(val & DISPLAY_PLANE_ENABLE,
8821eb
+		I915_STATE_WARN(val & DISPLAY_PLANE_ENABLE,
8821eb
 		     "plane %c assertion failure, should be disabled but not\n",
8821eb
 		     plane_name(pipe));
8821eb
 		return;
98a08a
@@ -1283,7 +1283,7 @@ static void assert_planes_disabled(struct drm_i915_private *dev_priv,
8821eb
 		val = I915_READ(reg);
8821eb
 		cur_pipe = (val & DISPPLANE_SEL_PIPE_MASK) >>
8821eb
 			DISPPLANE_SEL_PIPE_SHIFT;
8821eb
-		WARN((val & DISPLAY_PLANE_ENABLE) && pipe == cur_pipe,
8821eb
+		I915_STATE_WARN((val & DISPLAY_PLANE_ENABLE) && pipe == cur_pipe,
8821eb
 		     "plane %c assertion failure, should be off on pipe %c but is still active\n",
8821eb
 		     plane_name(i), pipe_name(pipe));
8821eb
 	}
98a08a
@@ -1299,7 +1299,7 @@ static void assert_sprites_disabled(struct drm_i915_private *dev_priv,
98a08a
 	if (INTEL_INFO(dev)->gen >= 9) {
98a08a
 		for_each_sprite(pipe, sprite) {
98a08a
 			val = I915_READ(PLANE_CTL(pipe, sprite));
98a08a
-			WARN(val & PLANE_CTL_ENABLE,
98a08a
+			I915_STATE_WARN(val & PLANE_CTL_ENABLE,
98a08a
 			     "plane %d assertion failure, should be off on pipe %c but is still active\n",
98a08a
 			     sprite, pipe_name(pipe));
98a08a
 		}
98a08a
@@ -1307,20 +1307,20 @@ static void assert_sprites_disabled(struct drm_i915_private *dev_priv,
8821eb
 		for_each_sprite(pipe, sprite) {
8821eb
 			reg = SPCNTR(pipe, sprite);
8821eb
 			val = I915_READ(reg);
8821eb
-			WARN(val & SP_ENABLE,
8821eb
+			I915_STATE_WARN(val & SP_ENABLE,
8821eb
 			     "sprite %c assertion failure, should be off on pipe %c but is still active\n",
8821eb
 			     sprite_name(pipe, sprite), pipe_name(pipe));
8821eb
 		}
8821eb
 	} else if (INTEL_INFO(dev)->gen >= 7) {
8821eb
 		reg = SPRCTL(pipe);
8821eb
 		val = I915_READ(reg);
8821eb
-		WARN(val & SPRITE_ENABLE,
8821eb
+		I915_STATE_WARN(val & SPRITE_ENABLE,
8821eb
 		     "sprite %c assertion failure, should be off on pipe %c but is still active\n",
8821eb
 		     plane_name(pipe), pipe_name(pipe));
8821eb
 	} else if (INTEL_INFO(dev)->gen >= 5) {
8821eb
 		reg = DVSCNTR(pipe);
8821eb
 		val = I915_READ(reg);
8821eb
-		WARN(val & DVS_ENABLE,
8821eb
+		I915_STATE_WARN(val & DVS_ENABLE,
8821eb
 		     "sprite %c assertion failure, should be off on pipe %c but is still active\n",
8821eb
 		     plane_name(pipe), pipe_name(pipe));
8821eb
 	}
98a08a
@@ -1328,7 +1328,7 @@ static void assert_sprites_disabled(struct drm_i915_private *dev_priv,
8821eb
 
8821eb
 static void assert_vblank_disabled(struct drm_crtc *crtc)
8821eb
 {
8821eb
-	if (WARN_ON(drm_crtc_vblank_get(crtc) == 0))
8821eb
+	if (I915_STATE_WARN_ON(drm_crtc_vblank_get(crtc) == 0))
8821eb
 		drm_crtc_vblank_put(crtc);
8821eb
 }
8821eb
 
98a08a
@@ -1337,12 +1337,12 @@ static void ibx_assert_pch_refclk_enabled(struct drm_i915_private *dev_priv)
8821eb
 	u32 val;
8821eb
 	bool enabled;
8821eb
 
8821eb
-	WARN_ON(!(HAS_PCH_IBX(dev_priv->dev) || HAS_PCH_CPT(dev_priv->dev)));
8821eb
+	I915_STATE_WARN_ON(!(HAS_PCH_IBX(dev_priv->dev) || HAS_PCH_CPT(dev_priv->dev)));
8821eb
 
8821eb
 	val = I915_READ(PCH_DREF_CONTROL);
8821eb
 	enabled = !!(val & (DREF_SSC_SOURCE_MASK | DREF_NONSPREAD_SOURCE_MASK |
8821eb
 			    DREF_SUPERSPREAD_SOURCE_MASK));
8821eb
-	WARN(!enabled, "PCH refclk assertion failure, should be active but is disabled\n");
8821eb
+	I915_STATE_WARN(!enabled, "PCH refclk assertion failure, should be active but is disabled\n");
8821eb
 }
8821eb
 
8821eb
 static void assert_pch_transcoder_disabled(struct drm_i915_private *dev_priv,
98a08a
@@ -1355,7 +1355,7 @@ static void assert_pch_transcoder_disabled(struct drm_i915_private *dev_priv,
8821eb
 	reg = PCH_TRANSCONF(pipe);
8821eb
 	val = I915_READ(reg);
8821eb
 	enabled = !!(val & TRANS_ENABLE);
8821eb
-	WARN(enabled,
8821eb
+	I915_STATE_WARN(enabled,
8821eb
 	     "transcoder assertion failed, should be off on pipe %c but is still active\n",
8821eb
 	     pipe_name(pipe));
8821eb
 }
98a08a
@@ -1435,11 +1435,11 @@ static void assert_pch_dp_disabled(struct drm_i915_private *dev_priv,
8821eb
 				   enum pipe pipe, int reg, u32 port_sel)
8821eb
 {
8821eb
 	u32 val = I915_READ(reg);
8821eb
-	WARN(dp_pipe_enabled(dev_priv, pipe, port_sel, val),
8821eb
+	I915_STATE_WARN(dp_pipe_enabled(dev_priv, pipe, port_sel, val),
8821eb
 	     "PCH DP (0x%08x) enabled on transcoder %c, should be disabled\n",
8821eb
 	     reg, pipe_name(pipe));
8821eb
 
8821eb
-	WARN(HAS_PCH_IBX(dev_priv->dev) && (val & DP_PORT_EN) == 0
8821eb
+	I915_STATE_WARN(HAS_PCH_IBX(dev_priv->dev) && (val & DP_PORT_EN) == 0
8821eb
 	     && (val & DP_PIPEB_SELECT),
8821eb
 	     "IBX PCH dp port still using transcoder B\n");
8821eb
 }
98a08a
@@ -1448,11 +1448,11 @@ static void assert_pch_hdmi_disabled(struct drm_i915_private *dev_priv,
8821eb
 				     enum pipe pipe, int reg)
8821eb
 {
8821eb
 	u32 val = I915_READ(reg);
8821eb
-	WARN(hdmi_pipe_enabled(dev_priv, pipe, val),
8821eb
+	I915_STATE_WARN(hdmi_pipe_enabled(dev_priv, pipe, val),
8821eb
 	     "PCH HDMI (0x%08x) enabled on transcoder %c, should be disabled\n",
8821eb
 	     reg, pipe_name(pipe));
8821eb
 
8821eb
-	WARN(HAS_PCH_IBX(dev_priv->dev) && (val & SDVO_ENABLE) == 0
8821eb
+	I915_STATE_WARN(HAS_PCH_IBX(dev_priv->dev) && (val & SDVO_ENABLE) == 0
8821eb
 	     && (val & SDVO_PIPE_B_SELECT),
8821eb
 	     "IBX PCH hdmi port still using transcoder B\n");
8821eb
 }
98a08a
@@ -1469,13 +1469,13 @@ static void assert_pch_ports_disabled(struct drm_i915_private *dev_priv,
8821eb
 
8821eb
 	reg = PCH_ADPA;
8821eb
 	val = I915_READ(reg);
8821eb
-	WARN(adpa_pipe_enabled(dev_priv, pipe, val),
8821eb
+	I915_STATE_WARN(adpa_pipe_enabled(dev_priv, pipe, val),
8821eb
 	     "PCH VGA enabled on transcoder %c, should be disabled\n",
8821eb
 	     pipe_name(pipe));
8821eb
 
8821eb
 	reg = PCH_LVDS;
8821eb
 	val = I915_READ(reg);
8821eb
-	WARN(lvds_pipe_enabled(dev_priv, pipe, val),
8821eb
+	I915_STATE_WARN(lvds_pipe_enabled(dev_priv, pipe, val),
8821eb
 	     "PCH LVDS enabled on transcoder %c, should be disabled\n",
8821eb
 	     pipe_name(pipe));
8821eb
 
98a08a
@@ -5382,25 +5382,25 @@ static void intel_connector_check_state(struct intel_connector *connector)
8821eb
 		if (connector->mst_port)
8821eb
 			return;
8821eb
 
8821eb
-		WARN(connector->base.dpms == DRM_MODE_DPMS_OFF,
8821eb
+		I915_STATE_WARN(connector->base.dpms == DRM_MODE_DPMS_OFF,
8821eb
 		     "wrong connector dpms state\n");
8821eb
-		WARN(connector->base.encoder != &encoder->base,
8821eb
+		I915_STATE_WARN(connector->base.encoder != &encoder->base,
8821eb
 		     "active connector not linked to encoder\n");
8821eb
 
8821eb
 		if (encoder) {
8821eb
-			WARN(!encoder->connectors_active,
8821eb
+			I915_STATE_WARN(!encoder->connectors_active,
8821eb
 			     "encoder->connectors_active not set\n");
8821eb
 
8821eb
 			encoder_enabled = encoder->get_hw_state(encoder, &pipe);
8821eb
-			WARN(!encoder_enabled, "encoder not enabled\n");
8821eb
-			if (WARN_ON(!encoder->base.crtc))
8821eb
+			I915_STATE_WARN(!encoder_enabled, "encoder not enabled\n");
8821eb
+			if (I915_STATE_WARN_ON(!encoder->base.crtc))
8821eb
 				return;
8821eb
 
8821eb
 			crtc = encoder->base.crtc;
8821eb
 
8821eb
-			WARN(!crtc->enabled, "crtc not enabled\n");
8821eb
-			WARN(!to_intel_crtc(crtc)->active, "crtc not active\n");
8821eb
-			WARN(pipe != to_intel_crtc(crtc)->pipe,
8821eb
+			I915_STATE_WARN(!crtc->enabled, "crtc not enabled\n");
8821eb
+			I915_STATE_WARN(!to_intel_crtc(crtc)->active, "crtc not active\n");
8821eb
+			I915_STATE_WARN(pipe != to_intel_crtc(crtc)->pipe,
8821eb
 			     "encoder active on the wrong pipe\n");
8821eb
 		}
8821eb
 	}
98a08a
@@ -7810,24 +7810,24 @@ static void assert_can_disable_lcpll(struct drm_i915_private *dev_priv)
8821eb
 	struct intel_crtc *crtc;
8821eb
 
8821eb
 	for_each_intel_crtc(dev, crtc)
8821eb
-		WARN(crtc->active, "CRTC for pipe %c enabled\n",
8821eb
+		I915_STATE_WARN(crtc->active, "CRTC for pipe %c enabled\n",
8821eb
 		     pipe_name(crtc->pipe));
8821eb
 
8821eb
-	WARN(I915_READ(HSW_PWR_WELL_DRIVER), "Power well on\n");
8821eb
-	WARN(I915_READ(SPLL_CTL) & SPLL_PLL_ENABLE, "SPLL enabled\n");
8821eb
-	WARN(I915_READ(WRPLL_CTL1) & WRPLL_PLL_ENABLE, "WRPLL1 enabled\n");
8821eb
-	WARN(I915_READ(WRPLL_CTL2) & WRPLL_PLL_ENABLE, "WRPLL2 enabled\n");
8821eb
-	WARN(I915_READ(PCH_PP_STATUS) & PP_ON, "Panel power on\n");
8821eb
-	WARN(I915_READ(BLC_PWM_CPU_CTL2) & BLM_PWM_ENABLE,
8821eb
+	I915_STATE_WARN(I915_READ(HSW_PWR_WELL_DRIVER), "Power well on\n");
8821eb
+	I915_STATE_WARN(I915_READ(SPLL_CTL) & SPLL_PLL_ENABLE, "SPLL enabled\n");
8821eb
+	I915_STATE_WARN(I915_READ(WRPLL_CTL1) & WRPLL_PLL_ENABLE, "WRPLL1 enabled\n");
8821eb
+	I915_STATE_WARN(I915_READ(WRPLL_CTL2) & WRPLL_PLL_ENABLE, "WRPLL2 enabled\n");
8821eb
+	I915_STATE_WARN(I915_READ(PCH_PP_STATUS) & PP_ON, "Panel power on\n");
8821eb
+	I915_STATE_WARN(I915_READ(BLC_PWM_CPU_CTL2) & BLM_PWM_ENABLE,
8821eb
 	     "CPU PWM1 enabled\n");
8821eb
 	if (IS_HASWELL(dev))
8821eb
-		WARN(I915_READ(HSW_BLC_PWM2_CTL) & BLM_PWM_ENABLE,
8821eb
+		I915_STATE_WARN(I915_READ(HSW_BLC_PWM2_CTL) & BLM_PWM_ENABLE,
8821eb
 		     "CPU PWM2 enabled\n");
8821eb
-	WARN(I915_READ(BLC_PWM_PCH_CTL1) & BLM_PCH_PWM_ENABLE,
8821eb
+	I915_STATE_WARN(I915_READ(BLC_PWM_PCH_CTL1) & BLM_PCH_PWM_ENABLE,
8821eb
 	     "PCH PWM1 enabled\n");
8821eb
-	WARN(I915_READ(UTIL_PIN_CTL) & UTIL_PIN_ENABLE,
8821eb
+	I915_STATE_WARN(I915_READ(UTIL_PIN_CTL) & UTIL_PIN_ENABLE,
8821eb
 	     "Utility pin enabled\n");
8821eb
-	WARN(I915_READ(PCH_GTC_CTL) & PCH_GTC_ENABLE, "PCH GTC enabled\n");
8821eb
+	I915_STATE_WARN(I915_READ(PCH_GTC_CTL) & PCH_GTC_ENABLE, "PCH GTC enabled\n");
8821eb
 
8821eb
 	/*
8821eb
 	 * In theory we can still leave IRQs enabled, as long as only the HPD
98a08a
@@ -7835,7 +7835,7 @@ static void assert_can_disable_lcpll(struct drm_i915_private *dev_priv)
8821eb
 	 * gen-specific and since we only disable LCPLL after we fully disable
8821eb
 	 * the interrupts, the check below should be enough.
8821eb
 	 */
8821eb
-	WARN(intel_irqs_enabled(dev_priv), "IRQs enabled\n");
8821eb
+	I915_STATE_WARN(intel_irqs_enabled(dev_priv), "IRQs enabled\n");
8821eb
 }
8821eb
 
8821eb
 static uint32_t hsw_read_dcomp(struct drm_i915_private *dev_priv)
98a08a
@@ -10742,7 +10742,7 @@ check_connector_state(struct drm_device *dev)
8821eb
 		 * ->get_hw_state callbacks. */
8821eb
 		intel_connector_check_state(connector);
8821eb
 
8821eb
-		WARN(&connector->new_encoder->base != connector->base.encoder,
8821eb
+		I915_STATE_WARN(&connector->new_encoder->base != connector->base.encoder,
8821eb
 		     "connector's staged encoder doesn't match current encoder\n");
8821eb
 	}
8821eb
 }
98a08a
@@ -10762,9 +10762,9 @@ check_encoder_state(struct drm_device *dev)
8821eb
 			      encoder->base.base.id,
8821eb
 			      encoder->base.name);
8821eb
 
8821eb
-		WARN(&encoder->new_crtc->base != encoder->base.crtc,
8821eb
+		I915_STATE_WARN(&encoder->new_crtc->base != encoder->base.crtc,
8821eb
 		     "encoder's stage crtc doesn't match current crtc\n");
8821eb
-		WARN(encoder->connectors_active && !encoder->base.crtc,
8821eb
+		I915_STATE_WARN(encoder->connectors_active && !encoder->base.crtc,
8821eb
 		     "encoder's active_connectors set, but no crtc\n");
8821eb
 
8821eb
 		list_for_each_entry(connector, &dev->mode_config.connector_list,
98a08a
@@ -10783,19 +10783,19 @@ check_encoder_state(struct drm_device *dev)
8821eb
 		if (!enabled && encoder->base.encoder_type == DRM_MODE_ENCODER_DPMST)
8821eb
 			continue;
8821eb
 
8821eb
-		WARN(!!encoder->base.crtc != enabled,
8821eb
+		I915_STATE_WARN(!!encoder->base.crtc != enabled,
8821eb
 		     "encoder's enabled state mismatch "
8821eb
 		     "(expected %i, found %i)\n",
8821eb
 		     !!encoder->base.crtc, enabled);
8821eb
-		WARN(active && !encoder->base.crtc,
8821eb
+		I915_STATE_WARN(active && !encoder->base.crtc,
8821eb
 		     "active encoder with no crtc\n");
8821eb
 
8821eb
-		WARN(encoder->connectors_active != active,
8821eb
+		I915_STATE_WARN(encoder->connectors_active != active,
8821eb
 		     "encoder's computed active state doesn't match tracked active state "
8821eb
 		     "(expected %i, found %i)\n", active, encoder->connectors_active);
8821eb
 
8821eb
 		active = encoder->get_hw_state(encoder, &pipe);
8821eb
-		WARN(active != encoder->connectors_active,
8821eb
+		I915_STATE_WARN(active != encoder->connectors_active,
8821eb
 		     "encoder's hw state doesn't match sw tracking "
8821eb
 		     "(expected %i, found %i)\n",
8821eb
 		     encoder->connectors_active, active);
98a08a
@@ -10804,7 +10804,7 @@ check_encoder_state(struct drm_device *dev)
8821eb
 			continue;
8821eb
 
8821eb
 		tracked_pipe = to_intel_crtc(encoder->base.crtc)->pipe;
8821eb
-		WARN(active && pipe != tracked_pipe,
8821eb
+		I915_STATE_WARN(active && pipe != tracked_pipe,
8821eb
 		     "active encoder's pipe doesn't match"
8821eb
 		     "(expected %i, found %i)\n",
8821eb
 		     tracked_pipe, pipe);
98a08a
@@ -10829,7 +10829,7 @@ check_crtc_state(struct drm_device *dev)
8821eb
 		DRM_DEBUG_KMS("[CRTC:%d]\n",
8821eb
 			      crtc->base.base.id);
8821eb
 
8821eb
-		WARN(crtc->active && !crtc->base.enabled,
8821eb
+		I915_STATE_WARN(crtc->active && !crtc->base.enabled,
8821eb
 		     "active crtc, but not enabled in sw tracking\n");
8821eb
 
8821eb
 		for_each_intel_encoder(dev, encoder) {
98a08a
@@ -10840,10 +10840,10 @@ check_crtc_state(struct drm_device *dev)
8821eb
 				active = true;
8821eb
 		}
8821eb
 
8821eb
-		WARN(active != crtc->active,
8821eb
+		I915_STATE_WARN(active != crtc->active,
8821eb
 		     "crtc's computed active state doesn't match tracked active state "
8821eb
 		     "(expected %i, found %i)\n", active, crtc->active);
8821eb
-		WARN(enabled != crtc->base.enabled,
8821eb
+		I915_STATE_WARN(enabled != crtc->base.enabled,
8821eb
 		     "crtc's computed enabled state doesn't match tracked enabled state "
8821eb
 		     "(expected %i, found %i)\n", enabled, crtc->base.enabled);
8821eb
 
98a08a
@@ -10863,13 +10863,13 @@ check_crtc_state(struct drm_device *dev)
8821eb
 				encoder->get_config(encoder, &pipe_config);
8821eb
 		}
8821eb
 
8821eb
-		WARN(crtc->active != active,
8821eb
+		I915_STATE_WARN(crtc->active != active,
8821eb
 		     "crtc active state doesn't match with hw state "
8821eb
 		     "(expected %i, found %i)\n", crtc->active, active);
8821eb
 
8821eb
 		if (active &&
8821eb
 		    !intel_pipe_config_compare(dev, &crtc->config, &pipe_config)) {
8821eb
-			WARN(1, "pipe state doesn't match!\n");
8821eb
+			I915_STATE_WARN(1, "pipe state doesn't match!\n");
8821eb
 			intel_dump_pipe_config(crtc, &pipe_config,
8821eb
 					       "[hw state]");
8821eb
 			intel_dump_pipe_config(crtc, &crtc->config,
98a08a
@@ -10897,14 +10897,14 @@ check_shared_dpll_state(struct drm_device *dev)
8821eb
 
8821eb
 		active = pll->get_hw_state(dev_priv, pll, &dpll_hw_state);
8821eb
 
98a08a
-		WARN(pll->active > hweight32(pll->config.crtc_mask),
98a08a
+		I915_STATE_WARN(pll->active > hweight32(pll->config.crtc_mask),
8821eb
 		     "more active pll users than references: %i vs %i\n",
98a08a
 		     pll->active, hweight32(pll->config.crtc_mask));
8821eb
-		WARN(pll->active && !pll->on,
8821eb
+		I915_STATE_WARN(pll->active && !pll->on,
8821eb
 		     "pll in active use but not on in sw tracking\n");
8821eb
-		WARN(pll->on && !pll->active,
8821eb
+		I915_STATE_WARN(pll->on && !pll->active,
8821eb
 		     "pll in on but not on in use in sw tracking\n");
8821eb
-		WARN(pll->on != active,
8821eb
+		I915_STATE_WARN(pll->on != active,
8821eb
 		     "pll on state mismatch (expected %i, found %i)\n",
8821eb
 		     pll->on, active);
8821eb
 
98a08a
@@ -10914,14 +10914,14 @@ check_shared_dpll_state(struct drm_device *dev)
8821eb
 			if (crtc->active && intel_crtc_to_shared_dpll(crtc) == pll)
8821eb
 				active_crtcs++;
8821eb
 		}
8821eb
-		WARN(pll->active != active_crtcs,
8821eb
+		I915_STATE_WARN(pll->active != active_crtcs,
8821eb
 		     "pll active crtcs mismatch (expected %i, found %i)\n",
8821eb
 		     pll->active, active_crtcs);
98a08a
-		WARN(hweight32(pll->config.crtc_mask) != enabled_crtcs,
98a08a
+		I915_STATE_WARN(hweight32(pll->config.crtc_mask) != enabled_crtcs,
8821eb
 		     "pll enabled crtcs mismatch (expected %i, found %i)\n",
98a08a
 		     hweight32(pll->config.crtc_mask), enabled_crtcs);
8821eb
 
98a08a
-		WARN(pll->on && memcmp(&pll->config.hw_state, &dpll_hw_state,
98a08a
+		I915_STATE_WARN(pll->on && memcmp(&pll->config.hw_state, &dpll_hw_state,
8821eb
 				       sizeof(dpll_hw_state)),
8821eb
 		     "pll hw state mismatch\n");
8821eb
 	}
8821eb
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
98a08a
index 5cecc20efa71..841e3d0b223d 100644
8821eb
--- a/drivers/gpu/drm/i915/intel_dp.c
8821eb
+++ b/drivers/gpu/drm/i915/intel_dp.c
98a08a
@@ -1558,7 +1558,7 @@ void intel_edp_panel_vdd_on(struct intel_dp *intel_dp)
98a08a
 	vdd = edp_panel_vdd_on(intel_dp);
98a08a
 	pps_unlock(intel_dp);
98a08a
 
98a08a
-	WARN(!vdd, "eDP port %c VDD already requested on\n",
98a08a
+	I915_STATE_WARN(!vdd, "eDP port %c VDD already requested on\n",
98a08a
 	     port_name(dp_to_dig_port(intel_dp)->port));
98a08a
 }
98a08a
 
98a08a
@@ -1642,7 +1642,7 @@ static void edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync)
8821eb
 	if (!is_edp(intel_dp))
8821eb
 		return;
8821eb
 
98a08a
-	WARN(!intel_dp->want_panel_vdd, "eDP port %c VDD not forced on",
98a08a
+	I915_STATE_WARN(!intel_dp->want_panel_vdd, "eDP port %c VDD not forced on",
98a08a
 	     port_name(dp_to_dig_port(intel_dp)->port));
8821eb
 
8821eb
 	intel_dp->want_panel_vdd = false;
8821eb
-- 
8821eb
2.1.0
8821eb