From 48ae838cb2867a6faa144add6f1046f927d29e2c Mon Sep 17 00:00:00 2001 From: Bard liao Date: Sun, 28 Apr 2019 05:48:01 +0800 Subject: [PATCH] trace: get time stamp from kernel Timer will be reset when DSP is powered down. So the time stamp of trace log will be reset after resume. Get time stamp from kernel and adding it as a shift of time stamp can avoid the reset. Signed-off-by: Bard liao --- src/arch/xtensa/include/arch/timer.h | 1 + src/include/uapi/abi.h | 2 +- src/include/uapi/ipc/header.h | 1 + src/include/uapi/ipc/trace.h | 10 ++++++++++ src/ipc/handler.c | 9 ++++++++- src/lib/trace.c | 2 +- 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/arch/xtensa/include/arch/timer.h b/src/arch/xtensa/include/arch/timer.h index e36df6ba1e01..be9ef0f0fab6 100644 --- a/src/arch/xtensa/include/arch/timer.h +++ b/src/arch/xtensa/include/arch/timer.h @@ -43,6 +43,7 @@ struct timer { uint32_t hitime; /* high end of 64bit timer */ uint32_t hitimeout; uint32_t lowtimeout; + uint64_t delta; }; /* internal API calls */ diff --git a/src/include/uapi/abi.h b/src/include/uapi/abi.h index 2bf11c03a6a4..5a08f4039497 100644 --- a/src/include/uapi/abi.h +++ b/src/include/uapi/abi.h @@ -52,7 +52,7 @@ /** \brief SOF ABI version major, minor and patch numbers */ #define SOF_ABI_MAJOR 3 -#define SOF_ABI_MINOR 6 +#define SOF_ABI_MINOR 7 #define SOF_ABI_PATCH 0 /** \brief SOF ABI version number. Format within 32bit word is MMmmmppp */ diff --git a/src/include/uapi/ipc/header.h b/src/include/uapi/ipc/header.h index 915448c601d4..dce0f22e9884 100644 --- a/src/include/uapi/ipc/header.h +++ b/src/include/uapi/ipc/header.h @@ -169,6 +169,7 @@ #define SOF_IPC_TRACE_DMA_PARAMS SOF_CMD_TYPE(0x001) #define SOF_IPC_TRACE_DMA_POSITION SOF_CMD_TYPE(0x002) +#define SOF_IPC_TRACE_DMA_PARAMS_EXT SOF_CMD_TYPE(0x003) /** @} */ diff --git a/src/include/uapi/ipc/trace.h b/src/include/uapi/ipc/trace.h index 06c9cef0b2a8..3a8ad8f5a4fc 100644 --- a/src/include/uapi/ipc/trace.h +++ b/src/include/uapi/ipc/trace.h @@ -49,12 +49,22 @@ #define SOF_TRACE_FILENAME_SIZE 32 /* DMA for Trace params info - SOF_IPC_DEBUG_DMA_PARAMS */ +/* Deprecated - use sof_ipc_dma_trace_params_ext */ struct sof_ipc_dma_trace_params { struct sof_ipc_cmd_hdr hdr; struct sof_ipc_host_buffer buffer; uint32_t stream_tag; } __attribute__((packed)); +/* DMA for Trace params info - SOF_IPC_DEBUG_DMA_PARAMS_EXT */ +struct sof_ipc_dma_trace_params_ext { + struct sof_ipc_cmd_hdr hdr; + struct sof_ipc_host_buffer buffer; + uint32_t stream_tag; + uint64_t timestamp; + uint32_t reserved[8]; +} __attribute__((packed)); + /* DMA for Trace params info - SOF_IPC_DEBUG_DMA_PARAMS */ struct sof_ipc_dma_trace_posn { struct sof_ipc_reply rhdr; diff --git a/src/ipc/handler.c b/src/ipc/handler.c index 21592893b867..ea6786139d09 100644 --- a/src/ipc/handler.c +++ b/src/ipc/handler.c @@ -719,12 +719,18 @@ static int ipc_dma_trace_config(uint32_t header) struct dma_sg_elem_array elem_array; uint32_t ring_size; #endif - struct sof_ipc_dma_trace_params params; + struct sof_ipc_dma_trace_params_ext params; int err; /* copy message with ABI safe method */ IPC_COPY_CMD(params, _ipc->comp_data); + if (iCS(header) == SOF_IPC_TRACE_DMA_PARAMS_EXT) + platform_timer->delta = params.timestamp - + platform_timer_get(platform_timer); + else + platform_timer->delta = 0; + #ifdef CONFIG_SUECREEK return 0; #endif @@ -806,6 +812,7 @@ static int ipc_glb_debug_message(uint32_t header) switch (cmd) { case SOF_IPC_TRACE_DMA_PARAMS: + case SOF_IPC_TRACE_DMA_PARAMS_EXT: return ipc_dma_trace_config(header); default: trace_ipc_error("ipc: unknown debug cmd 0x%x", cmd); diff --git a/src/lib/trace.c b/src/lib/trace.c index c49cddb5e655..1b367dc61ae5 100644 --- a/src/lib/trace.c +++ b/src/lib/trace.c @@ -71,7 +71,7 @@ static void put_header(uint32_t *dst, uint32_t id_0, uint32_t id_1, header.id_0 = id_0 & TRACE_ID_MASK; header.id_1 = id_1 & TRACE_ID_MASK; header.core_id = cpu_get_id(); - header.timestamp = timestamp; + header.timestamp = timestamp + platform_timer->delta; header.log_entry_address = entry; memcpy(dst, &header, sizeof(header));