diff mbox

[v3,3/4] drm/i915: Highlight modified i915 params in gpu error state

Message ID 20170614181551.47136-4-michal.wajdeczko@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michal Wajdeczko June 14, 2017, 6:15 p.m. UTC
We now know types and default values for all params.
Use dedicated err_print macros to dump them in gpu error state
and flag any that was modified.

Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_drv.h       | 20 ++++++++++++++++++++
 drivers/gpu/drm/i915/i915_gpu_error.c | 30 ++++++++++++++----------------
 2 files changed, 34 insertions(+), 16 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 38ef734..8bd6234 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -252,6 +252,26 @@  static inline const char *enableddisabled(bool v)
 	return v ? "enabled" : "disabled";
 }
 
+static inline bool is_equal_int(int a, int b)
+{
+	return a == b;
+}
+
+static inline bool is_equal_uint(unsigned int a, unsigned int b)
+{
+	return a == b;
+}
+
+static inline bool is_equal_bool(bool a, bool b)
+{
+	return a == b;
+}
+
+static inline bool is_equal_charp(const char *a, const char *b)
+{
+	return a && b ? !strcmp(a, b) : a == b;
+}
+
 enum pipe {
 	INVALID_PIPE = -1,
 	PIPE_A = 0,
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index 000f733..3e388b3 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -546,27 +546,25 @@  static void err_print_capabilities(struct drm_i915_error_state_buf *m,
 #undef PRINT_FLAG
 }
 
-static __always_inline void err_print_param(struct drm_i915_error_state_buf *m,
-					    const char *name,
-					    const char *type,
-					    const void *x)
-{
-	if (!__builtin_strcmp(type, "bool"))
-		err_printf(m, "i915.%s=%s\n", name, yesno(*(const bool *)x));
-	else if (!__builtin_strcmp(type, "int"))
-		err_printf(m, "i915.%s=%d\n", name, *(const int *)x);
-	else if (!__builtin_strcmp(type, "uint"))
-		err_printf(m, "i915.%s=%u\n", name, *(const unsigned int *)x);
-	else if (!__builtin_strcmp(type, "charp"))
-		err_printf(m, "i915.%s=%s\n", name, *(const char **)x);
-	else
-		BUILD_BUG();
+#define err_print_param_int(m, name, x, flag) \
+	err_printf(m, "i915.%s=%d%s\n", name, x, flag);
+#define err_print_param_uint(m, name, x, flag) \
+	err_printf(m, "i915.%s=%u%s\n", name, x, flag);
+#define err_print_param_bool(m, name, x, flag) \
+	err_printf(m, "i915.%s=%s%s\n", name, yesno(x), flag);
+#define err_print_param_charp(m, name, x, flag) \
+	err_printf(m, "i915.%s=%s%s\n", name, x, flag);
+
+static inline const char *param_flag(bool modified)
+{
+	return modified ? " [modified]" : "";
 }
 
 static void err_print_params(struct drm_i915_error_state_buf *m,
 			     const struct i915_params *p)
 {
-#define PRINT(X, T, V, U, M, B, D) err_print_param(m, #X, #T, &p->X);
+#define PRINT(X, T, V, U, M, B, D) \
+	err_print_param_##T(m, #X, p->X, param_flag(!is_equal_##T(V, p->X)));
 	I915_PARAMS_FOR_EACH(PRINT);
 #undef PRINT
 }