]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ASoC: SOF: fix uninitialised "work" with VirtIO
authorGuennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Wed, 25 Mar 2020 21:12:31 +0000 (16:12 -0500)
committerMark Brown <broonie@kernel.org>
Thu, 26 Mar 2020 18:31:14 +0000 (18:31 +0000)
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@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20200325211233.27394-4-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/pcm.c
sound/soc/sof/sof-audio.h
sound/soc/sof/topology.c

index f4769e19965a55f4be47ca0992fdc3b1fa75dcc3..47cd741f2a8c74eacb91dfc27b7b923d6022c143 100644 (file)
@@ -57,7 +57,7 @@ static int sof_pcm_dsp_params(struct snd_sof_pcm *spcm, struct snd_pcm_substream
 /*
  * sof pcm period elapse work
  */
-static void sof_pcm_period_elapsed_work(struct work_struct *work)
+void snd_sof_pcm_period_elapsed_work(struct work_struct *work)
 {
        struct snd_sof_pcm_stream *sps =
                container_of(work, struct snd_sof_pcm_stream,
@@ -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];
 
index eacd10e4da11a3b485ce0148fe6609c355a4ffb6..bf65f31af85821b8dee165da8380ee3d4d76077f 100644 (file)
@@ -11,6 +11,8 @@
 #ifndef __SOUND_SOC_SOF_AUDIO_H
 #define __SOUND_SOC_SOF_AUDIO_H
 
+#include <linux/workqueue.h>
+
 #include <sound/soc.h>
 #include <sound/control.h>
 #include <sound/sof/stream.h> /* needs to be included before control.h */
@@ -189,6 +191,7 @@ struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_soc_component *scomp,
 struct snd_sof_pcm *snd_sof_find_spcm_pcm_id(struct snd_soc_component *scomp,
                                             unsigned int pcm_id);
 void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream);
+void snd_sof_pcm_period_elapsed_work(struct work_struct *work);
 
 /*
  * Mixer IPC
index 54437caf9488ccd9c5cf037be27a4c3f0fb8a15e..fe8ba3e05e08bd5a351702114d6ae2cb53ddcfb0 100644 (file)
@@ -9,6 +9,7 @@
 //
 
 #include <linux/firmware.h>
+#include <linux/workqueue.h>
 #include <sound/tlv.h>
 #include <sound/pcm_params.h>
 #include <uapi/sound/sof/tokens.h>
@@ -2461,8 +2462,11 @@ static int sof_dai_load(struct snd_soc_component *scomp, int index,
 
        spcm->scomp = scomp;
 
-       for_each_pcm_streams(stream)
+       for_each_pcm_streams(stream) {
                spcm->stream[stream].comp_id = COMP_ID_UNASSIGNED;
+               INIT_WORK(&spcm->stream[stream].period_elapsed_work,
+                         snd_sof_pcm_period_elapsed_work);
+       }
 
        spcm->pcm = *pcm;
        dev_dbg(scomp->dev, "tplg: load pcm %s\n", pcm->dai_name);