mirror of https://github.com/thesofproject/sof.git
trace: core: add trace_flush()
This patch adds a new trace_flush() feature to flush the last remaining trace messages during panic. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
This commit is contained in:
parent
3d8089ed0f
commit
cb1fc87454
|
@ -72,6 +72,7 @@ int dma_trace_init_complete(struct dma_trace_data *d);
|
|||
int dma_trace_host_buffer(struct dma_trace_data *d, struct dma_sg_elem *elem,
|
||||
uint32_t host_size);
|
||||
int dma_trace_enable(struct dma_trace_data *d);
|
||||
void dma_trace_flush(void *t);
|
||||
|
||||
void dtrace_event(const char *e, uint32_t size);
|
||||
void dtrace_event_atomic(const char *e, uint32_t length);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <reef/reef.h>
|
||||
#include <reef/mailbox.h>
|
||||
#include <reef/interrupt.h>
|
||||
#include <reef/trace.h>
|
||||
#include <platform/platform.h>
|
||||
#include <uapi/ipc.h>
|
||||
#include <stdint.h>
|
||||
|
@ -59,8 +60,13 @@ static inline void panic_rewind(uint32_t p, uint32_t stack_rewind_frames)
|
|||
|
||||
/* TODO: send IPC oops message to host */
|
||||
|
||||
/* panic and loop forever */
|
||||
/* panic */
|
||||
platform_panic(p);
|
||||
|
||||
/* flush last trace messages */
|
||||
trace_flush();
|
||||
|
||||
/* and loop forever */
|
||||
while (1) {};
|
||||
}
|
||||
|
||||
|
|
|
@ -106,6 +106,7 @@ void _trace_error(uint32_t event);
|
|||
void _trace_error_value(uint32_t event);
|
||||
void _trace_event_atomic(uint32_t event);
|
||||
void _trace_error_atomic(uint32_t event);
|
||||
void trace_flush(void);
|
||||
void trace_off(void);
|
||||
void trace_init(struct reef * reef);
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <arch/cache.h>
|
||||
#include <platform/timer.h>
|
||||
#include <platform/dma.h>
|
||||
#include <platform/platform.h>
|
||||
#include <reef/lock.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -285,6 +286,40 @@ int dma_trace_enable(struct dma_trace_data *d)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void dma_trace_flush(void *t)
|
||||
{
|
||||
struct dma_trace_buf *buffer = &trace_data->dmatb;
|
||||
uint32_t avail = buffer->avail;
|
||||
int32_t size;
|
||||
int32_t wrap_count;
|
||||
|
||||
/* number of bytes to flush */
|
||||
if (avail > DMA_FLUSH_TRACE_SIZE) {
|
||||
size = DMA_FLUSH_TRACE_SIZE;
|
||||
} else {
|
||||
/* check for buffer wrap */
|
||||
if (buffer->w_ptr > buffer->r_ptr)
|
||||
size = buffer->w_ptr - buffer->r_ptr;
|
||||
else
|
||||
size = buffer->end_addr - buffer->r_ptr +
|
||||
buffer->w_ptr - buffer->addr;
|
||||
}
|
||||
|
||||
/* check for buffer wrap */
|
||||
if (buffer->w_ptr - size < buffer->addr) {
|
||||
wrap_count = buffer->w_ptr - buffer->addr;
|
||||
memcpy(t, buffer->end_addr - (size - wrap_count),
|
||||
size - wrap_count);
|
||||
memcpy(t + (size - wrap_count), buffer->addr,
|
||||
wrap_count);
|
||||
} else {
|
||||
memcpy(t, buffer->w_ptr - size, size);
|
||||
}
|
||||
|
||||
/* writeback trace data */
|
||||
dcache_writeback_region(t, size);
|
||||
}
|
||||
|
||||
static void dtrace_add_event(const char *e, uint32_t length)
|
||||
{
|
||||
struct dma_trace_buf *buffer = &trace_data->dmatb;
|
||||
|
|
|
@ -136,6 +136,17 @@ void _trace_event_atomic(uint32_t event)
|
|||
dtrace_event_atomic((const char*)dt, sizeof(uint64_t) * 2);
|
||||
}
|
||||
|
||||
void trace_flush(void)
|
||||
{
|
||||
volatile uint64_t *t;
|
||||
|
||||
/* get mailbox position */
|
||||
t = (volatile uint64_t *)(MAILBOX_TRACE_BASE + trace.pos);
|
||||
|
||||
/* flush dma trace messages */
|
||||
dma_trace_flush((void *)t);
|
||||
}
|
||||
|
||||
void trace_off(void)
|
||||
{
|
||||
trace.enable = 0;
|
||||
|
|
|
@ -88,6 +88,9 @@ struct reef;
|
|||
/* local buffer size of DMA tracing */
|
||||
#define DMA_TRACE_LOCAL_SIZE HOST_PAGE_SIZE
|
||||
|
||||
/* trace bytes flushed during panic */
|
||||
#define DMA_FLUSH_TRACE_SIZE (MAILBOX_TRACE_SIZE >> 2)
|
||||
|
||||
/* the interval of DMA trace copying */
|
||||
#define DMA_TRACE_PERIOD 500000
|
||||
|
||||
|
|
|
@ -82,6 +82,9 @@ struct reef;
|
|||
/* local buffer size of DMA tracing */
|
||||
#define DMA_TRACE_LOCAL_SIZE HOST_PAGE_SIZE
|
||||
|
||||
/* trace bytes flushed during panic */
|
||||
#define DMA_FLUSH_TRACE_SIZE (MAILBOX_TRACE_SIZE >> 2)
|
||||
|
||||
/* the interval of DMA trace copying */
|
||||
#define DMA_TRACE_PERIOD 500000
|
||||
|
||||
|
|
|
@ -92,6 +92,9 @@ struct reef;
|
|||
/* local buffer size of DMA tracing */
|
||||
#define DMA_TRACE_LOCAL_SIZE HOST_PAGE_SIZE
|
||||
|
||||
/* trace bytes flushed during panic */
|
||||
#define DMA_FLUSH_TRACE_SIZE (MAILBOX_TRACE_SIZE >> 2)
|
||||
|
||||
/* the interval of DMA trace copying */
|
||||
#define DMA_TRACE_PERIOD 500000
|
||||
|
||||
|
|
|
@ -81,6 +81,9 @@ struct reef;
|
|||
/* local buffer size of DMA tracing */
|
||||
#define DMA_TRACE_LOCAL_SIZE HOST_PAGE_SIZE
|
||||
|
||||
/* trace bytes flushed during panic */
|
||||
#define DMA_FLUSH_TRACE_SIZE (MAILBOX_TRACE_SIZE >> 2)
|
||||
|
||||
/* the interval of DMA trace copying */
|
||||
#define DMA_TRACE_PERIOD 500000
|
||||
|
||||
|
|
Loading…
Reference in New Issue