[Sound-open-firmware] [PATCH 08/14] ASoC: SOF: fix uninitialised "work" with VirtIO

Sridharan, Ranjani ranjani.sridharan at intel.com
Fri Mar 13 16:24:07 CET 2020


On Thu, Mar 12, 2020 at 7:51 AM Guennadi Liakhovetski <
guennadi.liakhovetski at linux.intel.com> wrote:

> In the VirtIO case the sof_pcm_open() function isn't called on the
> host during guest streaming, which then leaves "work" structures
> uninitialised. However it is then used to handle position update
> messages from the DSP. Move their initialisation to immediately after
> allocation of the containing structure.
>
> Signed-off-by: Guennadi Liakhovetski <
> guennadi.liakhovetski at linux.intel.com>
> ---
>  sound/soc/sof/pcm.c      | 2 --
>  sound/soc/sof/topology.c | 5 +++++
>  2 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c
> index f4769e1..cd77796 100644
> --- a/sound/soc/sof/pcm.c
> +++ b/sound/soc/sof/pcm.c
> @@ -475,8 +475,6 @@ static int sof_pcm_open(struct snd_soc_component
> *component,
>         dev_dbg(component->dev, "pcm: open stream %d dir %d\n",
>                 spcm->pcm.pcm_id, substream->stream);
>
> -       INIT_WORK(&spcm->stream[substream->stream].period_elapsed_work,
> -                 sof_pcm_period_elapsed_work);
>
>         caps = &spcm->pcm.caps[substream->stream];
>
> diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
> index 9f4f886..16ee748 100644
> --- a/sound/soc/sof/topology.c
> +++ b/sound/soc/sof/topology.c
> @@ -2459,6 +2459,11 @@ static int sof_dai_load(struct snd_soc_component
> *scomp, int index,
>         spcm->stream[SNDRV_PCM_STREAM_PLAYBACK].comp_id =
> COMP_ID_UNASSIGNED;
>         spcm->stream[SNDRV_PCM_STREAM_CAPTURE].comp_id =
> COMP_ID_UNASSIGNED;
>
> +
>  INIT_WORK(&spcm->stream[SNDRV_PCM_STREAM_PLAYBACK].period_elapsed_work,
> +                 sof_pcm_period_elapsed_work);
> +
>  INIT_WORK(&spcm->stream[SNDRV_PCM_STREAM_CAPTURE].period_elapsed_work,
> +                 sof_pcm_period_elapsed_work);
>
Hi Guennadi,
Maybe it's better to use the newly introduced for_each_pcm_streams() macro
here?
Thanks,
Ranjani


More information about the Alsa-devel mailing list