Message ID | 20200312144429.17959-9-guennadi.liakhovetski@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ASoC: SOF DSP virtualisation | expand |
On Thu, Mar 12, 2020 at 03:44:23PM +0100, Guennadi Liakhovetski 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. This is good practice in general, independently of anything you're doing with VirtIO - it makes it harder to introduce bugs. I'd split this out and send it separately.
On Thu, Mar 12, 2020 at 7:51 AM Guennadi Liakhovetski < guennadi.liakhovetski@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@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
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); + spcm->pcm = *pcm; dev_dbg(scomp->dev, "tplg: load pcm %s\n", pcm->dai_name);
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> --- sound/soc/sof/pcm.c | 2 -- sound/soc/sof/topology.c | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-)