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

Oliver O'Halloran oohall at gmail.com
Mon Oct 12 13:53:07 AEDT 2020


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>
---
 core/init.c     |  3 +++
 core/trace.c    | 17 ++++++++++-------
 include/trace.h |  1 +
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/core/init.c b/core/init.c
index 6ddc7bde1be6..fbe1f90e6aae 100644
--- a/core/init.c
+++ b/core/init.c
@@ -1372,6 +1372,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/trace.c b/core/trace.c
index 5a3ad4921cdf..561bd79e0654 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 04c8440b9e0c..1b1be249cbde 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.26.2



More information about the Skiboot mailing list