Skip to content

Commit cc9b22a

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 <[email protected]>
1 parent a34de30 commit cc9b22a

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

sound/soc/sof/ipc3-topology.c

Lines changed: 7 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,13 @@ 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, "out of range core id for %s, moving it %d -> 0\n",
567+
swidget->widget->name, pipeline->core);
563568
pipeline->core = SOF_DSP_PRIMARY_CORE;
569+
}
564570

565571
if (sof_debug_check_flag(SOF_DBG_DYNAMIC_PIPELINES_OVERRIDE))
566572
swidget->dynamic_pipeline_widget =

sound/soc/sof/ipc4-topology.c

Lines changed: 7 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,13 @@ 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, "out of range core id for %s, moving it %d -> 0\n",
945+
swidget->widget->name, pipeline->core_id);
941946
pipeline->core_id = SOF_DSP_PRIMARY_CORE;
947+
}
942948

943949
swidget->core = pipeline->core_id;
944950
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 -> 0\n",
1572+
swidget->widget->name, 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)