[Intel-gfx] [PATCH 7/7] drm/i915/debug: Warn when waiting on condition timeouts

Mika Kuoppala mika.kuoppala at linux.intel.com
Tue May 17 15:43:28 UTC 2016


Warn if we timeout on waiting register or other condition.

Signed-off-by: Mika Kuoppala <mika.kuoppala at intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h     | 25 ++++++++++++++++++++-----
 drivers/gpu/drm/i915/intel_drv.h    | 10 +++++++++-
 drivers/gpu/drm/i915/intel_uncore.c | 10 +++++-----
 3 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index ccf6747894b1..3d03a17a8b7c 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2873,11 +2873,26 @@ static inline bool intel_vgpu_active(struct drm_i915_private *dev_priv)
 	return dev_priv->vgpu.active;
 }
 
-int intel_wait_until_register(struct drm_i915_private *dev_priv,
-			      i915_reg_t reg,
-			      u32 mask,
-			      u32 value,
-			      unsigned long timeout_ms);
+int __intel_wait_until_register(struct drm_i915_private *dev_priv,
+				i915_reg_t reg,
+				u32 mask,
+				u32 value,
+				unsigned long timeout_ms);
+
+#if defined(CONFIG_DRM_I915_DEBUG)
+#define intel_wait_until_register(dev_priv, reg, mask, value, timeout_ms) ({ \
+	int __ret; \
+	WARN_ON(__ret = __intel_wait_until_register((dev_priv), \
+						    (reg), (mask), \
+						    (value), \
+						    (timeout_ms))); \
+	__ret; \
+	})
+#else
+#define intel_wait_until_register(dev_priv, reg, mask, value, timeout_ms) \
+	__intel_wait_until_register((dev_priv), \
+				    (reg), (mask), (value), timeout_ms);
+#endif
 
 #define wait_until_reg(reg, mask, value, timeout_ms) ({ \
 	if (__builtin_constant_p(timeout_ms)) \
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 1b03461e75e4..917b649f84b6 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -80,7 +80,15 @@
 	ret__;								\
 })
 
-#define wait_for(COND, MS)  __wait_for_ms((COND), (MS), 5)
+#if defined(CONFIG_DRM_I915_DEBUG)
+#define wait_for(COND, MS)  ({ \
+	int r__; \
+	WARN_ON(r__ = __wait_for_ms((COND), (MS), 5)); \
+	r__;\
+	})
+#else
+#define wait_for(COND, MS) __wait_for_ms((COND), (MS), 5)
+#endif
 
 /* If CONFIG_PREEMPT_COUNT is disabled, in_atomic() always reports false. */
 #if defined(CONFIG_DRM_I915_DEBUG) && defined(CONFIG_PREEMPT_COUNT)
diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index f72420e00621..def601ba93d4 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -1859,11 +1859,11 @@ intel_uncore_forcewake_for_reg(struct drm_i915_private *dev_priv,
 	return fw_domains;
 }
 
-int intel_wait_until_register(struct drm_i915_private *dev_priv,
-			      i915_reg_t reg,
-			      u32 mask,
-			      u32 value,
-			      unsigned long timeout_ms)
+int __intel_wait_until_register(struct drm_i915_private *dev_priv,
+				i915_reg_t reg,
+				u32 mask,
+				u32 value,
+				unsigned long timeout_ms)
 {
 	return wait_for((I915_READ(reg) & mask) == value, timeout_ms);
 }
-- 
2.5.0



More information about the Intel-gfx mailing list