[Intel-gfx] [PATCH 5/6] drm/i915: Add helpers to reduce (repetitive) noise

Joonas Lahtinen joonas.lahtinen at linux.intel.com
Thu Dec 17 11:25:50 PST 2015


Add helpers to reduce the amount of noise. Use the i915.debug parameter
introduced in the previous patch to decide on whether to display all
debug messages or just ones that are meaningful to end user.

Take for example the CI environment, we want to see all possible warning
messages even though the system continues to operate. Opposite to that is
environment in daily use, repeating errors should be displayed once to
indicate the need for a bug report, but if the machine continues to work,
we should not spam the user continuously.

Cc: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 37fce5a..07240af 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -110,6 +110,32 @@
 	unlikely(__ret_warn_on);					\
 })
 
+#define I915_DEBUG(condition, format...) ({				\
+	int __ret_debug_on = !!(condition);				\
+	if (unlikely(__ret_debug_on))					\
+		WARN(unlikely(i915.debug), format);			\
+	unlikely(__ret_debug_on);					\
+})
+
+#define I915_DEBUG_ON(condition) ({					\
+	static const char __debug_on_txt[] =				\
+		"I915_DEBUG_ON(" __stringify(condition) ")\n";		\
+	int __ret_debug_on = !!(condition);				\
+	if (unlikely( __ret_debug_on)) 					\
+		WARN(unlikely(i915.debug), __debug_on_txt);		\
+	unlikely(__ret_debug_on);					\
+})
+
+#define I915_WARN_RECUR(condition, format...) ({			\
+	static bool __section(.data.unlikely) __warned;			\
+	int __ret_warn_on = !!(condition);				\
+	if (unlikely(__ret_warn_on)) {					\
+		if (WARN(unlikely(!__warned || i915.debug), format))	\
+			__warned = true;				\
+	}								\
+	unlikely(__ret_debug_on);					\
+})
+
 static inline const char *yesno(bool v)
 {
 	return v ? "yes" : "no";
-- 
2.4.3



More information about the Intel-gfx mailing list