From 454fde245531d7e3928b61dbfd1c5158aef00401 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Thu, 2 Apr 2026 14:05:22 +0800 Subject: [PATCH] ASoC: SOF: Intel: reset SPIB in hda_data_stream_cleanup The register will indicate to the host DMA where the position is in the buffer currently processed by host SW. Reset it to 0 in hda_data_stream_cleanup. The register is ignored by the host DMA if SPIB is disabled. That's why the "enable" parameter needs to be HDA_DSP_SPIB_ENABLE. Signed-off-by: Bard Liao --- sound/soc/sof/intel/hda-stream.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/sound/soc/sof/intel/hda-stream.c b/sound/soc/sof/intel/hda-stream.c index 1c04b5d9c0d8b6..b102e39760c67a 100644 --- a/sound/soc/sof/intel/hda-stream.c +++ b/sound/soc/sof/intel/hda-stream.c @@ -1324,11 +1324,23 @@ int hda_data_stream_cleanup(struct device *dev, struct snd_dma_buffer *dmab, struct snd_sof_dev *sdev = dev_get_drvdata(dev); struct hdac_stream *hstream = hdac_stream(hext_stream); int sd_offset = SOF_STREAM_SD_OFFSET(hstream); - int ret = 0; + int ret1; + int ret; - if (hstream->direction == SNDRV_PCM_STREAM_PLAYBACK) - ret = hda_dsp_stream_spib_config(sdev, hext_stream, HDA_DSP_SPIB_DISABLE, 0); - else + /* + * Reset SPIB. The SPIB value will only take effect when SPIB is enabled, + * That is why we need to set the value with HDA_DSP_SPIB_ENABLE + */ + ret = hda_dsp_stream_spib_config(sdev, hext_stream, HDA_DSP_SPIB_ENABLE, 0); + if (ret < 0) { + dev_err(sdev->dev, "%s: failed to reset SPIB: %d\n", __func__, ret); + } + + ret1 = hda_dsp_stream_spib_config(sdev, hext_stream, HDA_DSP_SPIB_DISABLE, 0); + if (!ret) + ret = ret1; + + if (hstream->direction == SNDRV_PCM_STREAM_CAPTURE) snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, sd_offset, SOF_HDA_SD_CTL_DMA_START, 0);