Blame SOURCES/0104-cxl-list-Add-debug-option.patch

e0018b
From 2a43dce3913b392a13a5ee918c8ee831a25d720e Mon Sep 17 00:00:00 2001
e0018b
From: Dan Williams <dan.j.williams@intel.com>
e0018b
Date: Sun, 23 Jan 2022 16:53:24 -0800
e0018b
Subject: [PATCH 104/217] cxl/list: Add --debug option
e0018b
e0018b
Add an option to turn on libray and cxl_filter_walk() messages. Gate it
e0018b
based on the global ENABLE_DEBUG configuration setting.
e0018b
e0018b
Link: https://lore.kernel.org/r/164298560409.3021641.11040422738199381922.stgit@dwillia2-desk3.amr.corp.intel.com
e0018b
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
e0018b
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
e0018b
---
e0018b
 Documentation/cxl/cxl-list.txt | 6 ++++--
e0018b
 cxl/filter.c                   | 3 +++
e0018b
 cxl/list.c                     | 9 +++++++++
e0018b
 3 files changed, 16 insertions(+), 2 deletions(-)
e0018b
e0018b
diff --git a/Documentation/cxl/cxl-list.txt b/Documentation/cxl/cxl-list.txt
e0018b
index 3076deb..42b6de6 100644
e0018b
--- a/Documentation/cxl/cxl-list.txt
e0018b
+++ b/Documentation/cxl/cxl-list.txt
e0018b
@@ -200,9 +200,11 @@ OPTIONS
e0018b
 	descendants of the individual ports that match the filter. By default
e0018b
 	all descendant objects are listed.
e0018b
 
e0018b
-include::human-option.txt[]
e0018b
+--debug::
e0018b
+	If the cxl tool was built with debug enabled, turn on debug
e0018b
+	messages.
e0018b
 
e0018b
-include::verbose-option.txt[]
e0018b
+include::human-option.txt[]
e0018b
 
e0018b
 include::../copyright.txt[]
e0018b
 
e0018b
diff --git a/cxl/filter.c b/cxl/filter.c
e0018b
index 8b79db3..32171a4 100644
e0018b
--- a/cxl/filter.c
e0018b
+++ b/cxl/filter.c
e0018b
@@ -387,6 +387,7 @@ int cxl_filter_walk(struct cxl_ctx *ctx, struct cxl_filter_params *p)
e0018b
 	if (!jports)
e0018b
 		goto err;
e0018b
 
e0018b
+	dbg(p, "walk memdevs\n");
e0018b
 	cxl_memdev_foreach(ctx, memdev) {
e0018b
 		struct json_object *jdev;
e0018b
 
e0018b
@@ -403,6 +404,7 @@ int cxl_filter_walk(struct cxl_ctx *ctx, struct cxl_filter_params *p)
e0018b
 		}
e0018b
 	}
e0018b
 
e0018b
+	dbg(p, "walk buses\n");
e0018b
 	cxl_bus_foreach(ctx, bus) {
e0018b
 		struct json_object *jbus = NULL;
e0018b
 		struct json_object *jchildports = NULL;
e0018b
@@ -431,6 +433,7 @@ int cxl_filter_walk(struct cxl_ctx *ctx, struct cxl_filter_params *p)
e0018b
 			}
e0018b
 		}
e0018b
 walk_children:
e0018b
+		dbg(p, "walk ports\n");
e0018b
 		walk_child_ports(port, p, pick_array(jchildports, jports),
e0018b
 				 flags);
e0018b
 		cond_add_put_array_suffix(jbus, "ports", devname, jchildports);
e0018b
diff --git a/cxl/list.c b/cxl/list.c
e0018b
index 1ef91b4..01ab19b 100644
e0018b
--- a/cxl/list.c
e0018b
+++ b/cxl/list.c
e0018b
@@ -13,6 +13,7 @@
e0018b
 #include "filter.h"
e0018b
 
e0018b
 static struct cxl_filter_params param;
e0018b
+static bool debug;
e0018b
 
e0018b
 static const struct option options[] = {
e0018b
 	OPT_STRING('m', "memdev", &param.memdev_filter, "memory device name(s)",
e0018b
@@ -35,6 +36,9 @@ static const struct option options[] = {
e0018b
 		    "use human friendly number formats "),
e0018b
 	OPT_BOOLEAN('H', "health", &param.health,
e0018b
 		    "include memory device health information "),
e0018b
+#ifdef ENABLE_DEBUG
e0018b
+	OPT_BOOLEAN(0, "debug", &debug, "debug list walk"),
e0018b
+#endif
e0018b
 	OPT_END(),
e0018b
 };
e0018b
 
e0018b
@@ -84,9 +88,14 @@ int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx)
e0018b
 	}
e0018b
 
e0018b
 	log_init(&param.ctx, "cxl list", "CXL_LIST_LOG");
e0018b
+	if (debug) {
e0018b
+		cxl_set_log_priority(ctx, LOG_DEBUG);
e0018b
+		param.ctx.log_priority = LOG_DEBUG;
e0018b
+	}
e0018b
 
e0018b
 	if (cxl_filter_has(param.port_filter, "root") && param.ports)
e0018b
 		param.buses = true;
e0018b
 
e0018b
+	dbg(&param, "walk topology\n");
e0018b
 	return cxl_filter_walk(ctx, ¶m;;
e0018b
 }
e0018b
-- 
e0018b
2.27.0
e0018b