[Sound-open-firmware] [PATCH] configure.ac: add CONFIG_DMA_TRACE flag for DMA trace feature

Liam Girdwood liam.r.girdwood at linux.intel.com
Wed Dec 6 08:23:57 CET 2017


On Wed, 2017-12-06 at 13:15 +0800, Keyon Jie wrote:
> We only support DMA trace feature on Baytrail, Cherrytrail
> at the moment, if CONFIG_DMA_TRACE flag is not defined, we
> will use traditional mailbox trace instead.
> 
> Signed-off-by: Keyon Jie <yang.jie at linux.intel.com>
> ---
>  configure.ac        |  2 ++
>  src/ipc/dma-copy.c  |  2 ++
>  src/ipc/intel-ipc.c |  4 ++++
>  src/lib/trace.c     | 58
> +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 66 insertions(+)
> 

This is more useful as a DEBUG option when DMA is broken/suspect as all
platforms should use DMA trace as default tracing mechanism. You could
use a cmd line option in configure.ac using AC_ARG_WITH() to
enable/disable DMA trace (default is enabled).

Liam

> diff --git a/configure.ac b/configure.ac
> index 8946c36..093d0b4 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -81,6 +81,7 @@ case "$with_platform" in
>  	AC_SUBST(XTENSA_CORE)
>  
>  	AC_DEFINE([CONFIG_BAYTRAIL], [1], [Configure for Baytrail])
> +	AC_DEFINE([CONFIG_DMA_TRACE], [1], [Configure DMA trace])
>      ;;
>      cherrytrail*)
>  
> @@ -97,6 +98,7 @@ case "$with_platform" in
>  	AC_SUBST(XTENSA_CORE)
>  
>  	AC_DEFINE([CONFIG_CHERRYTRAIL], [1], [Configure for
> Cherrytrail])
> +	AC_DEFINE([CONFIG_DMA_TRACE], [1], [Configure DMA trace])
>      ;;
>      *)
>          AC_MSG_ERROR([Host platform not specified])
> 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;


More information about the Sound-open-firmware mailing list