For debug reason, e.g. DMA trace doesn't work or not implemented yet, we can use --disable-dma-trace in configure command line, which will unset CONFIG_DMA_TRACE flag, and it will fallback to use traditional mailbox trace instead.
The flag is set by default, if we don't add '--disable-dma-trace' to configure command.
Signed-off-by: Keyon Jie yang.jie@linux.intel.com --- configure.ac | 8 ++++++++ src/ipc/dma-copy.c | 2 ++ src/ipc/intel-ipc.c | 4 ++++ src/lib/trace.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+)
diff --git a/configure.ac b/configure.ac index 8946c36..6d67220 100644 --- a/configure.ac +++ b/configure.ac @@ -122,6 +122,14 @@ case "$with_dsp_core" in
esac
+# dma trace support (Optional), dma trace by default +AC_ARG_ENABLE([dma-trace], + AS_HELP_STRING([--disable-dma-trace], [Disabled dma trace and use fallback mailbox trace])) + +AS_IF([test "x$enable_dma_trace" != "xno"], [ + AC_DEFINE([CONFIG_DMA_TRACE], [1], [Configure DMA trace]) + ]) + # Test after CFLAGS set othewise test of cross compiler fails. AM_PROG_AS AM_PROG_AR diff --git a/src/ipc/dma-copy.c b/src/ipc/dma-copy.c index 8565966..57d3e3d 100644 --- a/src/ipc/dma-copy.c +++ b/src/ipc/dma-copy.c @@ -77,7 +77,9 @@ static void dma_complete(void *data, uint32_t type, struct dma_sg_elem *next) if (type == DMA_IRQ_TYPE_LLIST) wait_completed(comp);
+#if defined(CONFIG_DMA_TRACE) ipc_dma_trace_send_position(); +#endif
next->size = DMA_RELOAD_END; } diff --git a/src/ipc/intel-ipc.c b/src/ipc/intel-ipc.c index e13b541..4c310b6 100644 --- a/src/ipc/intel-ipc.c +++ b/src/ipc/intel-ipc.c @@ -585,6 +585,7 @@ static int ipc_glb_pm_message(uint32_t header) } }
+#if defined(CONFIG_DMA_TRACE) /* * Debug IPC Operations. */ @@ -662,6 +663,7 @@ static int ipc_glb_debug_message(uint32_t header) return -EINVAL; } } +#endif
/* * Topology IPC Operations. @@ -877,8 +879,10 @@ int ipc_cmd(void) return ipc_glb_stream_message(hdr->cmd); case iGS(SOF_IPC_GLB_DAI_MSG): return ipc_glb_dai_message(hdr->cmd); +#if defined(CONFIG_DMA_TRACE) case iGS(SOF_IPC_GLB_TRACE_MSG): return ipc_glb_debug_message(hdr->cmd); +#endif default: trace_ipc_error("eGc"); trace_value(type); diff --git a/src/lib/trace.c b/src/lib/trace.c index eec93b5..bb81d47 100644 --- a/src/lib/trace.c +++ b/src/lib/trace.c @@ -111,6 +111,8 @@ void _trace_error_atomic(uint32_t event) dcache_writeback_region((void*)t, sizeof(uint64_t) * 2); }
+#if defined(CONFIG_DMA_TRACE) + void _trace_event(uint32_t event) { uint64_t dt[2]; @@ -135,6 +137,62 @@ void _trace_event_atomic(uint32_t event) dtrace_event_atomic((const char*)dt, sizeof(uint64_t) * 2); }
+#else + +void _trace_event(uint32_t event) +{ + unsigned long flags; + uint64_t time, *t; + + if (!trace.enable) + return; + + time = platform_timer_get(platform_timer); + + /* send event by mail box too. */ + spin_lock_irq(&trace.lock, flags); + + /* write timestamp and event to trace buffer */ + t = (uint64_t *)(MAILBOX_TRACE_BASE + trace.pos); + trace.pos += (sizeof(uint64_t) << 1); + + if (trace.pos > MAILBOX_TRACE_SIZE - sizeof(uint64_t) * 2) + trace.pos = 0; + + spin_unlock_irq(&trace.lock, flags); + + t[0] = time; + t[1] = event; + + /* writeback trace data */ + dcache_writeback_region((void *)t, sizeof(uint64_t) * 2); +} + +void _trace_event_atomic(uint32_t event) +{ + uint64_t time, *t; + + if (!trace.enable) + return; + + time = platform_timer_get(platform_timer); + + /* write timestamp and event to trace buffer */ + t = (uint64_t *)(MAILBOX_TRACE_BASE + trace.pos); + trace.pos += (sizeof(uint64_t) << 1); + + if (trace.pos > MAILBOX_TRACE_SIZE - sizeof(uint64_t) * 2) + trace.pos = 0; + + t[0] = time; + t[1] = event; + + /* writeback trace data */ + dcache_writeback_region((void *)t, sizeof(uint64_t) * 2); +} + +#endif + void trace_off(void) { trace.enable = 0;