ASoC: SOF: send time stamp to FW for alignment
authorBard liao <yung-chuan.liao@linux.intel.com>
Mon, 3 Jun 2019 16:18:17 +0000 (11:18 -0500)
committerMark Brown <broonie@kernel.org>
Mon, 3 Jun 2019 17:41:23 +0000 (18:41 +0100)
Timer will be reset when DSP is powered down. So the time stamp of trace
log will be reset after resume. Send time stamp to FW can align the time
stamp and avoid reset time stamp in trace log.

Signed-off-by: Bard liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/sof/header.h
include/sound/sof/trace.h
include/uapi/sound/sof/abi.h
sound/soc/sof/trace.c

index 1efcf7b18ec20cdf186f94b24b094aac1f4df734..ab5862d80afedf820c7d6e53dbec23f424ff081e 100644 (file)
 /* trace and debug */
 #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)
 
 /* Get message component id */
 #define SOF_IPC_MESSAGE_ID(x)                  ((x) & 0xffff)
index 7d211f319a92e2d385612c4efa5bec8f675beed2..2187ff7d07ce2f02e953572da366303124c37011 100644 (file)
 #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;
 }  __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_ns; /* in nanosecond */
+       uint32_t reserved[8];
+}  __packed;
+
 /* DMA for Trace params info - SOF_IPC_DEBUG_DMA_PARAMS */
 struct sof_ipc_dma_trace_posn {
        struct sof_ipc_reply rhdr;
index 0868eb47acf7e8ecd57824723f17824ab955085b..92eee681bc6286e005efe71ae1c925be411048f9 100644 (file)
@@ -26,7 +26,7 @@
 
 /* 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
 
 /* SOF ABI version number. Format within 32bit word is MMmmmppp */
index b02520f8e5954f54c2a01efb3ca56fd19d56b626..befed975161cb74edaf958a6aeb93ad919cd0a4c 100644 (file)
@@ -161,7 +161,9 @@ static int trace_debugfs_create(struct snd_sof_dev *sdev)
 
 int snd_sof_init_trace_ipc(struct snd_sof_dev *sdev)
 {
-       struct sof_ipc_dma_trace_params params;
+       struct sof_ipc_fw_ready *ready = &sdev->fw_ready;
+       struct sof_ipc_fw_version *v = &ready->version;
+       struct sof_ipc_dma_trace_params_ext params;
        struct sof_ipc_reply ipc_reply;
        int ret;
 
@@ -169,8 +171,16 @@ int snd_sof_init_trace_ipc(struct snd_sof_dev *sdev)
                return -EINVAL;
 
        /* set IPC parameters */
-       params.hdr.size = sizeof(params);
-       params.hdr.cmd = SOF_IPC_GLB_TRACE_MSG | SOF_IPC_TRACE_DMA_PARAMS;
+       params.hdr.cmd = SOF_IPC_GLB_TRACE_MSG;
+       /* PARAMS_EXT is only supported from ABI 3.7.0 onwards */
+       if (v->abi_version >= SOF_ABI_VER(3, 7, 0)) {
+               params.hdr.size = sizeof(struct sof_ipc_dma_trace_params_ext);
+               params.hdr.cmd |= SOF_IPC_TRACE_DMA_PARAMS_EXT;
+               params.timestamp_ns = ktime_get(); /* in nanosecond */
+       } else {
+               params.hdr.size = sizeof(struct sof_ipc_dma_trace_params);
+               params.hdr.cmd |= SOF_IPC_TRACE_DMA_PARAMS;
+       }
        params.buffer.phy_addr = sdev->dmatp.addr;
        params.buffer.size = sdev->dmatb.bytes;
        params.buffer.pages = sdev->dma_trace_pages;