Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions sound/soc/sof/intel/hda-dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ static int hda_link_pcm_prepare(struct snd_pcm_substream *substream,
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in commit: dma_sata in subject

int stream = substream->stream;

if (link_dev->link_prepared)
if (link_dev && link_dev->link_prepared)
return 0;

dev_dbg(sdev->dev, "hda: prepare stream dir %d\n", substream->stream);
Expand All @@ -306,6 +306,10 @@ static int hda_link_pcm_trigger(struct snd_pcm_substream *substream,
bus = hstream->bus;
rtd = asoc_substream_to_rtd(substream);

/* when paused streams are never released after system resume, link_dev would be NULL. */
if (!link_dev)
return 0;

link = snd_hdac_ext_bus_get_link(bus, asoc_rtd_to_codec(rtd, 0)->component->name);
if (!link)
return -EINVAL;
Expand Down Expand Up @@ -347,7 +351,10 @@ static int hda_link_pcm_trigger(struct snd_pcm_substream *substream,
snd_hdac_ext_link_clear_stream_id(link, stream_tag);
}

snd_soc_dai_set_dma_data(dai, substream, NULL);
snd_hdac_ext_stream_release(link_dev, HDAC_EXT_STREAM_TYPE_LINK);
link_dev->link_prepared = 0;
hda_stream->host_reserved = 0;

fallthrough;
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
Expand Down Expand Up @@ -377,11 +384,8 @@ static int hda_link_hw_free(struct snd_pcm_substream *substream,
rtd = asoc_substream_to_rtd(substream);
link_dev = snd_soc_dai_get_dma_data(dai, substream);

if (!link_dev) {
dev_dbg(dai->dev,
"%s: link_dev is not assigned\n", __func__);
return -EINVAL;
}
if (!link_dev)
return 0;

hda_stream = hstream_to_sof_hda_stream(link_dev);

Expand Down
12 changes: 10 additions & 2 deletions sound/soc/sof/intel/hda-dsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ int hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev)
{
#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
struct hdac_bus *bus = sof_to_bus(sdev);
struct sof_intel_hda_stream *hda_stream;
struct snd_soc_pcm_runtime *rtd;
struct hdac_ext_stream *stream;
struct hdac_ext_link *link;
Expand All @@ -922,16 +923,23 @@ int hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev)
* explicitly during suspend.
*/
if (stream->link_substream) {
struct snd_soc_dai *cpu_dai;

rtd = asoc_substream_to_rtd(stream->link_substream);
cpu_dai = asoc_rtd_to_cpu(rtd, 0);
name = asoc_rtd_to_codec(rtd, 0)->component->name;
link = snd_hdac_ext_bus_get_link(bus, name);
if (!link)
return -EINVAL;

snd_soc_dai_set_dma_data(cpu_dai, stream->link_substream, NULL);
snd_hdac_ext_stream_release(stream, HDAC_EXT_STREAM_TYPE_LINK);
stream->link_prepared = 0;

if (hdac_stream(stream)->direction ==
SNDRV_PCM_STREAM_CAPTURE)
hda_stream = hstream_to_sof_hda_stream(stream);
hda_stream->host_reserved = 0;

if (hdac_stream(stream)->direction == SNDRV_PCM_STREAM_CAPTURE)
continue;

stream_tag = hdac_stream(stream)->stream_tag;
Expand Down
19 changes: 11 additions & 8 deletions sound/soc/sof/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,16 @@ static int sof_resume(struct device *dev, bool runtime_resume)
return ret;
}

/*
* Nothing further to be done for platforms that support the low power
* D0 substate.
*/
/* Only resume trace when resuming from low-power D0 substate */
if (!runtime_resume && sof_ops(sdev)->set_power_state &&
old_state == SOF_DSP_PM_D0)
old_state == SOF_DSP_PM_D0) {
/* this is not fatal */
ret = snd_sof_init_trace_ipc(sdev);
if (ret < 0)
dev_warn(sdev->dev, "failed to init trace after resume %d\n", ret);

return 0;
}

sdev->fw_state = SOF_FW_BOOT_PREPARE;

Expand Down Expand Up @@ -204,15 +207,15 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)

target_state = snd_sof_dsp_power_target(sdev);

/* release trace */
snd_sof_release_trace(sdev);

/* Skip to platform-specific suspend if DSP is entering D0 */
if (target_state == SOF_DSP_PM_D0)
goto suspend;

sof_tear_down_pipelines(sdev, false);

/* release trace */
snd_sof_release_trace(sdev);

#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE)
/* cache debugfs contents during runtime suspend */
if (runtime_suspend)
Expand Down
1 change: 0 additions & 1 deletion sound/soc/sof/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,6 @@ void snd_sof_release_trace(struct snd_sof_dev *sdev)

sdev->dtrace_is_enabled = false;
sdev->dtrace_draining = true;
wake_up(&sdev->trace_sleep);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, how can you be sure the user-space thread is not in sof_wait_trace_avail() ? The release trace can be called when sof-logger is still running and waiting for traces.

EXPORT_SYMBOL(snd_sof_release_trace);

Expand Down