All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v3 3/4] drm/i915: Highlight modified i915 params in gpu error state
Date: Wed, 14 Jun 2017 18:15:50 +0000	[thread overview]
Message-ID: <20170614181551.47136-4-michal.wajdeczko@intel.com> (raw)
In-Reply-To: <20170614181551.47136-1-michal.wajdeczko@intel.com>

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 --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
 }
-- 
2.7.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-06-14 18:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-14 18:15 [PATCH v3 0/4] drm/i915: Misc improvements around module params Michal Wajdeczko
2017-06-14 18:15 ` [PATCH v3 1/4] drm/i915: Rename lvds_use_ssc modparam to panel_use_ssc Michal Wajdeczko
2017-06-14 18:15 ` [PATCH v3 2/4] drm/i915: Extend PARAMS_FOR_EACH macro with more data Michal Wajdeczko
2017-06-15 19:24   ` Jani Nikula
2017-06-14 18:15 ` Michal Wajdeczko [this message]
2017-06-14 18:15 ` [PATCH v3 4/4] drm/i915/debugfs: Highlight modified i915 params Michal Wajdeczko
2017-06-14 18:33 ` ✓ Fi.CI.BAT: success for drm/i915: Misc improvements around module params (rev3) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170614181551.47136-4-michal.wajdeczko@intel.com \
    --to=michal.wajdeczko@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.