mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-16 02:14:58 +00:00
ASoC: SOF: Intel: hda-dai: Do not release the link DMA on STOP
The linkDMA should not be released on stop trigger since a stream re-start might happen without closing of the stream. This leaves a short time for other streams to 'steal' the linkDMA since it has been released. This issue is not easy to reproduce under normal conditions as usually after stop the stream is closed, or the same stream is restarted, but if another stream got in between the stop and start, like this: aplay -Dhw:0,3 -c2 -r48000 -fS32_LE /dev/zero -d 120 CTRL+z aplay -Dhw:0,0 -c2 -r48000 -fS32_LE /dev/zero -d 120 then the link DMA channels will be mixed up, resulting firmware error or crash. Fixes: ab5593793e90 ("ASoC: SOF: Intel: hda: Always clean up link DMA during stop") Cc: stable@vger.kernel.org Closes: https://github.com/thesofproject/sof/issues/9695 Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Liam Girdwood <liam.r.girdwood@intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://patch.msgid.link/20241217091019.31798-1-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
001a3d5e8b
commit
e8d0ba147d
@ -103,8 +103,10 @@ hda_dai_get_ops(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai
|
||||
return sdai->platform_private;
|
||||
}
|
||||
|
||||
int hda_link_dma_cleanup(struct snd_pcm_substream *substream, struct hdac_ext_stream *hext_stream,
|
||||
struct snd_soc_dai *cpu_dai)
|
||||
static int
|
||||
hda_link_dma_cleanup(struct snd_pcm_substream *substream,
|
||||
struct hdac_ext_stream *hext_stream,
|
||||
struct snd_soc_dai *cpu_dai, bool release)
|
||||
{
|
||||
const struct hda_dai_widget_dma_ops *ops = hda_dai_get_ops(substream, cpu_dai);
|
||||
struct sof_intel_hda_stream *hda_stream;
|
||||
@ -128,6 +130,17 @@ int hda_link_dma_cleanup(struct snd_pcm_substream *substream, struct hdac_ext_st
|
||||
snd_hdac_ext_bus_link_clear_stream_id(hlink, stream_tag);
|
||||
}
|
||||
|
||||
if (!release) {
|
||||
/*
|
||||
* Force stream reconfiguration without releasing the channel on
|
||||
* subsequent stream restart (without free), including LinkDMA
|
||||
* reset.
|
||||
* The stream is released via hda_dai_hw_free()
|
||||
*/
|
||||
hext_stream->link_prepared = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ops->release_hext_stream)
|
||||
ops->release_hext_stream(sdev, cpu_dai, substream);
|
||||
|
||||
@ -211,7 +224,7 @@ static int __maybe_unused hda_dai_hw_free(struct snd_pcm_substream *substream,
|
||||
if (!hext_stream)
|
||||
return 0;
|
||||
|
||||
return hda_link_dma_cleanup(substream, hext_stream, cpu_dai);
|
||||
return hda_link_dma_cleanup(substream, hext_stream, cpu_dai, true);
|
||||
}
|
||||
|
||||
static int __maybe_unused hda_dai_hw_params_data(struct snd_pcm_substream *substream,
|
||||
@ -304,7 +317,8 @@ static int __maybe_unused hda_dai_trigger(struct snd_pcm_substream *substream, i
|
||||
switch (cmd) {
|
||||
case SNDRV_PCM_TRIGGER_STOP:
|
||||
case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||
ret = hda_link_dma_cleanup(substream, hext_stream, dai);
|
||||
ret = hda_link_dma_cleanup(substream, hext_stream, dai,
|
||||
cmd == SNDRV_PCM_TRIGGER_STOP ? false : true);
|
||||
if (ret < 0) {
|
||||
dev_err(sdev->dev, "%s: failed to clean up link DMA\n", __func__);
|
||||
return ret;
|
||||
@ -660,8 +674,7 @@ static int hda_dai_suspend(struct hdac_bus *bus)
|
||||
}
|
||||
|
||||
ret = hda_link_dma_cleanup(hext_stream->link_substream,
|
||||
hext_stream,
|
||||
cpu_dai);
|
||||
hext_stream, cpu_dai, true);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
@ -1038,8 +1038,6 @@ 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);
|
||||
|
||||
static inline struct snd_sof_dev *widget_to_sdev(struct snd_soc_dapm_widget *w)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user