ASoC: SOF: ipc4-topology: No need to unbind routes within a pipeline
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Fri, 27 Jan 2023 12:00:14 +0000 (14:00 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 27 Jan 2023 12:13:58 +0000 (12:13 +0000)
The FW currently ignores unbinding routes if the source and sink widgets
belong to the same pipeline. So no need to send the IPC at all in the
first place.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230127120031.10709-2-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/ipc4-topology.c

index ba99114e86a9162d05ac9c6f08bd0345f8980f9d..ae8ec98bb4eb3a72a8e66b8ceabae62a11e5516e 100644 (file)
@@ -1805,12 +1805,19 @@ static int sof_ipc4_route_free(struct snd_sof_dev *sdev, struct snd_sof_route *s
        struct sof_ipc4_fw_module *sink_fw_module = sink_widget->module_info;
        struct sof_ipc4_msg msg = {{ 0 }};
        u32 header, extension;
-       int ret;
+       int ret = 0;
 
        dev_dbg(sdev->dev, "unbind modules %s:%d -> %s:%d\n",
                src_widget->widget->name, sroute->src_queue_id,
                sink_widget->widget->name, sroute->dst_queue_id);
 
+       /*
+        * routes belonging to the same pipeline will be disconnected by the FW when the pipeline
+        * is freed. So avoid sending this IPC which will be ignored by the FW anyway.
+        */
+       if (src_widget->pipe_widget == sink_widget->pipe_widget)
+               goto out;
+
        header = src_fw_module->man4_module_entry.id;
        header |= SOF_IPC4_MOD_INSTANCE(src_widget->instance_id);
        header |= SOF_IPC4_MSG_TYPE_SET(SOF_IPC4_MOD_UNBIND);
@@ -1829,7 +1836,7 @@ static int sof_ipc4_route_free(struct snd_sof_dev *sdev, struct snd_sof_route *s
        if (ret < 0)
                dev_err(sdev->dev, "failed to unbind modules %s -> %s\n",
                        src_widget->widget->name, sink_widget->widget->name);
-
+out:
        sof_ipc4_put_queue_id(sink_widget, sroute->dst_queue_id, SOF_PIN_TYPE_SINK);
        sof_ipc4_put_queue_id(src_widget, sroute->src_queue_id, SOF_PIN_TYPE_SOURCE);