]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: SOF: Validate and correct the core id against the number of cores of the DSP
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Wed, 20 May 2026 13:55:14 +0000 (16:55 +0300)
committerMark Brown <broonie@kernel.org>
Thu, 21 May 2026 10:25:22 +0000 (11:25 +0100)
Generic development topologies can reference core id outside of the range
of the number of DSP cores the device might have.
Product families have different number of cores, for example:
Intel TGL has 4, TGL-H has 2, ADL has 4, ADL-S has 2, etc
The development topologies are tuned for the higher end devices and in this
case they will fail on DSP with less number of cores.

Override the out of range core id from topology to primary core and inform
the user about it.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Liam Girdwood <liam.r.girdwood@intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://patch.msgid.link/20260520135514.32720-3-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/ipc3-topology.c
sound/soc/sof/ipc4-topology.c
sound/soc/sof/topology.c

index 8006777f2f64fcd0dac70392eae72f40add83d6b..4e066bbded9179a5a55afaa8a5d6df474654bd71 100644 (file)
@@ -519,6 +519,7 @@ static int sof_ipc3_widget_setup_comp_mixer(struct snd_sof_widget *swidget)
 static int sof_ipc3_widget_setup_comp_pipeline(struct snd_sof_widget *swidget)
 {
        struct snd_soc_component *scomp = swidget->scomp;
+       struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
        struct snd_sof_pipeline *spipe = swidget->spipe;
        struct sof_ipc_pipe_new *pipeline;
        struct snd_sof_widget *comp_swidget;
@@ -559,8 +560,15 @@ static int sof_ipc3_widget_setup_comp_pipeline(struct snd_sof_widget *swidget)
        if (ret < 0)
                goto err;
 
-       if (sof_debug_check_flag(SOF_DBG_DISABLE_MULTICORE))
+       if (sof_debug_check_flag(SOF_DBG_DISABLE_MULTICORE)) {
+               pipeline->core = SOF_DSP_PRIMARY_CORE;
+       } else if (pipeline->core > sdev->num_cores - 1) {
+               dev_info(scomp->dev,
+                        "out of range core id for %s, moving it %d -> %d\n",
+                        swidget->widget->name, pipeline->core,
+                        SOF_DSP_PRIMARY_CORE);
                pipeline->core = SOF_DSP_PRIMARY_CORE;
+       }
 
        if (sof_debug_check_flag(SOF_DBG_DYNAMIC_PIPELINES_OVERRIDE))
                swidget->dynamic_pipeline_widget =
index 94851ad809fc55ce951ba3c26d9ac9edbafedb26..e32cf4dee091d25cd9b7d2b14ef0ecdffe33bf55 100644 (file)
@@ -927,6 +927,7 @@ static void sof_ipc4_widget_free_comp_dai(struct snd_sof_widget *swidget)
 static int sof_ipc4_widget_setup_comp_pipeline(struct snd_sof_widget *swidget)
 {
        struct snd_soc_component *scomp = swidget->scomp;
+       struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
        struct sof_ipc4_pipeline *pipeline;
        struct snd_sof_pipeline *spipe = swidget->spipe;
        int ret;
@@ -942,8 +943,15 @@ static int sof_ipc4_widget_setup_comp_pipeline(struct snd_sof_widget *swidget)
                goto err;
        }
 
-       if (sof_debug_check_flag(SOF_DBG_DISABLE_MULTICORE))
+       if (sof_debug_check_flag(SOF_DBG_DISABLE_MULTICORE)) {
+               pipeline->core_id = SOF_DSP_PRIMARY_CORE;
+       } else if (pipeline->core_id > sdev->num_cores - 1) {
+               dev_info(scomp->dev,
+                        "out of range core id for %s, moving it %d -> %d\n",
+                        swidget->widget->name, pipeline->core_id,
+                        SOF_DSP_PRIMARY_CORE);
                pipeline->core_id = SOF_DSP_PRIMARY_CORE;
+       }
 
        swidget->core = pipeline->core_id;
        spipe->core_mask |= BIT(pipeline->core_id);
index 63d582c6589154ad6c420311c26d9965d741e50c..86cdf7649262b8785294a6ad58a5c8762ec1e470 100644 (file)
@@ -1567,8 +1567,15 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
                int core = sof_get_token_value(SOF_TKN_COMP_CORE_ID, swidget->tuples,
                                               swidget->num_tuples);
 
-               if (core >= 0)
+               if (core >= 0) {
+                       if (core > sdev->num_cores - 1) {
+                               dev_info(scomp->dev,
+                                        "out of range core id for %s, moving it %d -> %d\n",
+                                        swidget->widget->name, core, SOF_DSP_PRIMARY_CORE);
+                               core = SOF_DSP_PRIMARY_CORE;
+                       }
                        swidget->core = core;
+               }
        }
 
        /* bind widget to external event */