[Intel-gfx] [PATCH v2 3/4] drm/i915: Add WARN_RECUR and i915.recur_warnings

Joonas Lahtinen joonas.lahtinen at linux.intel.com
Fri Dec 18 03:08:17 PST 2015


Add i915.recur_warnings parameter to control output in cases where the warning
is of recurring type and is potentially called from multiple paths. Using just
WARN_ONCE would mask out other calling paths but one, this is not desireable
on developer machine or CI system, but is a compromise to be made on end user
system not to flood the message and overflow all possible kernel log buffers.

When the recur_warnings option is false (default), WARN_RECUR will reduce to
WARN_ONCE.

v2:
- More upstreamable macro name and parameter (Chris)
- Squash a hunk that slipped to next patch

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    | 10 ++++++++++
 drivers/gpu/drm/i915/i915_params.c |  6 ++++++
 drivers/gpu/drm/i915/i915_params.h |  1 +
 3 files changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 3ce609f..e1ca61f 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -76,6 +76,16 @@
 #undef WARN_ON_ONCE
 #define WARN_ON_ONCE(x) WARN_ONCE((x), "WARN_ON_ONCE(" __stringify(x) ")")
 
+#define 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.recur_warnings), format))	\
+			__warned = true;				\
+	unlikely(__ret_warn_on);					\
+})
+
 #define MISSING_CASE(x) WARN(1, "Missing switch case (%lu) in %s\n", \
 			     (long) (x), __func__);
 
diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c
index 8d90c25..f75dac9 100644
--- a/drivers/gpu/drm/i915/i915_params.c
+++ b/drivers/gpu/drm/i915/i915_params.c
@@ -57,6 +57,7 @@ struct i915_params i915 __read_mostly = {
 	.edp_vswing = 0,
 	.enable_guc_submission = false,
 	.guc_log_level = -1,
+	.recur_warnings = false,
 };
 
 module_param_named(modeset, i915.modeset, int, 0400);
@@ -203,3 +204,8 @@ MODULE_PARM_DESC(enable_guc_submission, "Enable GuC submission (default:false)")
 module_param_named(guc_log_level, i915.guc_log_level, int, 0400);
 MODULE_PARM_DESC(guc_log_level,
 	"GuC firmware logging level (-1:disabled (default), 0-3:enabled)");
+
+module_param_named(recur_warnings, i915.recur_warnings, bool, 0600);
+MODULE_PARM_DESC(recur_warnings,
+	"Display all warnings of recurring nature (default: false). "
+	"For developers only.");
diff --git a/drivers/gpu/drm/i915/i915_params.h b/drivers/gpu/drm/i915/i915_params.h
index 5299290..23be479 100644
--- a/drivers/gpu/drm/i915/i915_params.h
+++ b/drivers/gpu/drm/i915/i915_params.h
@@ -60,6 +60,7 @@ struct i915_params {
 	bool enable_guc_submission;
 	bool verbose_state_checks;
 	bool nuclear_pageflip;
+	bool recur_warnings;
 };
 
 extern struct i915_params i915 __read_mostly;
-- 
2.4.3



More information about the Intel-gfx mailing list