[Sound-open-firmware] [PATCH 2/2] trace: dma: Help kernel and userspace detect missing trace messages.
Liam Girdwood
liam.r.girdwood at linux.intel.com
Tue Dec 19 18:27:52 CET 2017
Add message count and overflow detection to the trace position output
so that kernel and userspace can detect the trace buffer has overflowed.
Signed-off-by: Liam Girdwood <liam.r.girdwood at linux.intel.com>
---
src/include/reef/dma-trace.h | 2 ++
src/include/uapi/ipc.h | 2 ++
src/ipc/intel-ipc.c | 2 ++
src/lib/dma-trace.c | 9 ++++++++-
4 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/include/reef/dma-trace.h b/src/include/reef/dma-trace.h
index 4b17953..ab9c112 100644
--- a/src/include/reef/dma-trace.h
+++ b/src/include/reef/dma-trace.h
@@ -57,6 +57,8 @@ struct dma_trace_data {
struct dma_trace_buf dmatb;
struct dma_copy dc;
uint32_t host_offset;
+ uint32_t overflow;
+ uint32_t messages;
uint32_t host_size;
struct work dmat_work;
uint32_t enabled;
diff --git a/src/include/uapi/ipc.h b/src/include/uapi/ipc.h
index dc35035..7123c8e 100644
--- a/src/include/uapi/ipc.h
+++ b/src/include/uapi/ipc.h
@@ -816,6 +816,8 @@ struct sof_ipc_dma_trace_params {
struct sof_ipc_dma_trace_posn {
struct sof_ipc_reply rhdr;
uint32_t host_offset; /* Offset of DMA host buffer */
+ uint32_t overflow; /* overflow bytes if any */
+ uint32_t messages; /* total trace messages */
} __attribute__((packed));
#endif
diff --git a/src/ipc/intel-ipc.c b/src/ipc/intel-ipc.c
index 5ddb1e3..5a98e1f 100644
--- a/src/ipc/intel-ipc.c
+++ b/src/ipc/intel-ipc.c
@@ -648,6 +648,8 @@ int ipc_dma_trace_send_position(void)
posn.rhdr.hdr.cmd = SOF_IPC_GLB_TRACE_MSG | SOF_IPC_TRACE_DMA_POSITION;
posn.host_offset = _ipc->dmat.host_offset;
+ posn.overflow = _ipc->dmat.overflow;
+ posn.messages = _ipc->dmat.messages;
posn.rhdr.hdr.size = sizeof(posn);
return ipc_queue_host_message(_ipc, posn.rhdr.hdr.cmd, &posn,
diff --git a/src/lib/dma-trace.c b/src/lib/dma-trace.c
index 0dccf7e..ea63ab4 100644
--- a/src/lib/dma-trace.c
+++ b/src/lib/dma-trace.c
@@ -60,8 +60,12 @@ static uint64_t trace_work(void *data, uint64_t delay)
d->copy_in_progress = 1;
/* make sure we dont write more than buffer */
- if (avail > DMA_TRACE_LOCAL_SIZE)
+ if (avail > DMA_TRACE_LOCAL_SIZE) {
+ d->overflow = avail - DMA_TRACE_LOCAL_SIZE;
avail = DMA_TRACE_LOCAL_SIZE;
+ } else {
+ d->overflow = 0;
+ }
/* copy to host in sections if we wrap */
lsize = hsize = avail;
@@ -134,6 +138,8 @@ int dma_trace_init_early(struct dma_trace_data *d)
buffer->end_addr = buffer->addr + buffer->size;
buffer->avail = 0;
d->host_offset = 0;
+ d->overflow = 0;
+ d->messages = 0;
d->enabled = 0;
d->copy_in_progress = 0;
@@ -217,6 +223,7 @@ static void dtrace_add_event(const char *e, uint32_t length)
}
buffer->avail += length;
+ trace_data->messages++;
}
void dtrace_event(const char *e, uint32_t length)
--
2.14.1
More information about the Sound-open-firmware
mailing list