Skip to content

Commit 2fc5773

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 5a81ef7 commit 2fc5773

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

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)
@@ -255,7 +264,7 @@ static size_t sof_wait_dtrace_avail(struct snd_sof_dev *sdev, loff_t pos,
255264
if (ret)
256265
return ret;
257266

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

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

429439
start:
440+
sdev->dtrace_state = SOF_DTRACE_ENABLED;
441+
430442
ret = snd_sof_dma_trace_trigger(sdev, SNDRV_PCM_TRIGGER_START);
431443
if (ret < 0) {
432444
dev_err(sdev->dev, "Host dtrace trigger start failed: %d\n", ret);
@@ -507,7 +519,7 @@ int ipc3_dtrace_posn_update(struct snd_sof_dev *sdev,
507519
if (!sdev->fw_trace_is_supported)
508520
return 0;
509521

510-
if (sdev->dtrace_state == SOF_DTRACE_ENABLED &&
522+
if (trace_pos_update_expected(sdev) &&
511523
sdev->host_offset != posn->host_offset) {
512524
sdev->host_offset = posn->host_offset;
513525
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
@@ -464,6 +464,7 @@ struct snd_sof_ipc {
464464
enum sof_dtrace_state {
465465
SOF_DTRACE_DISABLED,
466466
SOF_DTRACE_STOPPED,
467+
SOF_DTRACE_INITIALIZING,
467468
SOF_DTRACE_ENABLED,
468469
};
469470

0 commit comments

Comments
 (0)