From: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
To: lgirdwood@gmail.com, broonie@kernel.org
Cc: alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com,
pierre-louis.bossart@linux.intel.com, rander.wang@intel.com,
ranjani.sridharan@linux.intel.com,
yung-chuan.liao@linux.intel.com
Subject: [PATCH 04/18] ASoC: SOF: sof-audio: Only process widgets in the connected widget list
Date: Fri, 27 Jan 2023 14:00:17 +0200 [thread overview]
Message-ID: <20230127120031.10709-5-peter.ujfalusi@linux.intel.com> (raw)
In-Reply-To: <20230127120031.10709-1-peter.ujfalusi@linux.intel.com>
From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
When walking the list of the widgets from the source to the sink, we
accidentally also end up preparing/setting up the widgets that are not
in the list of connected DAPM widgets associated with the PCM. Avoid
this by checking if a widget is part of the connected DAPM widget list
during widget prepare, unprepare, setup or free.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
---
sound/soc/sof/sof-audio.c | 51 +++++++++++++++++++++++++++------------
1 file changed, 36 insertions(+), 15 deletions(-)
diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c
index 572ac6a0c9ac..b127b304298c 100644
--- a/sound/soc/sof/sof-audio.c
+++ b/sound/soc/sof/sof-audio.c
@@ -241,24 +241,32 @@ static int sof_setup_pipeline_connections(struct snd_sof_dev *sdev,
if (!widget->dobj.private)
continue;
- snd_soc_dapm_widget_for_each_sink_path(widget, p)
+ snd_soc_dapm_widget_for_each_sink_path(widget, p) {
+ if (!widget_in_list(list, p->sink))
+ continue;
+
if (p->sink->dobj.private) {
ret = sof_route_setup(sdev, widget, p->sink);
if (ret < 0)
return ret;
}
+ }
}
} else {
for_each_dapm_widgets(list, i, widget) {
if (!widget->dobj.private)
continue;
- snd_soc_dapm_widget_for_each_source_path(widget, p)
+ snd_soc_dapm_widget_for_each_source_path(widget, p) {
+ if (!widget_in_list(list, p->source))
+ continue;
+
if (p->source->dobj.private) {
ret = sof_route_setup(sdev, p->source, widget);
if (ret < 0)
return ret;
}
+ }
}
}
@@ -266,7 +274,8 @@ static int sof_setup_pipeline_connections(struct snd_sof_dev *sdev,
}
static void
-sof_unprepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *widget)
+sof_unprepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *widget,
+ struct snd_soc_dapm_widget_list *list)
{
const struct sof_ipc_tplg_ops *tplg_ops = sof_ipc_get_ops(sdev, tplg);
struct snd_sof_widget *swidget = widget->dobj.private;
@@ -287,9 +296,11 @@ sof_unprepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widg
sink_unprepare:
/* unprepare all widgets in the sink paths */
snd_soc_dapm_widget_for_each_sink_path(widget, p) {
+ if (!widget_in_list(list, p->sink))
+ continue;
if (!p->walking && p->sink->dobj.private) {
p->walking = true;
- sof_unprepare_widgets_in_path(sdev, p->sink);
+ sof_unprepare_widgets_in_path(sdev, p->sink, list);
p->walking = false;
}
}
@@ -299,7 +310,8 @@ static int
sof_prepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *widget,
struct snd_pcm_hw_params *fe_params,
struct snd_sof_platform_stream_params *platform_params,
- struct snd_pcm_hw_params *pipeline_params, int dir)
+ struct snd_pcm_hw_params *pipeline_params, int dir,
+ struct snd_soc_dapm_widget_list *list)
{
const struct sof_ipc_tplg_ops *tplg_ops = sof_ipc_get_ops(sdev, tplg);
struct snd_sof_widget *swidget = widget->dobj.private;
@@ -327,10 +339,13 @@ sof_prepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget
sink_prepare:
/* prepare all widgets in the sink paths */
snd_soc_dapm_widget_for_each_sink_path(widget, p) {
+ if (!widget_in_list(list, p->sink))
+ continue;
if (!p->walking && p->sink->dobj.private) {
p->walking = true;
ret = sof_prepare_widgets_in_path(sdev, p->sink, fe_params,
- platform_params, pipeline_params, dir);
+ platform_params, pipeline_params, dir,
+ list);
p->walking = false;
if (ret < 0) {
/* unprepare the source widget */
@@ -352,7 +367,7 @@ sof_prepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget
* (DAI type for capture, AIF type for playback)
*/
static int sof_free_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *widget,
- int dir)
+ int dir, struct snd_soc_dapm_widget_list *list)
{
struct snd_soc_dapm_path *p;
int err;
@@ -367,9 +382,12 @@ static int sof_free_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dap
/* free all widgets in the sink paths even in case of error to keep use counts balanced */
snd_soc_dapm_widget_for_each_sink_path(widget, p) {
if (!p->walking) {
+ if (!widget_in_list(list, p->sink))
+ continue;
+
p->walking = true;
- err = sof_free_widgets_in_path(sdev, p->sink, dir);
+ err = sof_free_widgets_in_path(sdev, p->sink, dir, list);
if (err < 0)
ret = err;
p->walking = false;
@@ -385,7 +403,7 @@ static int sof_free_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dap
* The error path in this function ensures that all successfully set up widgets getting freed.
*/
static int sof_set_up_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *widget,
- int dir)
+ int dir, struct snd_soc_dapm_widget_list *list)
{
struct snd_soc_dapm_path *p;
int ret;
@@ -398,9 +416,12 @@ static int sof_set_up_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_d
snd_soc_dapm_widget_for_each_sink_path(widget, p) {
if (!p->walking) {
+ if (!widget_in_list(list, p->sink))
+ continue;
+
p->walking = true;
- ret = sof_set_up_widgets_in_path(sdev, p->sink, dir);
+ ret = sof_set_up_widgets_in_path(sdev, p->sink, dir, list);
p->walking = false;
if (ret < 0) {
if (widget->dobj.private)
@@ -435,11 +456,11 @@ sof_walk_widgets_in_order(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget_l
switch (op) {
case SOF_WIDGET_SETUP:
- ret = sof_set_up_widgets_in_path(sdev, widget, dir);
+ ret = sof_set_up_widgets_in_path(sdev, widget, dir, list);
str = "set up";
break;
case SOF_WIDGET_FREE:
- ret = sof_free_widgets_in_path(sdev, widget, dir);
+ ret = sof_free_widgets_in_path(sdev, widget, dir, list);
str = "free";
break;
case SOF_WIDGET_PREPARE:
@@ -455,12 +476,12 @@ sof_walk_widgets_in_order(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget_l
*/
memcpy(&pipeline_params, fe_params, sizeof(*fe_params));
- ret = sof_prepare_widgets_in_path(sdev, widget, fe_params,
- platform_params, &pipeline_params, dir);
+ ret = sof_prepare_widgets_in_path(sdev, widget, fe_params, platform_params,
+ &pipeline_params, dir, list);
break;
}
case SOF_WIDGET_UNPREPARE:
- sof_unprepare_widgets_in_path(sdev, widget);
+ sof_unprepare_widgets_in_path(sdev, widget, list);
break;
default:
dev_err(sdev->dev, "Invalid widget op %d\n", op);
--
2.39.1
next prev parent reply other threads:[~2023-01-27 12:02 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-27 12:00 From 644473b181f0f310e428301a2ed459f912eec7ea Mon Sep 17 00:00:00 2001 Peter Ujfalusi
2023-01-27 12:00 ` [PATCH 01/18] ASoC: SOF: ipc4-topology: No need to unbind routes within a pipeline Peter Ujfalusi
2023-01-27 12:00 ` [PATCH 02/18] ASoC: soc-pcm: Export widget_in_list() Peter Ujfalusi
2023-01-27 12:00 ` [PATCH 03/18] ASoC: SOF: sof-audio: Set up/free DAI/AIF widgets only once Peter Ujfalusi
2023-01-27 12:00 ` Peter Ujfalusi [this message]
2023-01-27 12:00 ` [PATCH 05/18] ASoC: SOF: pcm: do not free widgets during suspend trigger Peter Ujfalusi
2023-01-27 12:00 ` [PATCH 06/18] ASoC: SOF: topology: Set IPC-specific trigger order for DAI links Peter Ujfalusi
2023-01-27 12:00 ` [PATCH 07/18] ASoC: SOF: Introduce PCM setup/free PCM IPC ops Peter Ujfalusi
2023-01-27 12:00 ` [PATCH 08/18] ASoC: SOF: ipc4-pcm: Define pcm_setup/free ops Peter Ujfalusi
2023-01-27 12:00 ` [PATCH 09/18] ASoC: SOF: ipc4: Add flag to skip triggering pipelines during FE DAI trigger Peter Ujfalusi
2023-01-27 12:00 ` [PATCH 10/18] ASoC: SOF: sof-audio: Populate the PCM stream pipeline_info Peter Ujfalusi
2023-01-27 12:00 ` [PATCH 11/18] ASoC: SOF: ipc4-pcm: Use the PCM stream's pipeline_info during trigger Peter Ujfalusi
2023-01-27 12:00 ` [PATCH 12/18] ASoC: SOF: Introduce struct snd_sof_pipeline Peter Ujfalusi
2023-01-27 12:00 ` [PATCH 13/18] ASoC: SOF: ipc4-pcm: Rename 'data' variable to trigger_list Peter Ujfalusi
2023-01-27 12:00 ` [PATCH 14/18] ASoC: SOF: ipc4-pcm: Implement pipeline trigger reference counting Peter Ujfalusi
2023-01-27 12:00 ` [PATCH 15/18] ASoC: SOF: ipc4-topology: Protect pipeline free with mutex Peter Ujfalusi
2023-01-27 12:00 ` [PATCH 16/18] ASoC: SOF: Avoid double decrementing use_count in sof_widget_setup on error Peter Ujfalusi
2023-01-27 12:00 ` [PATCH 17/18] ASoC: SOF: Protect swidget->use_count with mutex for kcontrol access race Peter Ujfalusi
2023-01-27 12:00 ` [PATCH 18/18] ASoC: SOF: ipc4-pcm: Do not run the trigger pipelines if no spipe is stored Peter Ujfalusi
2023-01-27 12:07 ` [PATCH 00/18] ASoC: SOF: ipc4: Multi-stream playback and capture support Péter Ujfalusi
2023-01-28 10:48 ` From 644473b181f0f310e428301a2ed459f912eec7ea Mon Sep 17 00:00:00 2001 Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230127120031.10709-5-peter.ujfalusi@linux.intel.com \
--to=peter.ujfalusi@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=rander.wang@intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox