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 v2 3/3] drm/i915/debugfs: Highlight modified i915 params
Date: Thu,  8 Jun 2017 15:41:38 +0000	[thread overview]
Message-ID: <20170608154138.44000-1-michal.wajdeczko@intel.com> (raw)
In-Reply-To: <20170608150734.42296-1-michal.wajdeczko@intel.com>

We know default values for all params and we know which params are safe
to change. Mark params that were changed when dumping them in debugfs.

v2: simplify is_default calculation for strings (Chris)

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_debugfs.c | 52 ++++++++++++++++++++++++++++---------
 1 file changed, 40 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 7a2f0b8..03381a1 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -35,20 +35,41 @@ static inline struct drm_i915_private *node_to_i915(struct drm_info_node *node)
 	return to_i915(node->minor->dev);
 }
 
+static inline const char *param_diagnostic(bool is_default, bool is_unsafe)
+{
+	if (is_default)
+		return "";
+	if (is_unsafe)
+		return " [modified *unsafe*]";
+	return " [modified]";
+}
+
 static __always_inline void seq_print_param(struct seq_file *m,
 					    const char *name,
 					    const char *type,
-					    const void *x)
-{
-	if (!__builtin_strcmp(type, "bool"))
-		seq_printf(m, "i915.%s=%s\n", name, yesno(*(const bool *)x));
-	else if (!__builtin_strcmp(type, "int"))
-		seq_printf(m, "i915.%s=%d\n", name, *(const int *)x);
-	else if (!__builtin_strcmp(type, "uint"))
-		seq_printf(m, "i915.%s=%u\n", name, *(const unsigned int *)x);
-	else if (!__builtin_strcmp(type, "charp"))
-		seq_printf(m, "i915.%s=%s\n", name, *(const char **)x);
-	else
+					    const void *x,
+					    const void *v,
+					    bool is_unsafe)
+{
+	if (!__builtin_strcmp(type, "bool")) {
+		bool is_default = *(const bool *)x == *(const bool *)v;
+		seq_printf(m, "i915.%s=%s%s\n", name, yesno(*(const bool *)x),
+			   param_diagnostic(is_default, is_unsafe));
+	} else if (!__builtin_strcmp(type, "int")) {
+		bool is_default = *(const int *)x == *(const int *)v;
+		seq_printf(m, "i915.%s=%d%s\n", name, *(const int *)x,
+			   param_diagnostic(is_default, is_unsafe));
+	} else if (!__builtin_strcmp(type, "uint")) {
+		bool is_default = *(const uint *)x == *(const uint *)v;
+		seq_printf(m, "i915.%s=%u%s\n", name, *(const unsigned int *)x,
+			   param_diagnostic(is_default, is_unsafe));
+	} else if (!__builtin_strcmp(type, "charp")) {
+		const char *new = *(const char **)x;
+		const char *old = *(const char **)v;
+		bool is_default = old && new ? !strcmp(old, new) : old == new;
+		seq_printf(m, "i915.%s=%s%s\n", name, *(const char **)x,
+			   param_diagnostic(is_default, is_unsafe));
+	} else
 		BUILD_BUG();
 }
 
@@ -66,9 +87,16 @@ static int i915_capabilities(struct seq_file *m, void *data)
 #undef PRINT_FLAG
 
 	kernel_param_lock(THIS_MODULE);
-#define PRINT_PARAM(T, X, V, M, S, B, D) seq_print_param(m, #X, #T, &i915.X);
+#define FLAG false
+#define FLAG_unsafe true
+#define PRINT_PARAM(T, X, V, M, S, B, D) do { \
+		typeof(i915.X) __v = V; \
+		seq_print_param(m, #X, #T, &i915.X, &__v, FLAG##S); \
+	} while(0);
 	I915_PARAMS_FOR_EACH(PRINT_PARAM);
 #undef PRINT_PARAM
+#undef FLAG
+#undef FLAG_unsafe
 	kernel_param_unlock(THIS_MODULE);
 
 	return 0;
-- 
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-08 15:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-08 15:07 [PATCH 0/3] drm/i915: Misc improvements around module params Michal Wajdeczko
2017-06-08 15:07 ` [PATCH 1/3] drm/i915: Rename i915.panel_use_ssc field to lvds_use_ssc Michal Wajdeczko
2017-06-08 16:03   ` Ville Syrjälä
2017-06-08 16:22     ` Michal Wajdeczko
2017-06-08 20:00       ` Chris Wilson
2017-06-08 15:07 ` [PATCH 2/3] drm/i915: Extend PARAMS_FOR_EACH macro with more data Michal Wajdeczko
2017-06-08 15:07 ` [PATCH 3/3] drm/i915/debugfs: Highlight modified i915 params Michal Wajdeczko
2017-06-08 15:25   ` Chris Wilson
2017-06-08 15:26 ` ✓ Fi.CI.BAT: success for drm/i915: Misc improvements around module params Patchwork
2017-06-08 15:41 ` Michal Wajdeczko [this message]
2017-06-09 10:27 [PATCH v2 0/3] " Michal Wajdeczko
2017-06-09 10:27 ` [PATCH v2 3/3] drm/i915/debugfs: Highlight modified i915 params Michal Wajdeczko
2017-06-09 11:54   ` Fiedorowicz, Lukasz

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=20170608154138.44000-1-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.