[Skiboot] [PATCH 2/2] Remove skiboot 'trace' infrastructure

Joel Stanley joel at jms.id.au
Wed Dec 12 11:21:14 AEDT 2018


This feature has bit rotted. For instance, the FSP TCE mapping was
broken in 2015 by commit f2a7a5c23d81 ("Move boot_tracebuf to BSS"),
and no one seems to have noticed.

Signed-off-by: Joel Stanley <joel at jms.id.au>
---
 .gitignore                  |   2 -
 core/Makefile.inc           |   2 +-
 core/affinity.c             |   1 -
 core/cpu.c                  |   5 -
 core/init.c                 |   5 -
 core/opal.c                 |  26 ---
 core/test/Makefile.check    |   2 +-
 core/test/run-trace.c       | 398 ------------------------------------
 core/trace.c                | 246 ----------------------
 external/trace/Makefile     |   7 -
 external/trace/dump_trace.c | 198 ------------------
 external/trace/trace.c      | 112 ----------
 external/trace/trace.h      |  20 --
 hw/fsp/fsp.c                |  78 +------
 hw/lpc-mbox.c               |   1 -
 hw/lpc-uart.c               |  21 +-
 hw/psi.c                    |   1 -
 hw/sbe-p9.c                 |   1 -
 include/cpu.h               |   1 -
 include/debug_descriptor.h  |  10 +-
 include/trace.h             |  46 -----
 include/trace_types.h       | 134 ------------
 platforms/ibm-fsp/common.c  |  36 +---
 23 files changed, 8 insertions(+), 1345 deletions(-)
 delete mode 100644 core/test/run-trace.c
 delete mode 100644 core/trace.c
 delete mode 100644 external/trace/Makefile
 delete mode 100644 external/trace/dump_trace.c
 delete mode 100644 external/trace/trace.c
 delete mode 100644 external/trace/trace.h
 delete mode 100644 include/trace.h
 delete mode 100644 include/trace_types.h

diff --git a/.gitignore b/.gitignore
index fc09a0d28b9b..05f5069377ab 100644
--- a/.gitignore
+++ b/.gitignore
@@ -61,7 +61,6 @@ core/test/run-msg
 core/test/run-nvram-format
 core/test/run-pel
 core/test/run-pool
-core/test/run-trace
 core/test/run-api-test
 core/test/run-bitmap
 core/test/run-buddy
@@ -69,7 +68,6 @@ core/test/run-flash-subpartition
 core/test/*-gcov
 debian-jessie-vmlinux
 debian-jessie-initrd.gz
-external/dump_trace
 external/mambo/skiboot-boot_test.dump
 external/mambo/skiboot-hello_world.dump
 external/mambo/mambo-socket-proxy
diff --git a/core/Makefile.inc b/core/Makefile.inc
index 3bdfd09dab96..b97fbc606460 100644
--- a/core/Makefile.inc
+++ b/core/Makefile.inc
@@ -4,7 +4,7 @@ SUBDIRS += core
 CORE_OBJS = relocate.o console.o stack.o init.o chip.o mem_region.o
 CORE_OBJS += malloc.o lock.o cpu.o utils.o fdt.o opal.o interrupts.o timebase.o
 CORE_OBJS += opal-msg.o pci.o pci-iov.o pci-virt.o pci-slot.o pcie-slot.o
-CORE_OBJS += pci-opal.o fast-reboot.o device.o exceptions.o trace.o affinity.o
+CORE_OBJS += pci-opal.o fast-reboot.o device.o exceptions.o affinity.o
 CORE_OBJS += vpd.o hostservices.o platform.o nvram.o nvram-format.o hmi.o
 CORE_OBJS += console-log.o ipmi.o time-utils.o pel.o pool.o errorlog.o
 CORE_OBJS += timer.o i2c.o rtc.o flash.o sensor.o ipmi-opal.o
diff --git a/core/affinity.c b/core/affinity.c
index 10d483deb409..7a987a6f40b5 100644
--- a/core/affinity.c
+++ b/core/affinity.c
@@ -47,7 +47,6 @@
 #include <opal.h>
 #include <device.h>
 #include <console.h>
-#include <trace.h>
 #include <chip.h>
 #include <cpu.h>
 #include <affinity.h>
diff --git a/core/cpu.c b/core/cpu.c
index a83f8baf1031..19802061c02d 100644
--- a/core/cpu.c
+++ b/core/cpu.c
@@ -24,7 +24,6 @@
 #include <mem_region.h>
 #include <opal.h>
 #include <stack.h>
-#include <trace.h>
 #include <affinity.h>
 #include <chip.h>
 #include <timebase.h>
@@ -1027,7 +1026,6 @@ void init_boot_cpu(void)
 	/* Setup boot CPU state */
 	boot_cpu = &cpu_stacks[pir].cpu;
 	init_cpu_thread(boot_cpu, cpu_state_active, pir);
-	init_boot_tracebuf(boot_cpu);
 	assert(this_cpu() == boot_cpu);
 	init_hid();
 }
@@ -1167,8 +1165,6 @@ void init_all_cpus(void)
 		t = pt = &cpu_stacks[pir].cpu;
 		if (t != boot_cpu) {
 			init_cpu_thread(t, state, pir);
-			/* Each cpu gets its own later in init_trace_buffers */
-			t->trace = boot_cpu->trace;
 		}
 		t->server_no = server_no;
 		t->primary = t;
@@ -1196,7 +1192,6 @@ void init_all_cpus(void)
 			      thread);
 			t = &cpu_stacks[pir + thread].cpu;
 			init_cpu_thread(t, state, pir + thread);
-			t->trace = boot_cpu->trace;
 			t->server_no = ((const u32 *)p->prop)[thread];
 			t->is_secondary = true;
 			t->primary = pt;
diff --git a/core/init.c b/core/init.c
index 262ac5fb310d..a204a342007e 100644
--- a/core/init.c
+++ b/core/init.c
@@ -35,7 +35,6 @@
 #include <chip.h>
 #include <interrupts.h>
 #include <mem_region.h>
-#include <trace.h>
 #include <console.h>
 #include <fsi-master.h>
 #include <centaur.h>
@@ -74,7 +73,6 @@ struct debug_descriptor debug_descriptor = {
 	.version	= DEBUG_DESC_VERSION,
 	.state_flags	= 0,
 	.memcons_phys	= (uint64_t)&memcons,
-	.trace_mask	= 0, /* All traces disabled by default */
 	/* console log level:
 	 *   high 4 bits in memory, low 4 bits driver (e.g. uart). */
 #ifdef DEBUG
@@ -1038,9 +1036,6 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt)
 	 */
 	probe_platform();
 
-	/* Allocate our split trace buffers now. Depends add_opal_node() */
-	init_trace_buffers();
-
 	/* On P7/P8, get the ICPs and make sure they are in a sane state */
 	init_interrupts();
 	if (proc_gen == proc_gen_p7 || proc_gen == proc_gen_p8)
diff --git a/core/opal.c b/core/opal.c
index 46035e836087..a5df054ba6e6 100644
--- a/core/opal.c
+++ b/core/opal.c
@@ -24,7 +24,6 @@
 #include <op-panel.h>
 #include <device.h>
 #include <console.h>
-#include <trace.h>
 #include <timebase.h>
 #include <affinity.h>
 #include <opal-msg.h>
@@ -93,27 +92,6 @@ long opal_bad_token(uint64_t token)
 	return OPAL_PARAMETER;
 }
 
-#ifdef OPAL_TRACE_ENTRY
-static void opal_trace_entry(struct stack_frame *eframe __unused)
-{
-	union trace t;
-	unsigned nargs, i;
-
-	if (eframe->gpr[0] > OPAL_LAST)
-		nargs = 0;
-	else
-		nargs = opal_num_args[eframe->gpr[0]];
-
-	t.opal.token = cpu_to_be64(eframe->gpr[0]);
-	t.opal.lr = cpu_to_be64(eframe->lr);
-	t.opal.sp = cpu_to_be64(eframe->gpr[1]);
-	for(i=0; i<nargs; i++)
-		t.opal.r3_to_11[i] = cpu_to_be64(eframe->gpr[3+i]);
-
-	trace_add(&t, TRACE_OPAL, offsetof(struct trace_opal, r3_to_11[nargs]));
-}
-#endif
-
 /*
  * opal_quiesce_state is used as a lock. Don't use an actual lock to avoid
  * lock busting.
@@ -138,10 +116,6 @@ int64_t opal_entry_check(struct stack_frame *eframe)
 		abort();
 	}
 
-#ifdef OPAL_TRACE_ENTRY
-	opal_trace_entry(eframe);
-#endif
-
 	if (!opal_check_token(token))
 		return opal_bad_token(token);
 
diff --git a/core/test/Makefile.check b/core/test/Makefile.check
index a5226a890361..2ef447da322c 100644
--- a/core/test/Makefile.check
+++ b/core/test/Makefile.check
@@ -13,7 +13,7 @@ CORE_TEST := \
 	core/test/run-mem_region_reservations \
 	core/test/run-mem_range_is_reserved \
 	core/test/run-nvram-format \
-	core/test/run-trace core/test/run-msg \
+	core/test/run-msg \
 	core/test/run-pel \
 	core/test/run-pool \
 	core/test/run-time-utils \
diff --git a/core/test/run-trace.c b/core/test/run-trace.c
deleted file mode 100644
index dd4cd450002c..000000000000
--- a/core/test/run-trace.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/* Copyright 2013-2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * 	http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <config.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <sched.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdbool.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#include <skiboot-valgrind.h>
-
-/* Don't include these: PPC-specific */
-#define __CPU_H
-#define __TIME_H
-#define __PROCESSOR_H
-
-#if defined(__i386__) || defined(__x86_64__)
-/* This is more than a lwsync, but it'll work */
-static void full_barrier(void)
-{
-	asm volatile("mfence" : : : "memory");
-}
-#define lwsync full_barrier
-#elif defined(__powerpc__) || defined(__powerpc64__)
-static inline void lwsync(void)
-{
-	asm volatile("lwsync" : : : "memory");
-}
-#else
-#error "Define lwsync for this arch"
-#endif
-
-#define zalloc(size) calloc((size), 1)
-
-struct cpu_thread {
-	uint32_t pir;
-	uint32_t chip_id;
-	struct trace_info *trace;
-	int server_no;
-	bool is_secondary;
-	struct cpu_thread *primary;
-};
-static struct cpu_thread *this_cpu(void);
-
-#define CPUS 4
-
-static struct cpu_thread fake_cpus[CPUS];
-
-static inline struct cpu_thread *next_cpu(struct cpu_thread *cpu)
-{
-	if (cpu == NULL)
-		return &fake_cpus[0];
-	cpu++;
-	if (cpu == &fake_cpus[CPUS])
-		return NULL;
-	return cpu;
-}
-
-#define first_cpu() next_cpu(NULL)
-
-#define for_each_cpu(cpu)	\
-	for (cpu = first_cpu(); cpu; cpu = next_cpu(cpu))
-
-static unsigned long timestamp;
-static unsigned long mftb(void)
-{
-	return timestamp;
-}
-
-static void *local_alloc(unsigned int chip_id,
-			 size_t size, size_t align)
-{
-	void *p;
-
-	(void)chip_id;
-	if (posix_memalign(&p, align, size))
-		p = NULL;
-	return p;
-}
-
-struct dt_node;
-extern struct dt_node *opal_node;
-
-#include "../trace.c"
-
-#define rmb() lwsync()
-
-#include "../external/trace/trace.c"
-#include "../device.c"
-
-char __rodata_start[1], __rodata_end[1];
-struct dt_node *opal_node;
-struct debug_descriptor debug_descriptor = {
-	.trace_mask = -1
-};
-
-void lock_caller(struct lock *l, const char *caller)
-{
-	(void)caller;
-	assert(!l->lock_val);
-	l->lock_val = 1;
-}
-
-void unlock(struct lock *l)
-{
-	assert(l->lock_val);
-	l->lock_val = 0;
-}
-
-struct cpu_thread *my_fake_cpu;
-static struct cpu_thread *this_cpu(void)
-{
-	return my_fake_cpu;
-}
-
-#include <sys/mman.h>
-#define PER_CHILD_TRACES ((RUNNING_ON_VALGRIND) ? (1024*16) : (1024*1024))
-
-static void write_trace_entries(int id)
-{
-	void exit(int);
-	unsigned int i;
-	union trace trace;
-
-	timestamp = id;
-	for (i = 0; i < PER_CHILD_TRACES; i++) {
-		timestamp = i * CPUS + id;
-		assert(sizeof(trace.hdr) % 8 == 0);
-		/* First child never repeats, second repeats once, etc. */
-		trace_add(&trace, 3 + ((i / (id + 1)) % 0x40),
-			  sizeof(trace.hdr));
-	}
-
-	/* Final entry has special type, so parent knows it's over. */
-	trace_add(&trace, 0x70, sizeof(trace.hdr));
-	exit(0);
-}
-
-static bool all_done(const bool done[])
-{
-	unsigned int i;
-
-	for (i = 0; i < CPUS; i++)
-		if (!done[i])
-			return false;
-	return true;
-}
-
-static void test_parallel(void)
-{
-	void *p;
-	unsigned int cpu;
-	unsigned int i, counts[CPUS] = { 0 }, overflows[CPUS] = { 0 };
-	unsigned int repeats[CPUS] = { 0 }, num_overflows[CPUS] = { 0 };
-	bool done[CPUS] = { false };
-	size_t len = sizeof(struct trace_info) + TBUF_SZ + sizeof(union trace);
-	int last = 0;
-
-	/* Use a shared mmap to test actual parallel buffers. */
-	i = (CPUS*len + getpagesize()-1)&~(getpagesize()-1);
-	p = mmap(NULL, i, PROT_READ|PROT_WRITE,
-		 MAP_ANONYMOUS|MAP_SHARED, -1, 0);
-
-	for (i = 0; i < CPUS; i++) {
-		fake_cpus[i].trace = p + i * len;
-		fake_cpus[i].trace->tb.mask = cpu_to_be64(TBUF_SZ - 1);
-		fake_cpus[i].trace->tb.max_size = cpu_to_be32(sizeof(union trace));
-		fake_cpus[i].is_secondary = false;
-	}
-
-	for (i = 0; i < CPUS; i++) {
-		if (!fork()) {
-			/* Child. */
-			my_fake_cpu = &fake_cpus[i];
-			write_trace_entries(i);
-		}
-	}
-
-	while (!all_done(done)) {
-		union trace t;
-
-		for (i = 0; i < CPUS; i++) {
-			if (trace_get(&t, &fake_cpus[(i+last) % CPUS].trace->tb))
-				break;
-		}
-
-		if (i == CPUS) {
-			sched_yield();
-			continue;
-		}
-		i = (i + last) % CPUS;
-		last = i;
-
-		assert(be16_to_cpu(t.hdr.cpu) < CPUS);
-		assert(!done[be16_to_cpu(t.hdr.cpu)]);
-
-		if (t.hdr.type == TRACE_OVERFLOW) {
-			/* Conveniently, each record is 16 bytes here. */
-			assert(be64_to_cpu(t.overflow.bytes_missed) % 16 == 0);
-			overflows[i] += be64_to_cpu(t.overflow.bytes_missed) / 16;
-			num_overflows[i]++;
-			continue;
-		}
-
-		assert(be64_to_cpu(t.hdr.timestamp) % CPUS == be16_to_cpu(t.hdr.cpu));
-		if (t.hdr.type == TRACE_REPEAT) {
-			assert(t.hdr.len_div_8 * 8 == sizeof(t.repeat));
-			assert(be16_to_cpu(t.repeat.num) != 0);
-			assert(be16_to_cpu(t.repeat.num) <= be16_to_cpu(t.hdr.cpu));
-			repeats[be16_to_cpu(t.hdr.cpu)] += be16_to_cpu(t.repeat.num);
-		} else if (t.hdr.type == 0x70) {
-			cpu = be16_to_cpu(t.hdr.cpu);
-			assert(cpu < CPUS);
-			done[cpu] = true;
-		} else {
-			cpu = be16_to_cpu(t.hdr.cpu);
-			assert(cpu < CPUS);
-			counts[cpu]++;
-		}
-	}
-
-	/* Gather children. */
-	for (i = 0; i < CPUS; i++) {
-		int status;
-		wait(&status);
-	}
-
-	for (i = 0; i < CPUS; i++) {
-		printf("Child %i: %u produced, %u overflows, %llu total\n", i,
-		       counts[i], overflows[i],
-		       (long long)be64_to_cpu(fake_cpus[i].trace->tb.end));
-		assert(counts[i] + repeats[i] <= PER_CHILD_TRACES);
-	}
-	/* Child 0 never repeats. */
-	assert(repeats[0] == 0);
-	assert(counts[0] + overflows[0] == PER_CHILD_TRACES);
-
-	/*
-	 * FIXME: Other children have some fuzz, since overflows may
-	 * include repeat record we already read.  And odd-numbered
-	 * overflows may include more repeat records than normal
-	 * records (they alternate).
-	 */
-}
-
-int main(void)
-{
-	union trace minimal;
-	union trace large;
-	union trace trace;
-	unsigned int i, j;
-
-	opal_node = dt_new_root("opal");
-	for (i = 0; i < CPUS; i++) {
-		fake_cpus[i].server_no = i;
-		fake_cpus[i].is_secondary = (i & 0x1);
-		fake_cpus[i].primary = &fake_cpus[i & ~0x1];
-	}
-	init_trace_buffers();
-	my_fake_cpu = &fake_cpus[0];
-
-	for (i = 0; i < CPUS; i++) {
-		assert(trace_empty(&fake_cpus[i].trace->tb));
-		assert(!trace_get(&trace, &fake_cpus[i].trace->tb));
-	}
-
-	assert(sizeof(trace.hdr) % 8 == 0);
-	timestamp = 1;
-	trace_add(&minimal, 100, sizeof(trace.hdr));
-	assert(trace_get(&trace, &my_fake_cpu->trace->tb));
-	assert(trace.hdr.len_div_8 == minimal.hdr.len_div_8);
-	assert(be64_to_cpu(trace.hdr.timestamp) == timestamp);
-
-	/* Make it wrap once. */
-	for (i = 0; i < TBUF_SZ / (minimal.hdr.len_div_8 * 8) + 1; i++) {
-		timestamp = i;
-		trace_add(&minimal, 99 + (i%2), sizeof(trace.hdr));
-	}
-
-	assert(trace_get(&trace, &my_fake_cpu->trace->tb));
-	/* First one must be overflow marker. */
-	assert(trace.hdr.type == TRACE_OVERFLOW);
-	assert(trace.hdr.len_div_8 * 8 == sizeof(trace.overflow));
-	assert(be64_to_cpu(trace.overflow.bytes_missed) == minimal.hdr.len_div_8 * 8);
-
-	for (i = 0; i < TBUF_SZ / (minimal.hdr.len_div_8 * 8); i++) {
-		assert(trace_get(&trace, &my_fake_cpu->trace->tb));
-		assert(trace.hdr.len_div_8 == minimal.hdr.len_div_8);
-		assert(be64_to_cpu(trace.hdr.timestamp) == i+1);
-		assert(trace.hdr.type == 99 + ((i+1)%2));
-	}
-	assert(!trace_get(&trace, &my_fake_cpu->trace->tb));
-
-	/* Now put in some weird-length ones, to test overlap.
-	 * Last power of 2, minus 8. */
-	for (j = 0; (1 << j) < sizeof(large); j++);
-	for (i = 0; i < TBUF_SZ; i++) {
-		timestamp = i;
-		trace_add(&large, 100 + (i%2), (1 << (j-1)));
-	}
-	assert(trace_get(&trace, &my_fake_cpu->trace->tb));
-	assert(trace.hdr.type == TRACE_OVERFLOW);
-	assert(trace_get(&trace, &my_fake_cpu->trace->tb));
-	assert(trace.hdr.len_div_8 == large.hdr.len_div_8);
-	i = be64_to_cpu(trace.hdr.timestamp);
-	while (trace_get(&trace, &my_fake_cpu->trace->tb))
-		assert(be64_to_cpu(trace.hdr.timestamp) == ++i);
-
-	/* Test repeats. */
-	for (i = 0; i < 65538; i++) {
-		timestamp = i;
-		trace_add(&minimal, 100, sizeof(trace.hdr));
-	}
-	timestamp = i;
-	trace_add(&minimal, 101, sizeof(trace.hdr));
-	timestamp = i+1;
-	trace_add(&minimal, 101, sizeof(trace.hdr));
-
-	assert(trace_get(&trace, &my_fake_cpu->trace->tb));
-	assert(trace.hdr.timestamp == 0);
-	assert(trace.hdr.len_div_8 == minimal.hdr.len_div_8);
-	assert(trace.hdr.type == 100);
-	assert(trace_get(&trace, &my_fake_cpu->trace->tb));
-	assert(trace.hdr.type == TRACE_REPEAT);
-	assert(trace.hdr.len_div_8 * 8 == sizeof(trace.repeat));
-	assert(be16_to_cpu(trace.repeat.num) == 65535);
-	assert(be64_to_cpu(trace.repeat.timestamp) == 65535);
-	assert(trace_get(&trace, &my_fake_cpu->trace->tb));
-	assert(be64_to_cpu(trace.hdr.timestamp) == 65536);
-	assert(trace.hdr.len_div_8 == minimal.hdr.len_div_8);
-	assert(trace.hdr.type == 100);
-	assert(trace_get(&trace, &my_fake_cpu->trace->tb));
-	assert(trace.hdr.type == TRACE_REPEAT);
-	assert(trace.hdr.len_div_8 * 8 == sizeof(trace.repeat));
-	assert(be16_to_cpu(trace.repeat.num) == 1);
-	assert(be64_to_cpu(trace.repeat.timestamp) == 65537);
-
-	assert(trace_get(&trace, &my_fake_cpu->trace->tb));
-	assert(be64_to_cpu(trace.hdr.timestamp) == 65538);
-	assert(trace.hdr.len_div_8 == minimal.hdr.len_div_8);
-	assert(trace.hdr.type == 101);
-	assert(trace_get(&trace, &my_fake_cpu->trace->tb));
-	assert(trace.hdr.type == TRACE_REPEAT);
-	assert(trace.hdr.len_div_8 * 8 == sizeof(trace.repeat));
-	assert(be16_to_cpu(trace.repeat.num) == 1);
-	assert(be64_to_cpu(trace.repeat.timestamp) == 65539);
-
-	/* Now, test adding repeat while we're reading... */
-	timestamp = 0;
-	trace_add(&minimal, 100, sizeof(trace.hdr));
-	assert(trace_get(&trace, &my_fake_cpu->trace->tb));
-	assert(be64_to_cpu(trace.hdr.timestamp) == 0);
-	assert(trace.hdr.len_div_8 == minimal.hdr.len_div_8);
-	assert(trace.hdr.type == 100);
-
-	for (i = 1; i < TBUF_SZ; i++) {
-		timestamp = i;
-		trace_add(&minimal, 100, sizeof(trace.hdr));
-		assert(trace_get(&trace, &my_fake_cpu->trace->tb));
-		if (i % 65536 == 0) {
-			assert(trace.hdr.type == 100);
-			assert(trace.hdr.len_div_8 == minimal.hdr.len_div_8);
-		} else {
-			assert(trace.hdr.type == TRACE_REPEAT);
-			assert(trace.hdr.len_div_8 * 8 == sizeof(trace.repeat));
-			assert(be16_to_cpu(trace.repeat.num) == 1);
-		}
-		assert(be64_to_cpu(trace.repeat.timestamp) == i);
-		assert(!trace_get(&trace, &my_fake_cpu->trace->tb));
-	}
-
-	for (i = 0; i < CPUS; i++)
-		if (!fake_cpus[i].is_secondary)
-			free(fake_cpus[i].trace);
-
-	test_parallel();
-
-	return 0;
-}
diff --git a/core/trace.c b/core/trace.c
deleted file mode 100644
index d4e1b1d0d245..000000000000
--- a/core/trace.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/* Copyright 2013-2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * 	http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <trace.h>
-#include <timebase.h>
-#include <lock.h>
-#include <string.h>
-#include <stdlib.h>
-#include <cpu.h>
-#include <device.h>
-#include <libfdt.h>
-#include <processor.h>
-#include <skiboot.h>
-#include <opal-api.h>
-#include <debug_descriptor.h>
-
-#define DEBUG_TRACES
-
-#define MAX_SIZE (sizeof(union trace) + 7)
-
-/* Smaller trace buffer for early booting */
-#define BOOT_TBUF_SZ 65536
-static struct {
-	struct trace_info trace_info;
-	char buf[BOOT_TBUF_SZ + MAX_SIZE];
-} boot_tracebuf;
-
-void init_boot_tracebuf(struct cpu_thread *boot_cpu)
-{
-	init_lock(&boot_tracebuf.trace_info.lock);
-	boot_tracebuf.trace_info.tb.mask = cpu_to_be64(BOOT_TBUF_SZ - 1);
-	boot_tracebuf.trace_info.tb.max_size = cpu_to_be32(MAX_SIZE);
-
-	boot_cpu->trace = &boot_tracebuf.trace_info;
-}
-
-static size_t tracebuf_extra(void)
-{
-	/* We make room for the largest possible record */
-	return TBUF_SZ + MAX_SIZE;
-}
-
-/* To avoid bloating each entry, repeats are actually specific entries.
- * tb->last points to the last (non-repeat) entry. */
-static bool handle_repeat(struct tracebuf *tb, const union trace *trace)
-{
-	struct trace_hdr *prev;
-	struct trace_repeat *rpt;
-	u32 len;
-
-	prev = (void *)tb->buf + be64_to_cpu(tb->last & tb->mask);
-
-	if (prev->type != trace->hdr.type
-	    || prev->len_div_8 != trace->hdr.len_div_8
-	    || prev->cpu != trace->hdr.cpu)
-		return false;
-
-	len = prev->len_div_8 << 3;
-	if (memcmp(prev + 1, &trace->hdr + 1, len - sizeof(*prev)) != 0)
-		return false;
-
-	/* If they've consumed prev entry, don't repeat. */
-	if (be64_to_cpu(tb->last) < be64_to_cpu(tb->start))
-		return false;
-
-	/* OK, it's a duplicate.  Do we already have repeat? */
-	if (be64_to_cpu(tb->last) + len != be64_to_cpu(tb->end)) {
-		u64 pos = be64_to_cpu(tb->last) + len;
-		/* FIXME: Reader is not protected from seeing this! */
-		rpt = (void *)tb->buf + (pos & be64_to_cpu(tb->mask));
-		assert(pos + rpt->len_div_8*8 == be64_to_cpu(tb->end));
-		assert(rpt->type == TRACE_REPEAT);
-
-		/* If this repeat entry is full, don't repeat. */
-		if (be16_to_cpu(rpt->num) == 0xFFFF)
-			return false;
-
-		rpt->num = cpu_to_be16(be16_to_cpu(rpt->num) + 1);
-		rpt->timestamp = trace->hdr.timestamp;
-		return true;
-	}
-
-	/*
-	 * Generate repeat entry: it's the smallest possible entry, so we
-	 * must have eliminated old entries.
-	 */
-	assert(trace->hdr.len_div_8 * 8 >= sizeof(*rpt));
-
-	rpt = (void *)tb->buf + be64_to_cpu(tb->end & tb->mask);
-	rpt->timestamp = trace->hdr.timestamp;
-	rpt->type = TRACE_REPEAT;
-	rpt->len_div_8 = sizeof(*rpt) >> 3;
-	rpt->cpu = trace->hdr.cpu;
-	rpt->prev_len = cpu_to_be16(trace->hdr.len_div_8 << 3);
-	rpt->num = cpu_to_be16(1);
-	lwsync(); /* write barrier: complete repeat record before exposing */
-	tb->end = cpu_to_be64(be64_to_cpu(tb->end) + sizeof(*rpt));
-	return true;
-}
-
-void trace_add(union trace *trace, u8 type, u16 len)
-{
-	struct trace_info *ti = this_cpu()->trace;
-	unsigned int tsz;
-
-	trace->hdr.type = type;
-	trace->hdr.len_div_8 = (len + 7) >> 3;
-
-	tsz = trace->hdr.len_div_8 << 3;
-
-#ifdef DEBUG_TRACES
-	assert(tsz >= sizeof(trace->hdr));
-	assert(tsz <= sizeof(*trace));
-	assert(trace->hdr.type != TRACE_REPEAT);
-	assert(trace->hdr.type != TRACE_OVERFLOW);
-#endif
-	/* Skip traces not enabled in the debug descriptor */
-	if (trace->hdr.type < (8 * sizeof(debug_descriptor.trace_mask)) &&
-	    !((1ul << trace->hdr.type) & debug_descriptor.trace_mask))
-		return;
-
-	trace->hdr.timestamp = cpu_to_be64(mftb());
-	trace->hdr.cpu = cpu_to_be16(this_cpu()->server_no);
-
-	lock(&ti->lock);
-
-	/* Throw away old entries before we overwrite them. */
-	while ((be64_to_cpu(ti->tb.start) + be64_to_cpu(ti->tb.mask) + 1)
-	       < (be64_to_cpu(ti->tb.end) + tsz)) {
-		struct trace_hdr *hdr;
-
-		hdr = (void *)ti->tb.buf +
-			be64_to_cpu(ti->tb.start & ti->tb.mask);
-		ti->tb.start = cpu_to_be64(be64_to_cpu(ti->tb.start) +
-					   (hdr->len_div_8 << 3));
-	}
-
-	/* Must update ->start before we rewrite new entries. */
-	lwsync(); /* write barrier */
-
-	/* Check for duplicates... */
-	if (!handle_repeat(&ti->tb, trace)) {
-		/* This may go off end, and that's why ti->tb.buf is oversize */
-		memcpy(ti->tb.buf + be64_to_cpu(ti->tb.end & ti->tb.mask),
-		       trace, tsz);
-		ti->tb.last = ti->tb.end;
-		lwsync(); /* write barrier: write entry before exposing */
-		ti->tb.end = cpu_to_be64(be64_to_cpu(ti->tb.end) + tsz);
-	}
-	unlock(&ti->lock);
-}
-
-static void trace_add_dt_props(void)
-{
-	unsigned int i;
-	u64 *prop, tmask;
-
-	prop = malloc(sizeof(u64) * 2 * debug_descriptor.num_traces);
-
-	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]);
-	}
-
-	dt_add_property(opal_node, "ibm,opal-traces",
-			prop, sizeof(u64) * 2 * i);
-	free(prop);
-
-	tmask = (uint64_t)&debug_descriptor.trace_mask;
-	dt_add_property_u64(opal_node, "ibm,opal-trace-mask", tmask);
-}
-
-static void trace_add_desc(struct trace_info *t, uint64_t size)
-{
-	unsigned int i = debug_descriptor.num_traces;
-
-	if (i >= DEBUG_DESC_MAX_TRACES) {
-		prerror("TRACE: Debug descriptor trace list full !\n");
-		return;
-	}
-	debug_descriptor.num_traces++;
-
-	debug_descriptor.trace_phys[i] = (uint64_t)&t->tb;
-	debug_descriptor.trace_tce[i] = 0; /* populated later */
-	debug_descriptor.trace_size[i] = size;
-}
-
-/* Allocate trace buffers once we know memory topology */
-void init_trace_buffers(void)
-{
-	struct cpu_thread *t;
-	struct trace_info *any = &boot_tracebuf.trace_info;
-	uint64_t size;
-
-	/* Boot the boot trace in the debug descriptor */
-	trace_add_desc(any, sizeof(boot_tracebuf.buf));
-
-	/* Allocate a trace buffer for each primary cpu. */
-	for_each_cpu(t) {
-		if (t->is_secondary)
-			continue;
-
-		/* Use a 4K alignment for TCE mapping */
-		size = ALIGN_UP(sizeof(*t->trace) + tracebuf_extra(), 0x1000);
-		t->trace = local_alloc(t->chip_id, size, 0x1000);
-		if (t->trace) {
-			any = t->trace;
-			memset(t->trace, 0, size);
-			init_lock(&t->trace->lock);
-			t->trace->tb.mask = cpu_to_be64(TBUF_SZ - 1);
-			t->trace->tb.max_size = cpu_to_be32(MAX_SIZE);
-			trace_add_desc(any, sizeof(t->trace->tb) +
-				       tracebuf_extra());
-		} else
-			prerror("TRACE: cpu 0x%x allocation failed\n", t->pir);
-	}
-
-	/* In case any allocations failed, share trace buffers. */
-	for_each_cpu(t) {
-		if (!t->is_secondary && !t->trace)
-			t->trace = any;
-	}
-
-	/* And copy those to the secondaries. */
-	for_each_cpu(t) {
-		if (!t->is_secondary)
-			continue;
-		t->trace = t->primary->trace;
-	}
-
-	/* Trace node in DT. */
-	trace_add_dt_props();
-}
diff --git a/external/trace/Makefile b/external/trace/Makefile
deleted file mode 100644
index 3b6684bf1f4d..000000000000
--- a/external/trace/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-HOSTEND=$(shell uname -m | sed -e 's/^i.*86$$/LITTLE/' -e 's/^x86.*/LITTLE/' -e 's/^ppc.*/BIG/')
-CFLAGS=-g -Wall -DHAVE_$(HOSTEND)_ENDIAN -I../../include -I../../
-
-dump_trace: dump_trace.c
-
-clean:
-	rm -f dump_trace *.o
diff --git a/external/trace/dump_trace.c b/external/trace/dump_trace.c
deleted file mode 100644
index db53d785be57..000000000000
--- a/external/trace/dump_trace.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/* Copyright 2013-2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * 	http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <err.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <inttypes.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <unistd.h>
-
-#include "../../ccan/endian/endian.h"
-#include "../../ccan/short_types/short_types.h"
-#include <trace_types.h>
-
-/* Handles trace from debugfs (one record at a time) or file */ 
-static bool get_trace(int fd, union trace *t, int *len)
-{
-	void *dest = t;
-	int r;
-
-	/* Move down any extra we read last time. */
-	if (*len >= sizeof(t->hdr) && *len >= t->hdr.len_div_8 * 8) {
-		u8 rlen = t->hdr.len_div_8 * 8;
-		memmove(dest, dest + rlen, *len - rlen);
-		*len -= rlen;
-	}
-
-	r = read(fd, dest + *len, sizeof(*t) - *len);
-	if (r < 0)
-		return false;
-
-	*len += r;
-	/* We should have a complete record. */
-	return *len >= sizeof(t->hdr) && *len >= t->hdr.len_div_8 * 8;
-}
-
-static void display_header(const struct trace_hdr *h)
-{
-	static u64 prev_ts;
-	u64 ts = be64_to_cpu(h->timestamp);
-
-	printf("%16lx (+%8lx) [%03x] : ",
-	       ts, prev_ts ? (ts - prev_ts) : 0, be16_to_cpu(h->cpu));
-	prev_ts = ts;
-}
-
-static void dump_fsp_event(struct trace_fsp_event *t)
-{
-	printf("FSP_EVT [st=%d] ", be16_to_cpu(t->fsp_state));
-
-	switch(be16_to_cpu(t->event)) {
-	case TRACE_FSP_EVT_LINK_DOWN:
-		printf("LINK DOWN");
-		break;
-	case TRACE_FSP_EVT_DISR_CHG:
-		printf("DISR CHANGE (0x%08x)", be32_to_cpu(t->data[0]));
-		break;
-	case TRACE_FSP_EVT_SOFT_RR:
-		printf("SOFT R&R (DISR=0x%08x)", be32_to_cpu(t->data[0]));
-		break;
-	case TRACE_FSP_EVT_RR_COMPL:
-		printf("R&R COMPLETE");
-		break;
-	case TRACE_FSP_EVT_HDES_CHG:
-		printf("HDES CHANGE (0x%08x)", be32_to_cpu(t->data[0]));
-		break;
-	case TRACE_FSP_EVT_POLL_IRQ:
-		printf("%s HDIR=%08x CTL=%08x PSI_IRQ=%d",
-		       t->data[0] ? "IRQ " : "POLL", be32_to_cpu(t->data[1]),
-		       be32_to_cpu(t->data[2]), be32_to_cpu(t->data[3]));
-		break;
-	default:
-		printf("Unknown %d (d: %08x %08x %08x %08x)",
-		       be16_to_cpu(t->event), be32_to_cpu(t->data[0]),
-		       be32_to_cpu(t->data[1]), be32_to_cpu(t->data[2]),
-		       be32_to_cpu(t->data[3]));
-	}
-	printf("\n");
-}
-
-static void dump_opal_call(struct trace_opal *t)
-{
-	unsigned int i, n;
-
-	printf("OPAL CALL %"PRIu64, be64_to_cpu(t->token));
-	printf(" LR=0x%016"PRIx64" SP=0x%016"PRIx64,
-	       be64_to_cpu(t->lr), be64_to_cpu(t->sp));
-	n = (t->hdr.len_div_8 * 8 - offsetof(union trace, opal.r3_to_11))
-		/ sizeof(u64);
-	for (i = 0; i < n; i++)
-		printf(" R%u=0x%016"PRIx64,
-		       i+3, be64_to_cpu(t->r3_to_11[i]));
-	printf("\n");
-}
-
-static void dump_fsp_msg(struct trace_fsp_msg *t)
-{
-	unsigned int i;
-
-	printf("FSP_MSG: CMD %u SEQ %u MOD %u SUB %u DLEN %u %s [",
-	       be32_to_cpu(t->word0) & 0xFFFF,
-	       be32_to_cpu(t->word0) >> 16,
-	       be32_to_cpu(t->word1) >> 8,
-	       be32_to_cpu(t->word1) & 0xFF,
-	       t->dlen,
-	       t->dir == TRACE_FSP_MSG_IN ? "IN" :
-	       (t->dir == TRACE_FSP_MSG_OUT ? "OUT" : "UNKNOWN"));
-
-	for (i = 0; i < t->dlen; i++) 
-		printf("%s%02x", i ? " " : "", t->data[i]);
-	printf("]\n");
-}
-
-static void dump_uart(struct trace_uart *t)
-{
-	switch(t->ctx) {
-	case TRACE_UART_CTX_IRQ:
-		printf(": IRQ  IRQEN=%d IN_CNT=%d\n",
-		       !t->irq_state, be16_to_cpu(t->in_count));
-		break;
-	case TRACE_UART_CTX_POLL:
-		printf(": POLL IRQEN=%d IN_CNT=%d\n",
-		       !t->irq_state, be16_to_cpu(t->in_count));
-		break;
-	case TRACE_UART_CTX_READ:
-		printf(": READ IRQEN=%d IN_CNT=%d READ=%d\n",
-		       !t->irq_state, be16_to_cpu(t->in_count), t->cnt);
-		break;
-	default:
-		printf(": ???? IRQEN=%d IN_CNT=%d\n",
-		       !t->irq_state, be16_to_cpu(t->in_count));
-		break;
-	}
-}
-
-int main(int argc, char *argv[])
-{
-	int fd, len = 0;
-	union trace t;
-	const char *in = "/sys/kernel/debug/powerpc/opal-trace";
-
-	if (argc > 2)
-		errx(1, "Usage: dump_trace [file]");
-
-	if (argv[1])
-		in = argv[1];
-	fd = open(in, O_RDONLY);
-	if (fd < 0)
-		err(1, "Opening %s", in);
-
-	while (get_trace(fd, &t, &len)) {
-		display_header(&t.hdr);
-		switch (t.hdr.type) {
-		case TRACE_REPEAT:
-			printf("REPEATS: %u times\n",
-			       be32_to_cpu(t.repeat.num));
-			break;
-		case TRACE_OVERFLOW:
-			printf("**OVERFLOW**: %"PRIu64" bytes missed\n",
-			       be64_to_cpu(t.overflow.bytes_missed));
-			break;
-		case TRACE_OPAL:
-			dump_opal_call(&t.opal);
-			break;
-		case TRACE_FSP_MSG:
-			dump_fsp_msg(&t.fsp_msg);
-			break;
-		case TRACE_FSP_EVENT:
-			dump_fsp_event(&t.fsp_evt);
-			break;
-		case TRACE_UART:
-			dump_uart(&t.uart);
-			break;
-		default:
-			printf("UNKNOWN(%u) CPU %u length %u\n",
-			       t.hdr.type, be16_to_cpu(t.hdr.cpu),
-			       t.hdr.len_div_8 * 8);
-		}
-	}
-	return 0;
-}
diff --git a/external/trace/trace.c b/external/trace/trace.c
deleted file mode 100644
index 745da53cbd9c..000000000000
--- a/external/trace/trace.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/* Copyright 2013-2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * 	http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/* This example code shows how to read from the trace buffer. */
-#include <external/trace/trace.h>
-#include "../ccan/endian/endian.h"
-#include "../ccan/short_types/short_types.h"
-#include <trace_types.h>
-#include <errno.h>
-
-bool trace_empty(const struct tracebuf *tb)
-{
-	const struct trace_repeat *rep;
-
-	if (tb->rpos == tb->end)
-		return true;
-
-	/*
-	 * If we have a single element only, and it's a repeat buffer
-	 * we've already seen every repeat for (yet which may be
-	 * incremented in future), we're also empty.
-	 */
-	rep = (void *)tb->buf + be64_to_cpu(tb->rpos & tb->mask);
-	if (be64_to_cpu(tb->end) != be64_to_cpu(tb->rpos) + sizeof(*rep))
-		return false;
-
-	if (rep->type != TRACE_REPEAT)
-		return false;
-
-	if (be16_to_cpu(rep->num) != be32_to_cpu(tb->last_repeat))
-		return false;
-
-	return true;
-}
-
-/* You can't read in parallel, so some locking required in caller. */
-bool trace_get(union trace *t, struct tracebuf *tb)
-{
-	u64 start, rpos;
-	size_t len;
-
-	len = sizeof(*t) < be32_to_cpu(tb->max_size) ? sizeof(*t) :
-		be32_to_cpu(tb->max_size);
-
-	if (trace_empty(tb))
-		return false;
-
-again:
-	/*
-	 * The actual buffer is slightly larger than tbsize, so this
-	 * memcpy is always valid.
-	 */
-	memcpy(t, tb->buf + be64_to_cpu(tb->rpos & tb->mask), len);
-
-	rmb(); /* read barrier, so we read tb->start after copying record. */
-
-	start = be64_to_cpu(tb->start);
-	rpos = be64_to_cpu(tb->rpos);
-
-	/* Now, was that overwritten? */
-	if (rpos < start) {
-		/* Create overflow record. */
-		t->overflow.unused64 = 0;
-		t->overflow.type = TRACE_OVERFLOW;
-		t->overflow.len_div_8 = sizeof(t->overflow) / 8;
-		t->overflow.bytes_missed = cpu_to_be64(start - rpos);
-		tb->rpos = cpu_to_be64(start);
-		return true;
-	}
-
-	/* Repeat entries need special handling */
-	if (t->hdr.type == TRACE_REPEAT) {
-		u32 num = be16_to_cpu(t->repeat.num);
-
-		/* In case we've read some already... */
-		t->repeat.num = cpu_to_be16(num - be32_to_cpu(tb->last_repeat));
-
-		/* Record how many repeats we saw this time. */
-		tb->last_repeat = cpu_to_be32(num);
-
-		/* Don't report an empty repeat buffer. */
-		if (t->repeat.num == 0) {
-			/*
-			 * This can't be the last buffer, otherwise
-			 * trace_empty would have returned true.
-			 */
-			assert(be64_to_cpu(tb->end) >
-			       rpos + t->hdr.len_div_8 * 8);
-			/* Skip to next entry. */
-			tb->rpos = cpu_to_be64(rpos + t->hdr.len_div_8 * 8);
-			tb->last_repeat = 0;
-			goto again;
-		}
-	} else {
-		tb->last_repeat = 0;
-		tb->rpos = cpu_to_be64(rpos + t->hdr.len_div_8 * 8);
-	}
-
-	return true;
-}
diff --git a/external/trace/trace.h b/external/trace/trace.h
deleted file mode 100644
index 4d2dbc796289..000000000000
--- a/external/trace/trace.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright 2013-2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * 	http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/* Is this tracebuf empty? */
-bool trace_empty(const struct tracebuf *tracebuf);
-
-/* Get the next trace from this buffer (false if empty). */
-bool trace_get(union trace *t, struct tracebuf *tb);
diff --git a/hw/fsp/fsp.c b/hw/fsp/fsp.c
index f7e674830f79..fc1be1035238 100644
--- a/hw/fsp/fsp.c
+++ b/hw/fsp/fsp.c
@@ -31,7 +31,6 @@
 #include <interrupts.h>
 #include <gx.h>
 #include <device.h>
-#include <trace.h>
 #include <timebase.h>
 #include <cpu.h>
 #include <errorlog.h>
@@ -125,9 +124,7 @@ static u64 fsp_hir_timeout;
 
 /*
  * We keep track on last logged values for some things to print only on
- * value changes, but also to relieve pressure on the tracer which
- * doesn't do a very good job at detecting repeats when called from
- * many different CPUs
+ * value changes
  */
 static u32 disr_last_print;
 static u32 drcr_last_print;
@@ -180,22 +177,6 @@ static struct fsp_cmdclass fsp_cmdclass[FSP_MCLASS_LAST - FSP_MCLASS_FIRST + 1]
 	DEF_CLASS(FSP_MCLASS_OCC,		16),
 };
 
-static void fsp_trace_msg(struct fsp_msg *msg, u8 dir __unused)
-{
-	union trace fsp __unused;
-#ifdef FSP_TRACE_MSG
-	size_t len = offsetof(struct trace_fsp_msg, data[msg->dlen]);
-
-	fsp.fsp_msg.dlen = msg->dlen;
-	fsp.fsp_msg.word0 = msg->word0;
-	fsp.fsp_msg.word1 = msg->word1;
-	fsp.fsp_msg.dir = dir;
-	memcpy(fsp.fsp_msg.data, msg->data.bytes, msg->dlen);
-	trace_add(&fsp, TRACE_FSP_MSG, len);
-#endif /* FSP_TRACE_MSG */
-	assert(msg->dlen <= sizeof(fsp.fsp_msg.data));
-}
-
 static struct fsp *fsp_get_active(void)
 {
 	/* XXX Handle transition between FSPs */
@@ -633,23 +614,6 @@ void fsp_reset_links(void)
 	return;
 }
 
-static void fsp_trace_event(struct fsp *fsp, u32 evt,
-			    u32 data0, u32 data1, u32 data2, u32 data3)
-{
-	union trace tfsp __unused;
-#ifdef FSP_TRACE_EVENT
-	size_t len = sizeof(struct trace_fsp_event);
-
-	tfsp.fsp_evt.event = evt;
-	tfsp.fsp_evt.fsp_state = fsp->state;
-	tfsp.fsp_evt.data[0] = data0;
-	tfsp.fsp_evt.data[1] = data1;
-	tfsp.fsp_evt.data[2] = data2;
-	tfsp.fsp_evt.data[3] = data3;
-	trace_add(&tfsp, TRACE_FSP_EVENT, len);
-#endif /* FSP_TRACE_EVENT */
-}
-
 static void fsp_handle_errors(struct fsp *fsp)
 {
 	u32 hstate;
@@ -678,7 +642,6 @@ static void fsp_handle_errors(struct fsp *fsp)
 	 */
 	if (!psi_check_link_active(psi)) {
 		/* Start R&R process */
-		fsp_trace_event(fsp, TRACE_FSP_EVT_LINK_DOWN, 0, 0, 0, 0);
 		prerror("FSP #%d: Link down, starting R&R\n", fsp->index);
 
 		fsp_start_rr(fsp);
@@ -690,8 +653,6 @@ static void fsp_handle_errors(struct fsp *fsp)
 
 	/* If in R&R, log values */
 	if (disr != disr_last_print) {
-		fsp_trace_event(fsp, TRACE_FSP_EVT_DISR_CHG, disr, 0, 0, 0);
-
 		prlog(PR_TRACE, "FSP #%d: DISR stat change = 0x%08x\n",
 		      fsp->index, disr);
 		disr_last_print = disr;
@@ -751,7 +712,6 @@ static void fsp_handle_errors(struct fsp *fsp)
 	if (disr & FSP_DISR_HIR_TRIGGER_MASK) {
 		const char *reason = "Unknown FSP_DISR_HIR_TRIGGER";
 		uint32_t plid;
-		fsp_trace_event(fsp, TRACE_FSP_EVT_SOFT_RR, disr, 0, 0, 0);
 
 		if (disr & FSP_DISR_FSP_UNIT_CHECK)
 			reason = "DISR Unit Check set";
@@ -783,8 +743,6 @@ static void fsp_handle_errors(struct fsp *fsp)
 		 * only do it while still in R&R state
 		 */
 		if (fsp->state == fsp_mbx_rr) {
-			fsp_trace_event(fsp, TRACE_FSP_EVT_RR_COMPL, 0,0,0,0);
-
 			prlog(PR_NOTICE, "FSP #%d: Detected R&R complete,"
 			      " acking\n", fsp->index);
 
@@ -821,8 +779,6 @@ static void fsp_handle_errors(struct fsp *fsp)
 
 	hstate = fsp_rreg(fsp, FSP_HDES_REG);
 	if (hstate != hstate_last_print) {
-		fsp_trace_event(fsp, TRACE_FSP_EVT_HDES_CHG, hstate, 0, 0, 0);
-
 		prlog(PR_DEBUG, "FSP #%d: HDES stat change = 0x%08x\n",
 		      fsp->index, hstate);
 		hstate_last_print = hstate;
@@ -926,11 +882,6 @@ static bool fsp_post_msg(struct fsp *fsp, struct fsp_msg *msg)
 	fsp->state = fsp_mbx_send;
 	msg->state = fsp_msg_sent;
 
-	/* We trace after setting the mailbox state so that if the
-	 * tracing recurses, it ends up just queuing the message up
-	 */
-	fsp_trace_msg(msg, TRACE_FSP_MSG_OUT);
-
 	/* Build the message in the mailbox */
 	reg = FSP_MBX1_HDATA_AREA;
 	fsp_wreg(fsp, reg, msg->word0); reg += 4;
@@ -1424,8 +1375,6 @@ static void __fsp_fill_incoming(struct fsp *fsp, struct fsp_msg *msg,
 		 FSP_MBX_CTL_HPEND |
 		 FSP_MBX_CTL_HCSP_MASK |
 		 FSP_MBX_CTL_DCSP_MASK);
-
-	fsp_trace_msg(msg, TRACE_FSP_MSG_IN);
 }
 
 static void __fsp_drop_incoming(struct fsp *fsp)
@@ -1558,16 +1507,6 @@ static void __fsp_poll(bool interrupt)
 	u32 ctl, hdir = 0;
 	bool psi_irq;
 
-	/*
-	 * The tracer isn't terribly efficient at detecting dups
-	 * especially when coming from multiple CPUs so we do our
-	 * own change-detection locally
-	 */
-	static u32 hdir_last_trace;
-	static u32 ctl_last_trace;
-	static bool psi_irq_last_trace;
-	static bool irq_last_trace;
-
 	if (!fsp)
 		return;
 
@@ -1620,24 +1559,9 @@ static void __fsp_poll(bool interrupt)
 	/* Read interrupt status (we may or may not use it) */
 	hdir = fsp_rreg(fsp, FSP_HDIR_REG);
 
-	/* Read control now as well so we can trace them */
 	ctl = fsp_rreg(fsp, FSP_MBX1_HCTL_REG);
-
-	/* Ditto with PSI irq state */
 	psi_irq = psi_poll_fsp_interrupt(iop->psi);
 
-	/* Trace it if anything changes */
-	if (hdir != hdir_last_trace || ctl != ctl_last_trace ||
-	    interrupt != irq_last_trace || psi_irq != psi_irq_last_trace) {
-		fsp_trace_event(fsp, TRACE_FSP_EVT_POLL_IRQ,
-				interrupt, hdir, ctl, psi_irq);
-
-		hdir_last_trace = hdir;
-		ctl_last_trace = ctl;
-		irq_last_trace = interrupt;
-		psi_irq_last_trace = psi_irq;
-	}
-
 	/*
 	 * We *MUST* ignore the MBOX2 bits here. While MBOX2 cannot generate
 	 * interrupt, it might still latch some bits here (and we found cases
diff --git a/hw/lpc-mbox.c b/hw/lpc-mbox.c
index 58a99692511e..6fe99c261508 100644
--- a/hw/lpc-mbox.c
+++ b/hw/lpc-mbox.c
@@ -24,7 +24,6 @@
 #include <interrupts.h>
 #include <processor.h>
 #include <errorlog.h>
-#include <trace.h>
 #include <timebase.h>
 #include <timer.h>
 #include <cpu.h>
diff --git a/hw/lpc-uart.c b/hw/lpc-uart.c
index 365bf3e27094..ebf9197186bb 100644
--- a/hw/lpc-uart.c
+++ b/hw/lpc-uart.c
@@ -22,7 +22,6 @@
 #include <interrupts.h>
 #include <processor.h>
 #include <errorlog.h>
-#include <trace.h>
 #include <timebase.h>
 #include <cpu.h>
 #include <chip.h>
@@ -77,17 +76,6 @@ void uart_set_console_policy(int policy)
 	uart_console_policy = policy;
 }
 
-static void uart_trace(u8 ctx, u8 cnt, u8 irq_state, u8 in_count)
-{
-	union trace t;
-
-	t.uart.ctx = ctx;
-	t.uart.cnt = cnt;
-	t.uart.irq_state = irq_state;
-	t.uart.in_count = cpu_to_be16(in_count);
-	trace_add(&t, TRACE_UART, sizeof(struct trace_uart));
-}
-
 static inline uint8_t uart_read(unsigned int reg)
 {
 	if (mmio_uart_base)
@@ -375,8 +363,6 @@ static int64_t uart_opal_read(int64_t term_number, int64_t *length,
 	/* Finally, flush whatever's left in the UART into our buffer */
 	uart_read_to_buffer();
 
-	uart_trace(TRACE_UART_CTX_READ, read_cnt, tx_full, in_count);
-
 	unlock(&uart_lock);
 
 	/* Adjust the OPAL event */
@@ -400,7 +386,7 @@ static int64_t uart_opal_flush(int64_t term_number)
 	return rc;
 }
 
-static void __uart_do_poll(u8 trace_ctx)
+static void __uart_do_poll(void)
 {
 	if (!in_buf)
 		return;
@@ -408,7 +394,6 @@ static void __uart_do_poll(u8 trace_ctx)
 	lock(&uart_lock);
 	uart_read_to_buffer();
 	uart_con_flush();
-	uart_trace(trace_ctx, 0, tx_full, in_count);
 	unlock(&uart_lock);
 
 	uart_adjust_opal_event();
@@ -416,7 +401,7 @@ static void __uart_do_poll(u8 trace_ctx)
 
 static void uart_console_poll(void *data __unused)
 {
-	__uart_do_poll(TRACE_UART_CTX_POLL);
+	__uart_do_poll();
 }
 
 static void uart_irq(uint32_t chip_id __unused, uint32_t irq_mask __unused)
@@ -425,7 +410,7 @@ static void uart_irq(uint32_t chip_id __unused, uint32_t irq_mask __unused)
 		prlog(PR_DEBUG, "UART: IRQ functional !\n");
 		irq_ok = true;
 	}
-	__uart_do_poll(TRACE_UART_CTX_IRQ);
+	__uart_do_poll();
 }
 
 /*
diff --git a/hw/psi.c b/hw/psi.c
index cbdbeaa9aeff..9c673b61d86c 100644
--- a/hw/psi.c
+++ b/hw/psi.c
@@ -24,7 +24,6 @@
 #include <gx.h>
 #include <interrupts.h>
 #include <cpu.h>
-#include <trace.h>
 #include <xscom.h>
 #include <chip.h>
 #include <lpc.h>
diff --git a/hw/sbe-p9.c b/hw/sbe-p9.c
index d52ada15a39f..4da72b9f2ae4 100644
--- a/hw/sbe-p9.c
+++ b/hw/sbe-p9.c
@@ -54,7 +54,6 @@
 #include <skiboot.h>
 #include <timebase.h>
 #include <timer.h>
-#include <trace.h>
 #include <xscom.h>
 
 enum p9_sbe_mbox_state {
diff --git a/include/cpu.h b/include/cpu.h
index 851fb8e808f9..25db03f81cad 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -57,7 +57,6 @@ struct cpu_thread {
 	struct cpu_thread		*primary;
 	enum cpu_thread_state		state;
 	struct dt_node			*node;
-	struct trace_info		*trace;
 	uint64_t			save_r1;
 	void				*icp_regs;
 	uint32_t			in_opal_call;
diff --git a/include/debug_descriptor.h b/include/debug_descriptor.h
index 619f49374385..6679728280b9 100644
--- a/include/debug_descriptor.h
+++ b/include/debug_descriptor.h
@@ -23,7 +23,7 @@
  */
 struct debug_descriptor {
 	u8	eye_catcher[8];	/* "OPALdbug" */
-#define DEBUG_DESC_VERSION	1
+#define DEBUG_DESC_VERSION	2
 	u32	version;
 	u8	console_log_levels;	/* high 4 bits in memory,
 					 * low 4 bits driver (e.g. uart). */
@@ -36,14 +36,6 @@ struct debug_descriptor {
 	u32	memcons_tce;
 	u32	memcons_obuf_tce;
 	u32	memcons_ibuf_tce;
-
-	/* Traces */
-	u64	trace_mask;
-	u32	num_traces;
-#define DEBUG_DESC_MAX_TRACES	256
-	u64	trace_phys[DEBUG_DESC_MAX_TRACES];
-	u32	trace_size[DEBUG_DESC_MAX_TRACES];
-	u32	trace_tce[DEBUG_DESC_MAX_TRACES];
 };
 extern struct debug_descriptor debug_descriptor;
 
diff --git a/include/trace.h b/include/trace.h
deleted file mode 100644
index da43572e2d06..000000000000
--- a/include/trace.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Copyright 2013-2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * 	http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __TRACE_H
-#define __TRACE_H
-#include <ccan/short_types/short_types.h>
-#include <stddef.h>
-#include <lock.h>
-#include <trace_types.h>
-
-#define TBUF_SZ (1024 * 1024)
-
-struct cpu_thread;
-
-/* Here's one we prepared earlier. */
-void init_boot_tracebuf(struct cpu_thread *boot_cpu);
-
-struct trace_info {
-	/* Lock for writers. */
-	struct lock lock;
-	/* Exposed to kernel. */
-	struct tracebuf tb;
-};
-
-/* Allocate trace buffers once we know memory topology */
-void init_trace_buffers(void);
-
-/* This will fill in timestamp and cpu; you must do type and len. */
-void trace_add(union trace *trace, u8 type, u16 len);
-
-/* Put trace node into dt. */
-void trace_add_node(void);
-#endif /* __TRACE_H */
diff --git a/include/trace_types.h b/include/trace_types.h
deleted file mode 100644
index 83c49a263c92..000000000000
--- a/include/trace_types.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/* Copyright 2013-2014 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * 	http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/* API for kernel to read trace buffer. */
-#ifndef __TRACE_TYPES_H
-#define __TRACE_TYPES_H
-
-#include <types.h>
-
-#define TRACE_REPEAT	1
-#define TRACE_OVERFLOW	2
-#define TRACE_OPAL	3	/* OPAL call */
-#define TRACE_FSP_MSG	4	/* FSP message sent/received */
-#define TRACE_FSP_EVENT	5	/* FSP driver event */
-#define TRACE_UART	6	/* UART driver traces */
-
-/* One per cpu, plus one for NMIs */
-struct tracebuf {
-	/* Mask to apply to get buffer offset. */
-	__be64 mask;
-	/* This where the buffer starts. */
-	__be64 start;
-	/* This is where writer has written to. */
-	__be64 end;
-	/* This is where the writer wrote to previously. */
-	__be64 last;
-	/* This is where the reader is up to. */
-	__be64 rpos;
-	/* If the last one we read was a repeat, this shows how many. */
-	__be32 last_repeat;
-	/* Maximum possible size of a record. */
-	__be32 max_size;
-
-	char buf[/* TBUF_SZ + max_size */];
-};
-
-/* Common header for all trace entries. */
-struct trace_hdr {
-	__be64 timestamp;
-	u8 type;
-	u8 len_div_8;
-	__be16 cpu;
-	u8 unused[4];
-};
-
-/* Note: all other entries must be at least as large as this! */
-struct trace_repeat {
-	__be64 timestamp; /* Last repeat happened at this timestamp */
-	u8 type; /* == TRACE_REPEAT */
-	u8 len_div_8;
-	__be16 cpu;
-	__be16 prev_len;
-	__be16 num; /* Starts at 1, ie. 1 repeat, or two traces. */
-	/* Note that the count can be one short, if read races a repeat. */
-};
-
-/* Overflow is special */
-struct trace_overflow {
-	__be64 unused64; /* Timestamp is unused */
-	u8 type; /* == TRACE_OVERFLOW */
-	u8 len_div_8;
-	u8 unused[6]; /* ie. hdr.cpu is indeterminate */
-	__be64 bytes_missed;
-};
-
-/* All other trace types have a full header */
-struct trace_opal {
-	struct trace_hdr hdr;
-	__be64 token, lr, sp, r3_to_11[9];
-};
-
-#define TRACE_FSP_MSG_IN	0
-#define TRACE_FSP_MSG_OUT	1
-
-struct trace_fsp_msg {
-	struct trace_hdr hdr;
-	__be32 word0;
-	__be32 word1;
-	u8 dlen;
-	u8 dir; /* TRACE_FSP_MSG_IN or TRACE_FSP_MSG_OUT */
-	u8 data[56]; /* See dlen, but max is 56 bytes. */
-};
-
-#define TRACE_FSP_EVT_LINK_DOWN		0
-#define TRACE_FSP_EVT_DISR_CHG		1 /* 0:disr */
-#define TRACE_FSP_EVT_SOFT_RR		2 /* 0:disr */
-#define TRACE_FSP_EVT_RR_COMPL		3
-#define TRACE_FSP_EVT_HDES_CHG		4 /* 0:hdes */
-#define TRACE_FSP_EVT_POLL_IRQ		5 /* 0:irq? 1:hdir 2:ctl 3:psi_irq */
-
-struct trace_fsp_event {
-	struct trace_hdr hdr;
-	__be16 event;
-	__be16 fsp_state;
-	__be32 data[4]; /* event type specific */
-};
-
-#define TRACE_UART_CTX_IRQ		0
-#define TRACE_UART_CTX_POLL		1
-#define TRACE_UART_CTX_READ		2
-
-struct trace_uart {
-	struct trace_hdr hdr;
-	u8 ctx;
-	u8 cnt;
-	u8 irq_state;
-	u8 unused;
-	__be16 in_count;
-};
-
-union trace {
-	struct trace_hdr hdr;
-	/* Trace types go here... */
-	struct trace_repeat repeat;
-	struct trace_overflow overflow;
-	struct trace_opal opal;
-	struct trace_fsp_msg fsp_msg;
-	struct trace_fsp_event fsp_evt;
-	struct trace_uart uart;
-};
-
-#endif /* __TRACE_TYPES_H */
diff --git a/platforms/ibm-fsp/common.c b/platforms/ibm-fsp/common.c
index a7f2beedcb78..eed0ec81088e 100644
--- a/platforms/ibm-fsp/common.c
+++ b/platforms/ibm-fsp/common.c
@@ -29,7 +29,7 @@
 
 static void map_debug_areas(void)
 {
-	uint64_t t, i;
+	uint64_t t;
 
 	/* Our memcons is in a section of its own and already
 	 * aligned to 4K. The buffers are mapped as a whole
@@ -42,40 +42,6 @@ static void map_debug_areas(void)
 	debug_descriptor.memcons_obuf_tce = t;
 	t = memcons.ibuf_phys - INMEM_CON_START + PSI_DMA_LOG_BUF;
 	debug_descriptor.memcons_ibuf_tce = t;
-
-	/* We only have space in the TCE table for the trace
-	 * areas on P8
-	 */
-	if (proc_gen != proc_gen_p8)
-		return;
-
-	t = PSI_DMA_TRACE_BASE;
-	for (i = 0; i < debug_descriptor.num_traces; i++) {
-		/*
-		 * Trace buffers are misaligned by 0x10 due to the lock
-		 * in the trace structure, and their size is also not
-		 * completely aligned. (They are allocated so that with
-		 * the lock included, they do cover entire multiple of
-		 * a 4K page however).
-		 *
-		 * This means we have to map the lock into the TCEs and
-		 * align everything. Not a huge deal but needs to be
-		 * taken into account.
-		 *
-		 * Note: Maybe we should map them read-only...
-		 */
-		uint64_t tstart, tend, toff, tsize;
-
-		tstart = ALIGN_DOWN(debug_descriptor.trace_phys[i], 0x1000);
-		tend = ALIGN_UP(debug_descriptor.trace_phys[i] +
-				debug_descriptor.trace_size[i], 0x1000);
-		toff = debug_descriptor.trace_phys[i] - tstart;
-		tsize = tend - tstart;
-
-		fsp_tce_map(t, (void *)tstart, tsize);
-		debug_descriptor.trace_tce[i] = t + toff;
-		t += tsize;
-	}
 }
 
 
-- 
2.19.1



More information about the Skiboot mailing list