Skip to contentSkip to conversation

ASoC: SOF: DSP core count handling updates

PATCH In review Peter Ujfalusi 2 participants 4 messages May 20 – May 22

Subsystems (3)
lore
Share & tools
lore

Peter Ujfalusi

author maintainer
#0 lore raw

cover ASoC: SOF: DSP core count handling updates

Hi,

The series address developer facing issues regarding to how the DSP core count is handled:
IPC4 code ignored the DISABLE_MULTICORE flag, fixed by the first patch. The second patch does a validation of the core index from topology against the number of DSP cores available on the booted device, which makes generic development topologies usable among different DSP variants without failure.

Regards,
Peter
---
Peter Ujfalusi (2):
ASoC: SOF: ipc4-topology: Handle SOF_DBG_DISABLE_MULTICORE flag for
pipelines
ASoC: SOF: Validate and correct the core id against the number of
cores of the DSP

 sound/soc/sof/ipc3-topology.c | 10 +++++++++-
 sound/soc/sof/ipc4-topology.c | 11 +++++++++++
 sound/soc/sof/topology.c      |  9 ++++++++-
 3 files changed, 28 insertions(+), 2 deletions(-)
Signature · 1 line
2.54.0
author maintainer
#1 lore raw

PATCH 1/2 ASoC: SOF: ipc4-topology: Handle SOF_DBG_DISABLE_MULTICORE flag for pipelines

SOF_DBG_DISABLE_MULTICORE is handled for swidgets in topology.c but the pipeline's core is not changed to primary core if the flag is set.

Check the flag and if it is set, force the pipeline core to primary core.

---
 sound/soc/sof/ipc4-topology.c | 3 +++
 1 file changed, 3 insertions(+)
sound/soc/sof/ipc4-topology.c +3 -0
index 76812d8fb567..94851ad809fc 100644
@@ -942,6 +942,9 @@ static int sof_ipc4_widget_setup_comp_pipeline(struct snd_sof_widget *swidget)
 		goto err;
 	}
 
+	if (sof_debug_check_flag(SOF_DBG_DISABLE_MULTICORE))
+		pipeline->core_id = SOF_DSP_PRIMARY_CORE;
+
 	swidget->core = pipeline->core_id;
 	spipe->core_mask |= BIT(pipeline->core_id);
 	if (pipeline->direction_valid) {
Signature · 1 line
2.54.0
author maintainer
#2 lore raw

PATCH 2/2 ASoC: SOF: Validate and correct the core id against the number of cores of the DSP

In reply to Peter Ujfalusi

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.

---
 sound/soc/sof/ipc3-topology.c | 10 +++++++++-
 sound/soc/sof/ipc4-topology.c | 10 +++++++++-
 sound/soc/sof/topology.c      |  9 ++++++++-
 3 files changed, 26 insertions(+), 3 deletions(-)
sound/soc/sof/ipc3-topology.c +9 -1
index 8006777f2f64..4e066bbded91 100644
@@ -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 =
sound/soc/sof/ipc4-topology.c +9 -1
index 94851ad809fc..e32cf4dee091 100644
@@ -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);
sound/soc/sof/topology.c +8 -1
index 87b539916b4a..8fc7726aec29 100644
@@ -1574,8 +1574,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 */
Signature · 1 line
2.54.0
maintainer
#3 lore raw
In reply to Peter Ujfalusi
Quoted 12 lines · Peter Ujfalusi

ASoC: SOF: DSP core count handling updates

Hi,

The series address developer facing issues regarding to how the DSP core count is handled:
IPC4 code ignored the DISABLE_MULTICORE flag, fixed by the first patch. The second patch does a validation of the core index from topology against the number of DSP cores available on the booted device, which makes generic development topologies usable among different DSP variants without failure.

Quoted 1 line

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2

Thanks!

[1/2] ASoC: SOF: ipc4-topology: Handle SOF_DBG_DISABLE_MULTICORE flag for pipelines

      https://git.kernel.org/broonie/sound/c/3d1b78a6119f
[2/2] ASoC: SOF: Validate and correct the core id against the number of cores of the DSP
      https://git.kernel.org/broonie/sound/c/d9265a36f4be

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark