Commit 73ea6609 authored by Ranjani Sridharan's avatar Ranjani Sridharan Committed by Mark Brown

ASoC: SOF: sof-audio: Set up/free DAI/AIF widgets only once

Calling the sof_widget_setup/free() for the DAI/AIF widgets inside the
snd_soc_dapm_widget_for_each_sink_path() loop will end up setting up or
freeing the widget multiple times if there are multiple paths leaving
the widget. Fix this by moving the widget setup/free for the starting
widget in each path outside the loop.
Signed-off-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarPéter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230127120031.10709-4-peter.ujfalusi@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 5edcf2a3
...@@ -357,19 +357,16 @@ static int sof_free_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dap ...@@ -357,19 +357,16 @@ static int sof_free_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dap
int err; int err;
int ret = 0; int ret = 0;
/* free all widgets even in case of error to keep use counts balanced */ if (widget->dobj.private) {
snd_soc_dapm_widget_for_each_sink_path(widget, p) {
if (!p->walking && p->sink->dobj.private && widget->dobj.private) {
p->walking = true;
if (WIDGET_IS_AIF_OR_DAI(widget->id)) {
err = sof_widget_free(sdev, widget->dobj.private); err = sof_widget_free(sdev, widget->dobj.private);
if (err < 0) if (err < 0)
ret = err; ret = err;
} }
err = sof_widget_free(sdev, p->sink->dobj.private); /* free all widgets in the sink paths even in case of error to keep use counts balanced */
if (err < 0) snd_soc_dapm_widget_for_each_sink_path(widget, p) {
ret = err; if (!p->walking) {
p->walking = true;
err = sof_free_widgets_in_path(sdev, p->sink, dir); err = sof_free_widgets_in_path(sdev, p->sink, dir);
if (err < 0) if (err < 0)
...@@ -392,34 +389,25 @@ static int sof_set_up_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_d ...@@ -392,34 +389,25 @@ static int sof_set_up_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_d
struct snd_soc_dapm_path *p; struct snd_soc_dapm_path *p;
int ret; int ret;
snd_soc_dapm_widget_for_each_sink_path(widget, p) { if (widget->dobj.private) {
if (!p->walking && p->sink->dobj.private && widget->dobj.private) {
p->walking = true;
if (WIDGET_IS_AIF_OR_DAI(widget->id)) {
ret = sof_widget_setup(sdev, widget->dobj.private); ret = sof_widget_setup(sdev, widget->dobj.private);
if (ret < 0) if (ret < 0)
goto out; return ret;
} }
ret = sof_widget_setup(sdev, p->sink->dobj.private); snd_soc_dapm_widget_for_each_sink_path(widget, p) {
if (ret < 0) { if (!p->walking) {
if (WIDGET_IS_AIF_OR_DAI(widget->id)) p->walking = true;
sof_widget_free(sdev, widget->dobj.private);
goto out;
}
ret = sof_set_up_widgets_in_path(sdev, p->sink, dir); ret = sof_set_up_widgets_in_path(sdev, p->sink, dir);
p->walking = false;
if (ret < 0) { if (ret < 0) {
if (WIDGET_IS_AIF_OR_DAI(widget->id)) if (widget->dobj.private)
sof_widget_free(sdev, widget->dobj.private); sof_widget_free(sdev, widget->dobj.private);
sof_widget_free(sdev, p->sink->dobj.private);
}
out:
p->walking = false;
if (ret < 0)
return ret; return ret;
} }
} }
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment