Skip to content

Commit aab109f

Browse files
ranj063plbossart
authored andcommitted
ASoC: SOF: ipc4-topology: Protect pipeline free with mutex
When starting/stopping multiple streams in parallel, pipeline triggers and pipeline frees can get interleaved. So use the same mutex used for pipeline trigger to protect the pipeline frees as well. Rename the trigger_mutex to pipeline_state_mutex for more clarity. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent e5af536 commit aab109f

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

sound/soc/sof/ipc4-pcm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
222222
if (!trigger_list)
223223
return -ENOMEM;
224224

225-
mutex_lock(&ipc4_data->trigger_mutex);
225+
mutex_lock(&ipc4_data->pipeline_state_mutex);
226226

227227
/*
228228
* IPC4 requires pipelines to be triggered in order starting at the sink and
@@ -289,7 +289,7 @@ static int sof_ipc4_trigger_pipelines(struct snd_soc_component *component,
289289
}
290290

291291
free:
292-
mutex_unlock(&ipc4_data->trigger_mutex);
292+
mutex_unlock(&ipc4_data->pipeline_state_mutex);
293293
kfree(trigger_list);
294294
return ret;
295295
}

sound/soc/sof/ipc4-priv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct sof_ipc4_fw_library {
7070
* base firmware
7171
*
7272
* @load_library: Callback function for platform dependent library loading
73-
* @trigger_mutex: Mutex to protect pipeline triggers, ref counts and states
73+
* @pipeline_state_mutex: Mutex to protect pipeline triggers, ref counts, states and deletion
7474
*/
7575
struct sof_ipc4_fw_data {
7676
u32 manifest_fw_hdr_offset;
@@ -83,7 +83,7 @@ struct sof_ipc4_fw_data {
8383

8484
int (*load_library)(struct snd_sof_dev *sdev,
8585
struct sof_ipc4_fw_library *fw_lib, bool reload);
86-
struct mutex trigger_mutex; /* protect pipeline triggers, ref counts and states */
86+
struct mutex pipeline_state_mutex; /* protect pipeline triggers, ref counts and states */
8787
};
8888

8989
extern const struct sof_ipc_fw_loader_ops ipc4_loader_ops;

sound/soc/sof/ipc4-topology.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,8 +1794,11 @@ static int sof_ipc4_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget
17941794
static int sof_ipc4_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)
17951795
{
17961796
struct sof_ipc4_fw_module *fw_module = swidget->module_info;
1797+
struct sof_ipc4_fw_data *ipc4_data = sdev->private;
17971798
int ret = 0;
17981799

1800+
mutex_lock(&ipc4_data->pipeline_state_mutex);
1801+
17991802
/* freeing a pipeline frees all the widgets associated with it */
18001803
if (swidget->id == snd_soc_dapm_scheduler) {
18011804
struct sof_ipc4_pipeline *pipeline = swidget->private;
@@ -1821,6 +1824,8 @@ static int sof_ipc4_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget
18211824
ida_free(&fw_module->m_ida, swidget->instance_id);
18221825
}
18231826

1827+
mutex_unlock(&ipc4_data->pipeline_state_mutex);
1828+
18241829
return ret;
18251830
}
18261831

sound/soc/sof/ipc4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ static int sof_ipc4_init(struct snd_sof_dev *sdev)
662662
{
663663
struct sof_ipc4_fw_data *ipc4_data = sdev->private;
664664

665-
mutex_init(&ipc4_data->trigger_mutex);
665+
mutex_init(&ipc4_data->pipeline_state_mutex);
666666

667667
xa_init_flags(&ipc4_data->fw_lib_xa, XA_FLAGS_ALLOC);
668668

0 commit comments

Comments
 (0)