Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions sound/soc/sof/sof-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ sof_unprepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widg
const struct sof_ipc_tplg_widget_ops *widget_ops;
struct snd_soc_dapm_path *p;

/* return if the widget is in use or if it is already unprepared */
if (!swidget->prepared || swidget->use_count > 1)
return;
/* skip if the widget is in use or if it is already unprepared */
if (!swidget->prepared || swidget->use_count > 0)
Comment thread
plbossart marked this conversation as resolved.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the use_count go negative?

if (!swidget->prepared || swidget->use_count)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the use_count go negative?

if (!swidget->prepared || swidget->use_count)

Ideally, no. But I do see it is negative when I meet IPC errors. And sof_widget_free() will never work at that time.

goto sink_unprepare;
Comment thread
plbossart marked this conversation as resolved.

widget_ops = tplg_ops ? tplg_ops->widget : NULL;
if (widget_ops && widget_ops[widget->id].ipc_unprepare)
Expand All @@ -320,6 +320,7 @@ sof_unprepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widg

swidget->prepared = false;

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))
Expand Down Expand Up @@ -347,7 +348,7 @@ sof_prepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget

widget_ops = tplg_ops ? tplg_ops->widget : NULL;
if (!widget_ops)
return 0;
goto sink_prepare;

if (!widget_ops[widget->id].ipc_prepare || swidget->prepared)
goto sink_prepare;
Expand Down