diff --git a/src/include/sof/ipc/msg.h b/src/include/sof/ipc/msg.h index 4a536b03b..1c9c39eac 100644 --- a/src/include/sof/ipc/msg.h +++ b/src/include/sof/ipc/msg.h @@ -114,6 +114,12 @@ void ipc_build_stream_posn(struct sof_ipc_stream_posn *posn, uint32_t type, void ipc_build_comp_event(struct sof_ipc_comp_event *event, uint32_t type, uint32_t id); +/** + * \brief Check if trace buffer is ready for transmission. + * @param[in,out] avail Data available in trace buffer + */ +bool ipc_trigger_trace_xfer(uint32_t avail); + /** * \brief Build trace position IPC message. * @param[in,out] posn Trace position message diff --git a/src/ipc/ipc3/helper.c b/src/ipc/ipc3/helper.c index 9db85d306..3a3e44de8 100644 --- a/src/ipc/ipc3/helper.c +++ b/src/ipc/ipc3/helper.c @@ -59,6 +59,11 @@ void ipc_build_comp_event(struct sof_ipc_comp_event *event, uint32_t type, event->src_comp_id = id; } +bool ipc_trigger_trace_xfer(uint32_t avail) +{ + return true; +} + void ipc_build_trace_posn(struct sof_ipc_dma_trace_posn *posn) { posn->rhdr.hdr.cmd = SOF_IPC_GLB_TRACE_MSG | diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index eaf236b00..fd2b58010 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -49,6 +49,11 @@ void ipc_build_comp_event(struct sof_ipc_comp_event *event, uint32_t type, { } +bool ipc_trigger_trace_xfer(uint32_t avail) +{ + return avail >= DMA_TRACE_LOCAL_SIZE / 2; +} + void ipc_build_trace_posn(struct sof_ipc_dma_trace_posn *posn) { posn->rhdr.hdr.cmd = SOF_IPC4_NOTIF_HEADER(SOF_IPC4_NOTIFY_LOG_BUFFER_STATUS); diff --git a/src/trace/dma-trace.c b/src/trace/dma-trace.c index 7cc26fa1d..f8ccfe6be 100644 --- a/src/trace/dma-trace.c +++ b/src/trace/dma-trace.c @@ -67,6 +67,9 @@ static enum task_state trace_work(void *data) if (!d->dc.chan) return SOF_TASK_STATE_RESCHEDULE; + if (!ipc_trigger_trace_xfer(avail)) + return SOF_TASK_STATE_RESCHEDULE; + /* make sure we don't write more than buffer */ if (avail > DMA_TRACE_LOCAL_SIZE) { overflow = avail - DMA_TRACE_LOCAL_SIZE;