Skip to content

Commit 1c47651

Browse files
committed
ASoC: SOF: Validate and correct the core id against the number of cores of the DSP
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>
1 parent d4960d0 commit 1c47651

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

sound/soc/sof/ipc3-topology.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ static int sof_ipc3_widget_setup_comp_mixer(struct snd_sof_widget *swidget)
519519
static int sof_ipc3_widget_setup_comp_pipeline(struct snd_sof_widget *swidget)
520520
{
521521
struct snd_soc_component *scomp = swidget->scomp;
522+
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
522523
struct snd_sof_pipeline *spipe = swidget->spipe;
523524
struct sof_ipc_pipe_new *pipeline;
524525
struct snd_sof_widget *comp_swidget;
@@ -559,8 +560,15 @@ static int sof_ipc3_widget_setup_comp_pipeline(struct snd_sof_widget *swidget)
559560
if (ret < 0)
560561
goto err;
561562

562-
if (sof_debug_check_flag(SOF_DBG_DISABLE_MULTICORE))
563+
if (sof_debug_check_flag(SOF_DBG_DISABLE_MULTICORE)) {
564+
pipeline->core = SOF_DSP_PRIMARY_CORE;
565+
} else if (pipeline->core > sdev->num_cores - 1) {
566+
dev_info(scomp->dev,
567+
"out of range core id for %s, moving it %d -> %d\n",
568+
swidget->widget->name, pipeline->core,
569+
SOF_DSP_PRIMARY_CORE);
563570
pipeline->core = SOF_DSP_PRIMARY_CORE;
571+
}
564572

565573
if (sof_debug_check_flag(SOF_DBG_DYNAMIC_PIPELINES_OVERRIDE))
566574
swidget->dynamic_pipeline_widget =

sound/soc/sof/ipc4-topology.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,7 @@ static void sof_ipc4_widget_free_comp_dai(struct snd_sof_widget *swidget)
922922
static int sof_ipc4_widget_setup_comp_pipeline(struct snd_sof_widget *swidget)
923923
{
924924
struct snd_soc_component *scomp = swidget->scomp;
925+
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
925926
struct sof_ipc4_pipeline *pipeline;
926927
struct snd_sof_pipeline *spipe = swidget->spipe;
927928
int ret;
@@ -937,8 +938,15 @@ static int sof_ipc4_widget_setup_comp_pipeline(struct snd_sof_widget *swidget)
937938
goto err;
938939
}
939940

940-
if (sof_debug_check_flag(SOF_DBG_DISABLE_MULTICORE))
941+
if (sof_debug_check_flag(SOF_DBG_DISABLE_MULTICORE)) {
942+
pipeline->core_id = SOF_DSP_PRIMARY_CORE;
943+
} else if (pipeline->core_id > sdev->num_cores - 1) {
944+
dev_info(scomp->dev,
945+
"out of range core id for %s, moving it %d -> %d\n",
946+
swidget->widget->name, pipeline->core_id,
947+
SOF_DSP_PRIMARY_CORE);
941948
pipeline->core_id = SOF_DSP_PRIMARY_CORE;
949+
}
942950

943951
swidget->core = pipeline->core_id;
944952
spipe->core_mask |= BIT(pipeline->core_id);

sound/soc/sof/topology.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,8 +1565,15 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
15651565
int core = sof_get_token_value(SOF_TKN_COMP_CORE_ID, swidget->tuples,
15661566
swidget->num_tuples);
15671567

1568-
if (core >= 0)
1568+
if (core >= 0) {
1569+
if (core > sdev->num_cores - 1) {
1570+
dev_info(scomp->dev,
1571+
"out of range core id for %s, moving it %d -> %d\n",
1572+
swidget->widget->name, core, SOF_DSP_PRIMARY_CORE);
1573+
core = SOF_DSP_PRIMARY_CORE;
1574+
}
15691575
swidget->core = core;
1576+
}
15701577
}
15711578

15721579
/* bind widget to external event */

0 commit comments

Comments
 (0)