Skip to content

Commit

Permalink
core/trace: Export trace buffers to sysfs
Browse files Browse the repository at this point in the history
Every property in the device-tree under /ibm,opal/firmware/exports has a
sysfs node created in /firmware/opal/exports. Add properties with the
physical address and size for each trace buffer so they are exported.

Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
  • Loading branch information
iamjpn authored and stewartsmith committed May 20, 2019
1 parent 8a566ff commit 8c47630
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/test/run-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ int main(void)
unsigned int i, j;

opal_node = dt_new_root("opal");
dt_new(dt_new(opal_node, "firmware"), "exports");
for (i = 0; i < CPUS; i++) {
fake_cpus[i].server_no = i;
fake_cpus[i].is_secondary = (i & 0x1);
Expand Down
10 changes: 10 additions & 0 deletions core/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <lock.h>
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include <cpu.h>
#include <device.h>
#include <libfdt.h>
Expand Down Expand Up @@ -167,12 +168,21 @@ static void trace_add_dt_props(void)
{
unsigned int i;
u64 *prop, tmask;
struct dt_node *exports;
char tname[256];

prop = malloc(sizeof(u64) * 2 * debug_descriptor.num_traces);

exports = dt_find_by_path(opal_node, "firmware/exports");
for (i = 0; i < debug_descriptor.num_traces; i++) {
prop[i * 2] = cpu_to_fdt64(debug_descriptor.trace_phys[i]);
prop[i * 2 + 1] = cpu_to_fdt64(debug_descriptor.trace_size[i]);

snprintf(tname, sizeof(tname), "trace-%x-%"PRIx64,
debug_descriptor.trace_pir[i],
debug_descriptor.trace_phys[i]);
dt_add_property_u64s(exports, tname, debug_descriptor.trace_phys[i],
debug_descriptor.trace_size[i]);
}

dt_add_property(opal_node, "ibm,opal-traces",
Expand Down

0 comments on commit 8c47630

Please sign in to comment.