Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ASoC: SOF: Intel: Make sure that link and host DMA is coupled after use
@ 2026-10-08  9:00 Peter Ujfalusi
  2026-10-08 10:17 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Ujfalusi @ 2026-10-08  9:00 UTC (permalink / raw)
  To: lgirdwood, broonie
  Cc: linux-sound, kai.vehmanen, yung-chuan.liao, pierre-louis.bossart

Couple the Host and Link DMA when the stream is put.
When the hda_dsp_stream_hw_free() is called the Link DMA might be still
locked and we would leave the DMAs decoupled.
hda_dsp_stream_hw_free() is not called for code loader use or in case of
probes or trace use for example.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
 sound/soc/sof/intel/hda-stream.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/sound/soc/sof/intel/hda-stream.c b/sound/soc/sof/intel/hda-stream.c
index c95230487a1b..759719cf8ab0 100644
--- a/sound/soc/sof/intel/hda-stream.c
+++ b/sound/soc/sof/intel/hda-stream.c
@@ -293,9 +293,8 @@ static int _hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stre
 {
 	const struct sof_intel_dsp_desc *chip_info =  get_chip_info(sdev->pdata);
 	struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
+	struct hdac_ext_stream *hext_stream_match = NULL;
 	struct hdac_bus *bus = sof_to_bus(sdev);
-	struct sof_intel_hda_stream *hda_stream;
-	struct hdac_ext_stream *hext_stream;
 	struct hdac_ext_stream *link_stream;
 	struct hdac_stream *s;
 	bool dmi_l1_enable = true;
@@ -308,6 +307,9 @@ static int _hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stre
 	 * that are DMI L1 incompatible.
 	 */
 	list_for_each_entry(s, &bus->stream_list, list) {
+		struct sof_intel_hda_stream *hda_stream;
+		struct hdac_ext_stream *hext_stream;
+
 		hext_stream = stream_to_hdac_ext_stream(s);
 		hda_stream = container_of(hext_stream, struct sof_intel_hda_stream, hext_stream);
 
@@ -315,6 +317,7 @@ static int _hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stre
 			continue;
 
 		if (s->direction == direction && s->stream_tag == stream_tag) {
+			hext_stream_match = hext_stream;
 			s->opened = false;
 			found = true;
 			if (pair)
@@ -324,6 +327,20 @@ static int _hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stre
 		}
 	}
 
+	if (!sdev->dspless_mode_selected && !pair && hext_stream_match) {
+		/*
+		 * Couple host and link DMA if link DMA is unused
+		 * In case of channel pair the snd_hdac_ext_stream_release() will
+		 * take care of coupling te HDA channel.
+		 */
+		if (!hext_stream_match->link_locked) {
+			u32 mask = BIT(hext_stream_match->hstream.index);
+
+			snd_sof_dsp_update_bits(sdev, HDA_DSP_PP_BAR,
+						SOF_HDA_REG_PP_PPCTL, mask, 0);
+		}
+	}
+
 	spin_unlock_irq(&bus->reg_lock);
 
 	/* Enable DMI L1 if permitted */
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: SOF: Intel: Make sure that link and host DMA is coupled after use
  2026-10-08  9:00 [PATCH] ASoC: SOF: Intel: Make sure that link and host DMA is coupled after use Peter Ujfalusi
@ 2026-10-08 10:17 ` Mark Brown
  2026-10-08 14:41   ` Péter Ujfalusi
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2026-10-08 10:17 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: lgirdwood, linux-sound, kai.vehmanen, yung-chuan.liao,
	pierre-louis.bossart

[-- Attachment #1: Type: text/plain, Size: 438 bytes --]

On Thu, Oct 08, 2026 at 12:00:45PM +0300, Peter Ujfalusi wrote:
> Couple the Host and Link DMA when the stream is put.
> When the hda_dsp_stream_hw_free() is called the Link DMA might be still
> locked and we would leave the DMAs decoupled.
> hda_dsp_stream_hw_free() is not called for code loader use or in case of
> probes or trace use for example.

This looks like it needs a rebase - it doesn't seem to apply against
anything I have.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: SOF: Intel: Make sure that link and host DMA is coupled after use
  2026-10-08 10:17 ` Mark Brown
@ 2026-10-08 14:41   ` Péter Ujfalusi
  0 siblings, 0 replies; 3+ messages in thread
From: Péter Ujfalusi @ 2026-10-08 14:41 UTC (permalink / raw)
  To: Mark Brown
  Cc: lgirdwood, linux-sound, kai.vehmanen, yung-chuan.liao,
	pierre-louis.bossart



On 08/10/2026 13:17, Mark Brown wrote:
> On Thu, Oct 08, 2026 at 12:00:45PM +0300, Peter Ujfalusi wrote:
>> Couple the Host and Link DMA when the stream is put.
>> When the hda_dsp_stream_hw_free() is called the Link DMA might be still
>> locked and we would leave the DMAs decoupled.
>> hda_dsp_stream_hw_free() is not called for code loader use or in case of
>> probes or trace use for example.
> 
> This looks like it needs a rebase - it doesn't seem to apply against
> anything I have.

I just picked it on top of you for-next, but but was created yesterday
sometime, sorry, I will check.

-- 
Péter


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-08 14:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-08  9:00 [PATCH] ASoC: SOF: Intel: Make sure that link and host DMA is coupled after use Peter Ujfalusi
2026-10-08 10:17 ` Mark Brown
2026-10-08 14:41   ` Péter Ujfalusi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox