Initialise DMA trace prior to platform initialisation so that more users may use trace as part of init.
Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com
dma trace fix --- src/include/reef/dma-trace.h | 2 +- src/include/reef/ipc.h | 2 +- src/include/reef/reef.h | 3 +++ src/init/init.c | 1 + src/ipc/intel-ipc.c | 9 +++++---- src/ipc/ipc.c | 1 + src/lib/dma-trace.c | 18 ++++++++---------- src/lib/trace.c | 4 ++++ src/platform/baytrail/platform.c | 4 +--- src/platform/haswell/platform.c | 4 +--- 10 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/src/include/reef/dma-trace.h b/src/include/reef/dma-trace.h index ab9c112..dcbd491 100644 --- a/src/include/reef/dma-trace.h +++ b/src/include/reef/dma-trace.h @@ -66,7 +66,7 @@ struct dma_trace_data { spinlock_t lock; };
-int dma_trace_init_early(struct dma_trace_data *d); +int dma_trace_init_early(struct reef *reef); 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); diff --git a/src/include/reef/ipc.h b/src/include/reef/ipc.h index bb814be..9261add 100644 --- a/src/include/reef/ipc.h +++ b/src/include/reef/ipc.h @@ -101,7 +101,7 @@ struct ipc { struct list_item comp_list; /* list of component devices */
/* DMA for Trace*/ - struct dma_trace_data dmat; + struct dma_trace_data *dmat;
void *private; }; diff --git a/src/include/reef/reef.h b/src/include/reef/reef.h index c872acc..e0df031 100644 --- a/src/include/reef/reef.h +++ b/src/include/reef/reef.h @@ -68,6 +68,9 @@ struct reef { /* system agent */ struct sa *sa;
+ /* DMA for Trace*/ + struct dma_trace_data *dmat; + /* private data */ void *arch_private; void *plat_private; diff --git a/src/init/init.c b/src/init/init.c index 03ac662..d847e11 100644 --- a/src/init/init.c +++ b/src/init/init.c @@ -41,6 +41,7 @@ #include <reef/work.h> #include <reef/trace.h> #include <reef/schedule.h> +#include <reef/dma-trace.h> #include <platform/platform.h>
/* main firmware context */ diff --git a/src/ipc/intel-ipc.c b/src/ipc/intel-ipc.c index fac3371..0cfec42 100644 --- a/src/ipc/intel-ipc.c +++ b/src/ipc/intel-ipc.c @@ -56,6 +56,7 @@ #include <reef/audio/pipeline.h> #include <uapi/ipc.h> #include <reef/intel-ipc.h> +#include <reef/dma-trace.h> #include <config.h>
#define iGS(x) ((x >> SOF_GLB_TYPE_SHIFT) & 0xf) @@ -626,7 +627,7 @@ static int ipc_dma_trace_config(uint32_t header) #endif trace_ipc("DAp");
- err = dma_trace_enable(&_ipc->dmat); + err = dma_trace_enable(_ipc->dmat); if (err < 0) goto error;
@@ -649,9 +650,9 @@ int ipc_dma_trace_send_position(void) struct sof_ipc_dma_trace_posn posn;
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.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/ipc/ipc.c b/src/ipc/ipc.c index 61b0cf2..b753efd 100644 --- a/src/ipc/ipc.c +++ b/src/ipc/ipc.c @@ -350,6 +350,7 @@ int ipc_init(struct reef *reef) /* init ipc data */ reef->ipc = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*reef->ipc)); reef->ipc->comp_data = rzalloc(RZONE_SYS, RFLAGS_NONE, SOF_IPC_MSG_MAX_SIZE); + reef->ipc->dmat = reef->dmat;
list_init(&reef->ipc->comp_list);
diff --git a/src/lib/dma-trace.c b/src/lib/dma-trace.c index 429c7b6..c72c55b 100644 --- a/src/lib/dma-trace.c +++ b/src/lib/dma-trace.c @@ -124,9 +124,12 @@ out: return DMA_TRACE_PERIOD; }
-int dma_trace_init_early(struct dma_trace_data *d) +int dma_trace_init_early(struct reef *reef) { - struct dma_trace_buf *buffer = &d->dmatb; + struct dma_trace_buf *buffer; + + trace_data = rzalloc(RZONE_SYS, RFLAGS_NONE, sizeof(*trace_data)); + buffer = &trace_data->dmatb;
/* allocate new buffer */ buffer->addr = rballoc(RZONE_RUNTIME, RFLAGS_NONE, DMA_TRACE_LOCAL_SIZE); @@ -142,15 +145,10 @@ int dma_trace_init_early(struct dma_trace_data *d) buffer->w_ptr = buffer->r_ptr = buffer->addr; 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;
- list_init(&d->config.elem_list); - spinlock_init(&d->lock); - trace_data = d; + list_init(&trace_data->config.elem_list); + spinlock_init(&trace_data->lock); + reef->dmat = trace_data;
return 0; } diff --git a/src/lib/trace.c b/src/lib/trace.c index 859bc0e..bfac6d3 100644 --- a/src/lib/trace.c +++ b/src/lib/trace.c @@ -208,6 +208,10 @@ void trace_off(void)
void trace_init(struct reef *reef) { + +#if defined(CONFIG_DMA_TRACE) + dma_trace_init_early(reef); +#endif trace.enable = 1; trace.pos = 0; spinlock_init(&trace.lock); diff --git a/src/platform/baytrail/platform.c b/src/platform/baytrail/platform.c index 3114ac1..11ea731 100644 --- a/src/platform/baytrail/platform.c +++ b/src/platform/baytrail/platform.c @@ -301,8 +301,6 @@ int platform_init(struct reef *reef) trace_point(TRACE_BOOT_PLATFORM_IPC); ipc_init(reef);
- dma_trace_init_early(&reef->ipc->dmat); - /* init DMACs */ trace_point(TRACE_BOOT_PLATFORM_DMA); dmac0 = dma_get(DMA_ID_DMAC0); @@ -365,7 +363,7 @@ int platform_init(struct reef *reef) #endif
/* Initialize DMA for Trace*/ - dma_trace_init_complete(&reef->ipc->dmat); + dma_trace_init_complete(reef->dmat);
return 0; } diff --git a/src/platform/haswell/platform.c b/src/platform/haswell/platform.c index b83e5fb..0b9274f 100644 --- a/src/platform/haswell/platform.c +++ b/src/platform/haswell/platform.c @@ -207,8 +207,6 @@ int platform_init(struct reef *reef) trace_point(TRACE_BOOT_PLATFORM_IPC); ipc_init(reef);
- dma_trace_init_early(&reef->ipc->dmat); - /* init DMACs */ trace_point(TRACE_BOOT_PLATFORM_DMA); dmac0 = dma_get(DMA_ID_DMAC0); @@ -242,7 +240,7 @@ int platform_init(struct reef *reef) dai_probe(ssp1);
/* Initialize DMA for Trace*/ - dma_trace_init_complete(&reef->ipc->dmat); + dma_trace_init_complete(reef->dmat);
return 0; }