Skip to content

Commit eb80144

Browse files
committed
ASoC: SOF: trace: Introduce SOF_DTRACE_INITIALIZING state
With the new state we can make sure we are not missing the first host_offset update. In case the dtrace is small, the DMA copy will be fast and depending on the moonphase it might be done before we set the sdev->dtrace_state to SOF_DTRACE_ENABLED. The DMA will start the copy as soon as the host starts the DMA. Set the dtrace to enabled before we let the DMA to run in order to avoid missing the position update. The new state is needed to cover architectures where the host side snd_sof_dma_trace_trigger() is a NOP and the dtrace in the firmware is ready as soon as the IPC message has been processed. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent c26e1b0 commit eb80144

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

sound/soc/sof/sof-priv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ struct snd_sof_ipc {
446446
enum sof_dtrace_state {
447447
SOF_DTRACE_DISABLED,
448448
SOF_DTRACE_STOPPED,
449+
SOF_DTRACE_INITIALIZING,
449450
SOF_DTRACE_ENABLED,
450451
};
451452

sound/soc/sof/trace.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ static int snd_sof_enable_trace(struct snd_sof_dev *sdev)
429429
dev_dbg(sdev->dev, "%s: stream_tag: %d\n", __func__, params.stream_tag);
430430

431431
/* send IPC to the DSP */
432+
sdev->dtrace_state = SOF_DTRACE_INITIALIZING;
432433
ret = sof_ipc_tx_message(sdev->ipc, &params, sizeof(params), &ipc_reply, sizeof(ipc_reply));
433434
if (ret < 0) {
434435
dev_err(sdev->dev,
@@ -437,15 +438,15 @@ static int snd_sof_enable_trace(struct snd_sof_dev *sdev)
437438
}
438439

439440
start:
441+
sdev->dtrace_state = SOF_DTRACE_ENABLED;
442+
440443
ret = snd_sof_dma_trace_trigger(sdev, SNDRV_PCM_TRIGGER_START);
441444
if (ret < 0) {
442445
dev_err(sdev->dev,
443446
"error: snd_sof_dma_trace_trigger: start: %d\n", ret);
444447
goto trace_release;
445448
}
446449

447-
sdev->dtrace_state = SOF_DTRACE_ENABLED;
448-
449450
return 0;
450451

451452
trace_release:
@@ -524,7 +525,8 @@ int snd_sof_trace_update_pos(struct snd_sof_dev *sdev,
524525
if (!sdev->dtrace_is_supported)
525526
return 0;
526527

527-
if (sdev->dtrace_state == SOF_DTRACE_ENABLED &&
528+
if ((sdev->dtrace_state == SOF_DTRACE_ENABLED ||
529+
sdev->dtrace_state == SOF_DTRACE_INITIALIZING) &&
528530
sdev->host_offset != posn->host_offset) {
529531
sdev->host_offset = posn->host_offset;
530532
wake_up(&sdev->trace_sleep);

0 commit comments

Comments
 (0)