[alsa-devel] [PATCH v3 5/8] ASoC: soc-pcm: call snd_soc_dai_startup()/shutdown() once
Amadeusz Sławiński
amadeuszx.slawinski at linux.intel.com
Fri Mar 27 19:16:10 CET 2020
On 2/10/2020 4:14 AM, Kuninori Morimoto wrote:
>
> From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
>
> Current soc_pcm_open() calls snd_soc_dai_startup() under loop.
> Thus, it needs to care about started/not-yet-started codec DAI.
>
> But, if soc-dai.c is handling it, soc-pcm.c don't need to care
> about it.
> This patch adds started flag to soc-dai.h, and simplify soc-pcm.c.
> This is one of prepare for cleanup soc-pcm-open()
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
> ---
(...)
> static inline void *snd_soc_dai_get_dma_data(const struct snd_soc_dai *dai,
> diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
> index 51031e33..73a8293 100644
> --- a/sound/soc/soc-dai.c
> +++ b/sound/soc/soc-dai.c
> @@ -295,17 +295,24 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai,
> {
> int ret = 0;
>
> - if (dai->driver->ops->startup)
> + if (!dai->started &&
> + dai->driver->ops->startup)
> ret = dai->driver->ops->startup(substream, dai);
>
> + if (ret == 0)
> + dai->started = 1;
> +
> return ret;
> }
Hi,
the above change breaks simultaneous playback and capture on single DAI
in more complicated use cases. With above change when one runs playback
first, startup callback is skipped when running capture while playback
is still running.
With snd_soc_skl it leads to null pointer dereference, because we didn't
initialize streams properly:
[ 78.901574] dpcm_be_dai_hw_params:2219: Analog Playback and Capture:
ASoC: hw_params BE Analog Playback and Capture
[ 78.901582] dapm_update_dai_unlocked:2638: snd_hda_codec_realtek
ehdaudio0D0: Update DAI routes for Analog Codec DAI capture
[ 78.901585] dapm_update_dai_chan:2612: snd_hda_codec_realtek
ehdaudio0D0: Connecting DAI route AIF3TX -> Analog Codec Capture
[ 78.901590] dapm_update_dai_chan:2612: snd_hda_codec_realtek
ehdaudio0D0: Connecting DAI route AIF1TX -> Analog Codec Capture
[ 78.901608] dapm_update_dai_unlocked:2638: snd_soc_skl 0000:00:1f.3:
Update DAI routes for Analog CPU DAI capture
[ 78.901612] dapm_update_dai_chan:2612: snd_soc_skl 0000:00:1f.3:
Connecting DAI route Analog CPU Capture -> codec0_in
[ 78.901615] dpcm_fe_dai_hw_params:2277: Analog HDA DSP: ASoC:
hw_params FE Analog HDA DSP rate 48000 chan 2 fmt 2
[ 78.901622] skl_pcm_hw_params:307: snd_soc_skl 0000:00:1f.3:
skl_pcm_hw_params: hda-dsp-analog-dai
[ 78.901624]
==================================================================
[ 78.907515] BUG: KASAN: null-ptr-deref in
skl_pcm_hw_params+0x102/0x3d0 [snd_soc_skl]
[ 78.914003] Write of size 4 at addr 0000000000000044 by task arecord/2119
Amadeusz
More information about the Alsa-devel
mailing list