Skip to content

Commit 7af8fff

Browse files
committed
ASoC: SOF: ipc3-dtrace: 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 e890361 commit 7af8fff

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

sound/soc/sof/ipc3-dtrace.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
enum sof_dtrace_state {
1919
SOF_DTRACE_DISABLED,
2020
SOF_DTRACE_STOPPED,
21+
SOF_DTRACE_INITIALIZING,
2122
SOF_DTRACE_ENABLED,
2223
};
2324

@@ -32,6 +33,15 @@ struct sof_dtrace_priv {
3233
enum sof_dtrace_state dtrace_state;
3334
};
3435

36+
static bool trace_pos_update_expected(struct sof_dtrace_priv *priv)
37+
{
38+
if (priv->dtrace_state == SOF_DTRACE_ENABLED ||
39+
priv->dtrace_state == SOF_DTRACE_INITIALIZING)
40+
return true;
41+
42+
return false;
43+
}
44+
3545
static int trace_filter_append_elem(struct snd_sof_dev *sdev, u32 key, u32 value,
3646
struct sof_ipc_trace_filter_elem *elem_list,
3747
int capacity, int *counter)
@@ -273,7 +283,7 @@ static size_t sof_wait_dtrace_avail(struct snd_sof_dev *sdev, loff_t pos,
273283
if (ret)
274284
return ret;
275285

276-
if (priv->dtrace_state != SOF_DTRACE_ENABLED && priv->dtrace_draining) {
286+
if (priv->dtrace_draining && !trace_pos_update_expected(priv)) {
277287
/*
278288
* tracing has ended and all traces have been
279289
* read by client, return EOF
@@ -444,24 +454,26 @@ static int ipc3_dtrace_enable(struct snd_sof_dev *sdev)
444454
dev_dbg(sdev->dev, "%s: stream_tag: %d\n", __func__, params.stream_tag);
445455

446456
/* send IPC to the DSP */
457+
priv->dtrace_state = SOF_DTRACE_INITIALIZING;
447458
ret = sof_ipc_tx_message(sdev->ipc, &params, sizeof(params), &ipc_reply, sizeof(ipc_reply));
448459
if (ret < 0) {
449460
dev_err(sdev->dev, "can't set params for DMA for trace %d\n", ret);
450461
goto trace_release;
451462
}
452463

453464
start:
465+
priv->dtrace_state = SOF_DTRACE_ENABLED;
466+
454467
ret = sof_dtrace_host_trigger(sdev, SNDRV_PCM_TRIGGER_START);
455468
if (ret < 0) {
456469
dev_err(sdev->dev, "Host dtrace trigger start failed: %d\n", ret);
457470
goto trace_release;
458471
}
459472

460-
priv->dtrace_state = SOF_DTRACE_ENABLED;
461-
462473
return 0;
463474

464475
trace_release:
476+
priv->dtrace_state = SOF_DTRACE_DISABLED;
465477
sof_dtrace_host_release(sdev);
466478
return ret;
467479
}
@@ -545,7 +557,7 @@ int ipc3_dtrace_posn_update(struct snd_sof_dev *sdev,
545557
if (!sdev->fw_trace_is_supported)
546558
return 0;
547559

548-
if (priv->dtrace_state == SOF_DTRACE_ENABLED &&
560+
if (trace_pos_update_expected(priv) &&
549561
priv->host_offset != posn->host_offset) {
550562
priv->host_offset = posn->host_offset;
551563
wake_up(&priv->trace_sleep);

0 commit comments

Comments
 (0)