Skip to contentSkip to conversation

ASoC: SOF: multi core support for 5.10

PATCH In review Kai Vehmanen 2 participants 5 messages Sep 2, 2020 – Sep 4, 2020

Subsystems (3)
lore
Share & tools
lore

Kai Vehmanen

author reviewer
#0 lore raw

cover ASoC: SOF: multi core support for 5.10

This series extends the multi-core support in SOF. Capability to specify which core to use, on a per component basis, is added to topology. The topology load functionality in SOF is modified to power up/down host controlled cores based on the topology description.

Guennadi Liakhovetski (2):
ASoC: SOF: add a "core" parameter to widget loading functions
ASoC: SOF: support topology components on secondary cores

Ranjani Sridharan (1):
ASoC: SOF: topology: fix core enable sequence

 include/uapi/sound/sof/tokens.h |   1 +
 sound/soc/sof/pm.c              |   1 +
 sound/soc/sof/sof-audio.c       |  25 ++++
 sound/soc/sof/sof-audio.h       |   5 +
 sound/soc/sof/sof-priv.h        |   3 +
 sound/soc/sof/topology.c        | 210 ++++++++++++++++++++++----------
 6 files changed, 184 insertions(+), 61 deletions(-)
Signature · 1 line
2.27.0
author reviewer
#1 lore raw

PATCH 1/3 ASoC: SOF: add a "core" parameter to widget loading functions

From: Guennadi Liakhovetski <[email protected]>

We want to be able to explicitly assign cores to individual pipeline components. This patch adds a "core" parameter to widget loading functions to be sent to the DSP for appropriate component scheduling.

---
 sound/soc/sof/sof-priv.h |  3 ++
 sound/soc/sof/topology.c | 74 +++++++++++++++++++++++++---------------
 2 files changed, 50 insertions(+), 27 deletions(-)
sound/soc/sof/sof-priv.h +3 -0
index 53d26be88f64..1c51d99f0459 100644
@@ -54,6 +54,9 @@ extern int sof_core_debug;
 	(IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE) || \
 	 IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST))
 
+/* So far the primary core on all DSPs has ID 0 */
+#define SOF_DSP_PRIMARY_CORE 0
+
 /* DSP power state */
 enum sof_dsp_power_states {
 	SOF_DSP_PM_D0,
sound/soc/sof/topology.c +47 -27

245 lines not on this page · raw message

Signature · 1 line
2.27.0
author reviewer
#2 lore raw

PATCH 2/3 ASoC: SOF: support topology components on secondary cores

In reply to Kai Vehmanen

From: Guennadi Liakhovetski <[email protected]>

Currently SOF supports running pipelines on secondary DSP cores in a limited way. This patch represents the next step in SOF multi-core DSP support, it adds checks for core ID to individual topology components. It takes care to power up all the requested cores. More advanced DSP core power management should be added in the future.

---
 include/uapi/sound/sof/tokens.h |   1 +
 sound/soc/sof/pm.c              |   1 +
 sound/soc/sof/sof-audio.c       |  25 +++++++
 sound/soc/sof/sof-audio.h       |   5 ++
 sound/soc/sof/topology.c        | 128 +++++++++++++++++++++++---------
 5 files changed, 126 insertions(+), 34 deletions(-)
include/uapi/sound/sof/tokens.h +1 -0
index 5941e2eb1588..37f5aaa09c2b 100644
@@ -73,6 +73,7 @@
 /* Token retired with ABI 3.2, do not use for new capabilities
  * #define SOF_TKN_COMP_PRELOAD_COUNT		403
  */
+#define SOF_TKN_COMP_CORE_ID			404
 
 /* SSP */
 #define SOF_TKN_INTEL_SSP_CLKS_CONTROL		500
sound/soc/sof/pm.c +1 -0
index 92e5f9b15f3a..a5f7c7f024a1 100644
@@ -256,6 +256,7 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)
 
 	/* reset FW state */
 	sdev->fw_state = SOF_FW_BOOT_NOT_STARTED;
+	sdev->enabled_cores_mask = 0;
 
 	return ret;
 }
sound/soc/sof/sof-audio.c +25 -0
index 33d84405cf9c..d05f99cd7919 100644
@@ -142,6 +142,22 @@ static int sof_restore_kcontrols(struct device *dev)
 	return 0;
 }
 
+const struct sof_ipc_pipe_new *snd_sof_pipeline_find(struct snd_sof_dev *sdev,
+						     int pipeline_id)
+{
+	const struct snd_sof_widget *swidget;
+
+	list_for_each_entry(swidget, &sdev->widget_list, list)
+		if (swidget->id == snd_soc_dapm_scheduler) {
+			const struct sof_ipc_pipe_new *pipeline =
+				swidget->private;
+			if (pipeline->pipeline_id == pipeline_id)
+				return pipeline;
+		}
+
+	return NULL;
+}
+
 int sof_restore_pipelines(struct device *dev)
 {
 	struct snd_sof_dev *sdev = dev_get_drvdata(dev);
@@ -161,6 +177,15 @@ int sof_restore_pipelines(struct device *dev)
 		if (!swidget->private)
 			continue;
 
+		ret = sof_pipeline_core_enable(sdev, swidget);
+		if (ret < 0) {
+			dev_err(dev,
+				"error: failed to enable target core: %d\n",
+				ret);
+
+			return ret;
+		}
+
 		switch (swidget->id) {
 		case snd_soc_dapm_dai_in:
 		case snd_soc_dapm_dai_out:
sound/soc/sof/sof-audio.h +5 -0
index 9629994fe463..7f8be8817e69 100644
@@ -83,6 +83,7 @@ struct snd_sof_widget {
 	int comp_id;
 	int pipeline_id;
 	int complete;
+	int core;
 	int id;
 
 	struct snd_soc_dapm_widget *widget;
@@ -151,6 +152,8 @@ int snd_sof_complete_pipeline(struct device *dev,
 int sof_load_pipeline_ipc(struct device *dev,
 			  struct sof_ipc_pipe_new *pipeline,
 			  struct sof_ipc_comp_reply *r);
+int sof_pipeline_core_enable(struct snd_sof_dev *sdev,
+			     const struct snd_sof_widget *swidget);
 
 /*
  * Stream IPC
@@ -190,6 +193,8 @@ struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_soc_component *scomp,
 					   int *direction);
 struct snd_sof_pcm *snd_sof_find_spcm_pcm_id(struct snd_soc_component *scomp,
 					     unsigned int pcm_id);
+const struct sof_ipc_pipe_new *snd_sof_pipeline_find(struct snd_sof_dev *sdev,
+						     int pipeline_id);
 void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream);
 void snd_sof_pcm_period_elapsed_work(struct work_struct *work);
 
sound/soc/sof/topology.c +94 -34

162 lines not on this page · raw message

Signature · 1 line
2.27.0
author reviewer
#3 lore raw

PATCH 3/3 ASoC: SOF: topology: fix core enable sequence

In reply to Kai Vehmanen

From: Ranjani Sridharan <[email protected]>

Core power up involves 2 steps: The first step tries to power up the core by setting the ADSPCS.SPA bit for the host-managed cores. The second step involves sending the IPC to power up other cores that are not host managed. The enabled_cores_mask should be updated only when both these steps are successful. If the IPC to the DSP fails, the host-managed core that was powered in step 1 should be powered off before returning the error.

---
 sound/soc/sof/topology.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
sound/soc/sof/topology.c +14 -6
index 46468fb7b6d1..d47da407a1bd 100644
@@ -1303,7 +1303,7 @@ static int sof_core_enable(struct snd_sof_dev *sdev, int core)
 	if (sdev->enabled_cores_mask & BIT(core))
 		return 0;
 
-	/* power up the core */
+	/* power up the core if it is host managed */
 	ret = snd_sof_dsp_core_power_up(sdev, BIT(core));
 	if (ret < 0) {
 		dev_err(sdev->dev, "error: %d powering up core %d\n",
@@ -1311,16 +1311,24 @@ static int sof_core_enable(struct snd_sof_dev *sdev, int core)
 		return ret;
 	}
 
-	/* update enabled cores mask */
-	sdev->enabled_cores_mask |= BIT(core);
-
-	/* Now notify DSP that the core has been powered up */
+	/* Now notify DSP */
 	ret = sof_ipc_tx_message(sdev->ipc, pm_core_config.hdr.cmd,
 				 &pm_core_config, sizeof(pm_core_config),
 				 &pm_core_config, sizeof(pm_core_config));
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(sdev->dev, "error: core %d enable ipc failure %d\n",
 			core, ret);
+		goto err;
+	}
+
+	/* update enabled cores mask */
+	sdev->enabled_cores_mask |= BIT(core);
+
+	return ret;
+err:
+	/* power down core if it is host managed and return the original error if this fails too */
+	if (snd_sof_dsp_core_power_down(sdev, BIT(core)) < 0)
+		dev_err(sdev->dev, "error: powering down core %d\n", core);
 
 	return ret;
 }
Signature · 1 line
2.27.0
maintainer
#4 lore raw
In reply to Kai Vehmanen
Quoted 11 lines · Kai Vehmanen

This series extends the multi-core support in SOF. Capability to specify which core to use, on a per component basis, is added to topology. The topology load functionality in SOF is modified to power up/down host controlled cores based on the topology description.

Guennadi Liakhovetski (2):
ASoC: SOF: add a "core" parameter to widget loading functions
ASoC: SOF: support topology components on secondary cores

[...]

Applied to

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

Thanks!

[1/3] ASoC: SOF: add a "core" parameter to widget loading functions

      commit: 0dcdf84289fbf61cd42cbb1e379e2150aa17e31e
[2/3] ASoC: SOF: support topology components on secondary cores
      commit: d1c6c4a9fd3da5c735386b0cdb44d79667f10a1b
[3/3] ASoC: SOF: topology: fix core enable sequence
      commit: 8c9ff1219aef657954540147522ceaecced71b2b

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