From patchwork Fri Jun 9 10:27:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wajdeczko X-Patchwork-Id: 9777965 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2FBD160350 for ; Fri, 9 Jun 2017 10:28:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F394285E8 for ; Fri, 9 Jun 2017 10:28:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13F6128604; Fri, 9 Jun 2017 10:28:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9A5C3285E8 for ; Fri, 9 Jun 2017 10:28:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 175456E5D4; Fri, 9 Jun 2017 10:28:14 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id E9BBA6E5BD for ; Fri, 9 Jun 2017 10:28:11 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP; 09 Jun 2017 03:28:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.39,317,1493708400"; d="scan'208"; a="1158509232" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 09 Jun 2017 03:28:09 -0700 Received: from mwajdecz-MOBL1.ger.corp.intel.com (mwajdecz-mobl1.ger.corp.intel.com [172.28.174.25]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id v59AS0qY021285; Fri, 9 Jun 2017 11:28:09 +0100 From: Michal Wajdeczko To: intel-gfx@lists.freedesktop.org Date: Fri, 9 Jun 2017 10:27:57 +0000 Message-Id: <20170609102757.14984-4-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.10.1.windows.1 In-Reply-To: <20170609102757.14984-1-michal.wajdeczko@intel.com> References: <20170609102757.14984-1-michal.wajdeczko@intel.com> Subject: [Intel-gfx] [PATCH v2 3/3] drm/i915/debugfs: Highlight modified i915 params X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Michal Wajdeczko Cc: Chris Wilson Reviewed-by: Lukasz Fiedorowicz --- 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;