From: Yan Wang yan.wang@linux.intel.com
For global trace level type, need one level array to save current trace levels. And it also need set/get functions to operate these trace levels.
Signed-off-by: Yan Wang yan.wang@linux.intel.com --- Test with: CNL nocodec SOF master: c1f2682c210201bbbc96fce7b382b25b90d19775 SOF-Tool master: 86fe688a2b4f68a1ce87e0951686be12a00f1a3c https://github.com/plbossart/sound/tree/topic/sof-v4.14: d09db67c5a9d6dfc85f700669fa2e43c678c8d51 --- src/include/sof/dma-trace.h | 7 ++++++ src/lib/dma-trace.c | 61 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+)
diff --git a/src/include/sof/dma-trace.h b/src/include/sof/dma-trace.h index 81ce0a2..42780ab 100644 --- a/src/include/sof/dma-trace.h +++ b/src/include/sof/dma-trace.h @@ -65,6 +65,7 @@ struct dma_trace_data { uint32_t enabled; uint32_t copy_in_progress; uint32_t stream_tag; + uint32_t global_trace_level[SOF_DMA_TRACE_LEVEL_END]; spinlock_t lock; };
@@ -73,9 +74,15 @@ 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); +int dma_trace_set_global_level(struct dma_trace_data *d, + enum sof_dma_trace_level_type type, + uint32_t level); 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);
+uint32_t get_global_class_trace_level(uint32_t event); +uint32_t get_global_value_trace_level(void); + #endif diff --git a/src/lib/dma-trace.c b/src/lib/dma-trace.c index 01a9925..8295f3e 100644 --- a/src/lib/dma-trace.c +++ b/src/lib/dma-trace.c @@ -269,8 +269,17 @@ static int dma_trace_start(struct dma_trace_data *d)
#endif
+int dma_trace_set_global_level(struct dma_trace_data *d, + enum sof_dma_trace_level_type type, + uint32_t level) +{ + d->global_trace_level[type] = level; + return 0; +} + int dma_trace_enable(struct dma_trace_data *d) { + int i; #if defined CONFIG_DMA_GW int err;
@@ -290,6 +299,10 @@ int dma_trace_enable(struct dma_trace_data *d) }
d->enabled = 1; + + for (i = 0; i < SOF_DMA_TRACE_LEVEL_END; i++) + d->global_trace_level[i] = 1; + work_schedule_default(&d->dmat_work, DMA_TRACE_PERIOD); return 0; } @@ -354,6 +367,54 @@ static void dtrace_add_event(const char *e, uint32_t length) trace_data->messages++; }
+uint32_t get_global_class_trace_level(uint32_t e) +{ + struct dma_trace_data *d = trace_data; + uint32_t class, level = 1; + + /* check whether this event should be sent */ + class = e & 0xff000000; + + switch (class) { + case TRACE_CLASS_IRQ: + level = d->global_trace_level[SOF_DMA_TRACE_LEVEL_IRQ]; + break; + case TRACE_CLASS_IPC: + level = d->global_trace_level[SOF_DMA_TRACE_LEVEL_IPC]; + break; + case TRACE_CLASS_DMA: + level = d->global_trace_level[SOF_DMA_TRACE_LEVEL_DMA]; + break; + case TRACE_CLASS_SSP: + level = d->global_trace_level[SOF_DMA_TRACE_LEVEL_SSP]; + break; + case TRACE_CLASS_WAIT: + level = d->global_trace_level[SOF_DMA_TRACE_LEVEL_WAIT]; + break; + case TRACE_CLASS_LOCK: + level = d->global_trace_level[SOF_DMA_TRACE_LEVEL_LOCK]; + break; + case TRACE_CLASS_MEM: + level = d->global_trace_level[SOF_DMA_TRACE_LEVEL_MEM]; + break; + case TRACE_CLASS_SA: + level = d->global_trace_level[SOF_DMA_TRACE_LEVEL_SA]; + break; + case TRACE_CLASS_SCH: + level = d->global_trace_level[SOF_DMA_TRACE_LEVEL_SCH]; + break; + default: + break; + } + + return level; +} + +uint32_t get_global_value_trace_level(void) +{ + return trace_data->global_trace_level[SOF_DMA_TRACE_LEVEL_VALUE]; +} + void dtrace_event(const char *e, uint32_t length) { struct dma_trace_buf *buffer = NULL;