From 12cb5bef63b97df56dc2c976a2a902811bc7e088 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 1 Dec 2026 11:43:50 +0200 Subject: [PATCH] ASoC: SOF: Intel: hda-dai: Prepare the link DMA on START if needed The link DMA is reset on STOP trigger and it is expected to be configured again in the BE prepare before the next START. When a BE is shared by two FEs (FE1 and FE2) this is not guaranteed: FE1: hw_params, prepare, start FE2: hw_params, prepare (stays in PREPARED state) FE1: stop (BE is stopped, link DMA reset) At this point the BE is in STOP state while FE2 is still PREPARED, which leads to a BE START without prepare in these sequences: a) FE1: prepare, start The BE prepare is skipped by DPCM since FE2 is in PREPARED state. b) FE2: start No prepare is done at all. c) FE1: hw_params, prepare FE2: start FE1: start The BE prepare is skipped for FE1 since FE2 is in PREPARED state and the BE is started by FE2. The BE is started with an unconfigured link DMA and the streams stall after the host DMA has filled up the buffers. Run the prepare of the DAI on START if the link DMA is not prepared. Fixes: ab5593793e90 ("ASoC: SOF: Intel: hda: Always clean up link DMA during stop") Closes: https://github.com/thesofproject/sof/issues/11566 Signed-off-by: Peter Ujfalusi --- sound/soc/sof/intel/hda-dai.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index 7a8875a885ab34..3bc342627365c3 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -353,6 +353,23 @@ static int __maybe_unused hda_dai_trigger(struct snd_pcm_substream *substream, i return 0; } + /* + * The link DMA is reset on STOP and it is expected to be configured + * again in the BE prepare before the next START. + * When the BE is shared by multiple FEs, DPCM can start the BE again + * without preparing it: the BE prepare is skipped while another FE + * using the BE is in PREPARED state, and that FE can also start the BE + * directly. Run the prepare of the DAI here to configure the link DMA. + */ + if (cmd == SNDRV_PCM_TRIGGER_START && !hext_stream->link_prepared && + dai->driver->ops && dai->driver->ops->prepare) { + dev_dbg(dai->dev, "link DMA not prepared, preparing it for START\n"); + + ret = dai->driver->ops->prepare(substream, dai); + if (ret < 0) + return ret; + } + if (ops->pre_trigger) { ret = ops->pre_trigger(sdev, dai, substream, cmd); if (ret < 0)