Skip to contentSkip to conversation

ASoC: SOF: sof-audio: fix prepare/unprepare

PATCH In review Pierre-Louis Bossart 2 participants 4 messages Sep 20, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ASoC: SOF: sof-audio: fix prepare/unprepare

2 patches from Rander required to enable mixing usages with multiple pipelines.

Rander Wang (2):
ASoC: SOF: clear prepare state when widget is unprepared
ASoC: SOF: don't unprepare widget used other pipelines

 sound/soc/sof/sof-audio.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 ASoC: SOF: clear prepare state when widget is unprepared

From: Rander Wang <[email protected]>

Playback can't work after the first try sometimes. The reason is that some widgets don't have ipc_unprepare ops and driver will jump to sink_prepare so miss to set prepare state to false. Next time these widgets will not be prepared and it will result to error with different format of audio file since the last setting is not applicable.

This patch makes sure that widget prepare state will be cleared to false when it is unprepared.

---
 sound/soc/sof/sof-audio.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
sound/soc/sof/sof-audio.c +7 -5
index a3d3dd7a00375..71cea83889fb0 100644
@@ -271,14 +271,16 @@ 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;
 
-	if (!widget_ops[widget->id].ipc_unprepare || !swidget->prepared)
-		goto sink_unprepare;
+	/* it is already unprepared */
+	if (!swidget->prepared)
+		return;
+
+	if (widget_ops[widget->id].ipc_unprepare)
+		/* unprepare the source widget */
+		widget_ops[widget->id].ipc_unprepare(swidget);
 
-	/* unprepare the source widget */
-	widget_ops[widget->id].ipc_unprepare(swidget);
 	swidget->prepared = false;
 
-sink_unprepare:
 	/* unprepare all widgets in the sink paths */
 	snd_soc_dapm_widget_for_each_sink_path(widget, p) {
 		if (!p->walking && p->sink->dobj.private) {
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/2 ASoC: SOF: don't unprepare widget used other pipelines

In reply to Pierre-Louis Bossart

From: Rander Wang <[email protected]>

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.

---
 sound/soc/sof/sof-audio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sof/sof-audio.c +2 -2
index 71cea83889fb0..62092e2d609c7 100644
@@ -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)
Signature · 1 line
2.34.1
maintainer
#3 lore raw
In reply to Pierre-Louis Bossart
Quoted 8 lines · Pierre-Louis Bossart

2 patches from Rander required to enable mixing usages with multiple pipelines.

Rander Wang (2):
ASoC: SOF: clear prepare state when widget is unprepared
ASoC: SOF: don't unprepare widget used other pipelines

[...]

Applied to

broonie/sound.git for-next

Thanks!

[1/2] ASoC: SOF: clear prepare state when widget is unprepared

      commit: ce59804d26432d7e2c1a8c906245a230a2b4505c
[2/2] ASoC: SOF: don't unprepare widget used other pipelines
      commit: 9862dcf70245c2d03764012b81966d8c2ea95a48

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark