Skip to contentSkip to conversation

ASoC: SOF: intel: hda: Clean up link DMA for IPC3 during stop

PATCH In review Jaroslav Kysela 2 participants 2 messages Aug 21, 2023 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: SOF: intel: hda: Clean up link DMA for IPC3 during stop

From: Ranjani Sridharan <[email protected]>

commit 90219f1bd273055f1dc1d7bdc0965755b992c045 upstream.

With IPC3, we reset hw_params during the stop trigger, so we should also clean up the link DMA during the stop trigger.

Note that many recent Intel based laptops are affected.

Added missing code for 6.4 kernels to keep the fix simple not depending on the other changes. This commit is present in 6.5 tree already.

---
 sound/soc/sof/intel/hda-dai-ops.c | 13 ++++++++++++-
 sound/soc/sof/intel/hda-dai.c     |  8 ++++----
 sound/soc/sof/intel/hda.h         |  2 ++
 3 files changed, 18 insertions(+), 5 deletions(-)
sound/soc/sof/intel/hda-dai-ops.c +12 -1
index 4b39cecacd68..5938046f46b2 100644
@@ -289,16 +289,27 @@ static const struct hda_dai_widget_dma_ops hda_ipc4_chain_dma_ops = {
 static int hda_ipc3_post_trigger(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
 				 struct snd_pcm_substream *substream, int cmd)
 {
+	struct hdac_ext_stream *hext_stream = hda_get_hext_stream(sdev, cpu_dai, substream);
 	struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(cpu_dai, substream->stream);
+	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_SUSPEND:
 	case SNDRV_PCM_TRIGGER_STOP:
 	{
 		struct snd_sof_dai_config_data data = { 0 };
+		int ret;
 
 		data.dai_data = DMA_CHAN_INVALID;
-		return hda_dai_config(w, SOF_DAI_CONFIG_FLAGS_HW_FREE, &data);
+		ret = hda_dai_config(w, SOF_DAI_CONFIG_FLAGS_HW_FREE, &data);
+		if (ret < 0)
+			return ret;
+
+		if (cmd == SNDRV_PCM_TRIGGER_STOP)
+			return hda_link_dma_cleanup(substream, hext_stream, cpu_dai, codec_dai);
+
+		break;
 	}
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
 		return hda_dai_config(w, SOF_DAI_CONFIG_FLAGS_PAUSE, NULL);
sound/soc/sof/intel/hda-dai.c +4 -4
index 44a5d94c5050..8a76320c3b99 100644
@@ -91,10 +91,10 @@ hda_dai_get_ops(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai
 	return sdai->platform_private;
 }
 
-static int hda_link_dma_cleanup(struct snd_pcm_substream *substream,
-				struct hdac_ext_stream *hext_stream,
-				struct snd_soc_dai *cpu_dai,
-				struct snd_soc_dai *codec_dai)
+int hda_link_dma_cleanup(struct snd_pcm_substream *substream,
+			 struct hdac_ext_stream *hext_stream,
+			 struct snd_soc_dai *cpu_dai,
+			 struct snd_soc_dai *codec_dai)
 {
 	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(cpu_dai->component);
 	const struct hda_dai_widget_dma_ops *ops = hda_dai_get_ops(substream, cpu_dai);
sound/soc/sof/intel/hda.h +2 -0
index c4befacde23e..94c738eae751 100644
@@ -942,5 +942,7 @@ const struct hda_dai_widget_dma_ops *
 hda_select_dai_widget_ops(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
 int hda_dai_config(struct snd_soc_dapm_widget *w, unsigned int flags,
 		   struct snd_sof_dai_config_data *data);
+int hda_link_dma_cleanup(struct snd_pcm_substream *substream, struct hdac_ext_stream *hext_stream,
+			 struct snd_soc_dai *cpu_dai, struct snd_soc_dai *codec_dai);
 
 #endif
Signature · 1 line
2.41.0
maintainer
#1 lore raw
Quoted 22 lines · Jaroslav Kysela

From: Ranjani Sridharan <[email protected]>

commit 90219f1bd273055f1dc1d7bdc0965755b992c045 upstream.

With IPC3, we reset hw_params during the stop trigger, so we should also clean up the link DMA during the stop trigger.

Quoted 6 lines

Note that many recent Intel based laptops are affected.

Added missing code for 6.4 kernels to keep the fix simple not depending on the other changes. This commit is present in 6.5 tree already.

Now queued up, thanks.

greg k-h