[Skiboot] [PATCH 07/22] trace: Add nvram hack to use the old trace export behaviour

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Fri Jun 25 16:19:22 AEST 2021


From: Oliver O'Halloran <oohall at gmail.com>

Previously we put all the trace buffer exports in the exports/ node.
However, there's one trace buffer for each core so I moved them into a
subdirectory since they were crowding up the place. Most kernels don't
support recursively exporting subnodes though so kernel's don't have
support for recursively exporting subnodes, so add a hack to restore the
old behaviour for now.

Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
[Fixed run-trace test case - Vasant]
Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
 core/init.c           |  3 +++
 core/test/run-trace.c |  5 +++++
 core/trace.c          | 17 ++++++++++-------
 include/trace.h       |  1 +
 4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/core/init.c b/core/init.c
index d5ba67edd..09749f475 100644
--- a/core/init.c
+++ b/core/init.c
@@ -1369,6 +1369,9 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt)
 	/* Disable protected execution facility in BML */
 	cpu_disable_pef();
 
+	/* export the trace buffers */
+	trace_add_dt_props();
+
 	/* Now release parts of memory nodes we haven't used ourselves... */
 	mem_region_release_unused();
 
diff --git a/core/test/run-trace.c b/core/test/run-trace.c
index b26827643..88b090358 100644
--- a/core/test/run-trace.c
+++ b/core/test/run-trace.c
@@ -102,6 +102,11 @@ struct debug_descriptor debug_descriptor = {
 	.trace_mask = -1
 };
 
+const char *nvram_query_safe(const char *key __unused)
+{
+	return NULL;
+}
+
 void lock_caller(struct lock *l, const char *caller)
 {
 	(void)caller;
diff --git a/core/trace.c b/core/trace.c
index 5a3ad4921..561bd79e0 100644
--- a/core/trace.c
+++ b/core/trace.c
@@ -18,6 +18,7 @@
 #include <skiboot.h>
 #include <opal-api.h>
 #include <debug_descriptor.h>
+#include <nvram.h>
 
 #define DEBUG_TRACES
 
@@ -155,7 +156,7 @@ void trace_add(union trace *trace, u8 type, u16 len)
 	unlock(&ti->lock);
 }
 
-static void trace_add_dt_props(void)
+void trace_add_dt_props(void)
 {
 	uint64_t boot_buf_phys = (uint64_t) &boot_tracebuf.trace_info;
 	struct dt_node *exports, *traces;
@@ -168,9 +169,14 @@ static void trace_add_dt_props(void)
 	if (!exports)
 		return;
 
-	traces = dt_new(exports, "traces");
-	if (!exports)
-		return;
+	/*
+	 * nvram hack to put all the trace buffer exports in the exports
+	 * node. This is useful if the kernel doesn't also export subnodes.
+	 */
+	if (nvram_query_safe("flat-trace-buf"))
+		traces = exports;
+	else
+		traces = dt_new(exports, "traces");
 
 	prop = malloc(sizeof(u64) * 2 * be32_to_cpu(debug_descriptor.num_traces));
 
@@ -256,7 +262,4 @@ void init_trace_buffers(void)
 			continue;
 		t->trace = t->primary->trace;
 	}
-
-	/* Trace node in DT. */
-	trace_add_dt_props();
 }
diff --git a/include/trace.h b/include/trace.h
index 04c8440b9..1b1be249c 100644
--- a/include/trace.h
+++ b/include/trace.h
@@ -25,6 +25,7 @@ struct trace_info {
 
 /* Allocate trace buffers once we know memory topology */
 void init_trace_buffers(void);
+void trace_add_dt_props(void);
 
 /* This will fill in timestamp and cpu; you must do type and len. */
 void trace_add(union trace *trace, u8 type, u16 len);
-- 
2.31.1



More information about the Skiboot mailing list