ASoC: SOF: don't unprepare widget used other pipelines
authorRander Wang <rander.wang@intel.com>
Tue, 20 Sep 2022 15:01:07 +0000 (17:01 +0200)
committerMark Brown <broonie@kernel.org>
Tue, 20 Sep 2022 18:07:34 +0000 (19:07 +0100)
If multiple pipeline are mixed into one, we can't unprepare
the widget used by other pipelines. This patch checks use_count
to address this case.

Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Rander Wang <rander.wang@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20220920150107.2090695-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/sof-audio.c

index 71cea83..62092e2 100644 (file)
@@ -271,8 +271,8 @@ sof_unprepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widg
        struct snd_sof_widget *swidget = widget->dobj.private;
        struct snd_soc_dapm_path *p;
 
-       /* it is already unprepared */
-       if (!swidget->prepared)
+       /* return if the widget is in use or if it is already unprepared */
+       if (!swidget->prepared || swidget->use_count > 1)
                return;
 
        if (widget_ops[widget->id].ipc_unprepare)