Skip to content

Commit 9d50941

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 a80343f commit 9d50941

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

sound/soc/sof/ipc3-dtrace.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515
#define TRACE_FILTER_ELEMENTS_PER_ENTRY 4
1616
#define TRACE_FILTER_MAX_CONFIG_STRING_LENGTH 1024
1717

18+
static bool trace_pos_update_expected(struct snd_sof_dev *sdev)
19+
{
20+
if (sdev->dtrace_state == SOF_DTRACE_ENABLED ||
21+
sdev->dtrace_state == SOF_DTRACE_INITIALIZING)
22+
return true;
23+
24+
return false;
25+
}
26+
1827
static int trace_filter_append_elem(struct snd_sof_dev *sdev, u32 key, u32 value,
1928
struct sof_ipc_trace_filter_elem *elem_list,
2029
int capacity, int *counter)
@@ -254,7 +263,7 @@ static size_t sof_wait_dtrace_avail(struct snd_sof_dev *sdev, loff_t pos,
254263
if (ret)
255264
return ret;
256265

257-
if (sdev->dtrace_state != SOF_DTRACE_ENABLED && sdev->dtrace_draining) {
266+
if (sdev->dtrace_draining && !trace_pos_update_expected(sdev)) {
258267
/*
259268
* tracing has ended and all traces have been
260269
* read by client, return EOF
@@ -419,13 +428,16 @@ static int ipc3_dtrace_enable(struct snd_sof_dev *sdev)
419428
dev_dbg(sdev->dev, "%s: stream_tag: %d\n", __func__, params.stream_tag);
420429

421430
/* send IPC to the DSP */
431+
sdev->dtrace_state = SOF_DTRACE_INITIALIZING;
422432
ret = sof_ipc_tx_message(sdev->ipc, &params, sizeof(params), &ipc_reply, sizeof(ipc_reply));
423433
if (ret < 0) {
424434
dev_err(sdev->dev, "can't set params for DMA for trace %d\n", ret);
425435
goto trace_release;
426436
}
427437

428438
start:
439+
sdev->dtrace_state = SOF_DTRACE_ENABLED;
440+
429441
ret = snd_sof_dma_trace_trigger(sdev, SNDRV_PCM_TRIGGER_START);
430442
if (ret < 0) {
431443
dev_err(sdev->dev, "Host dtrace trigger start failed: %d\n", ret);
@@ -506,7 +518,7 @@ int ipc3_dtrace_posn_update(struct snd_sof_dev *sdev,
506518
if (!sdev->fw_trace_is_supported)
507519
return 0;
508520

509-
if (sdev->dtrace_state == SOF_DTRACE_ENABLED &&
521+
if (trace_pos_update_expected(sdev) &&
510522
sdev->host_offset != posn->host_offset) {
511523
sdev->host_offset = posn->host_offset;
512524
wake_up(&sdev->trace_sleep);

sound/soc/sof/sof-priv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ struct snd_sof_ipc {
465465
enum sof_dtrace_state {
466466
SOF_DTRACE_DISABLED,
467467
SOF_DTRACE_STOPPED,
468+
SOF_DTRACE_INITIALIZING,
468469
SOF_DTRACE_ENABLED,
469470
};
470471

0 commit comments

Comments
 (0)