* [PATCH 0/3] ASoC: SOF: multi core support for 5.10
@ 2020-09-02 14:07 Kai Vehmanen
2020-09-02 14:07 ` [PATCH 1/3] ASoC: SOF: add a "core" parameter to widget loading functions Kai Vehmanen
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Kai Vehmanen @ 2020-09-02 14:07 UTC (permalink / raw)
To: alsa-devel, broonie
Cc: daniel.baluta, pierre-louis.bossart, kai.vehmanen,
ranjani.sridharan
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(-)
--
2.27.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] ASoC: SOF: add a "core" parameter to widget loading functions
2020-09-02 14:07 [PATCH 0/3] ASoC: SOF: multi core support for 5.10 Kai Vehmanen
@ 2020-09-02 14:07 ` Kai Vehmanen
2020-09-02 14:07 ` [PATCH 2/3] ASoC: SOF: support topology components on secondary cores Kai Vehmanen
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Kai Vehmanen @ 2020-09-02 14:07 UTC (permalink / raw)
To: alsa-devel, broonie
Cc: Guennadi Liakhovetski, daniel.baluta, pierre-louis.bossart,
kai.vehmanen, ranjani.sridharan
From: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
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.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
---
sound/soc/sof/sof-priv.h | 3 ++
sound/soc/sof/topology.c | 74 +++++++++++++++++++++++++---------------
2 files changed, 50 insertions(+), 27 deletions(-)
diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h
index 53d26be88f64..1c51d99f0459 100644
--- a/sound/soc/sof/sof-priv.h
+++ b/sound/soc/sof/sof-priv.h
@@ -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,
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 95e63d138326..d41df9337328 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -1360,7 +1360,7 @@ static int sof_connect_dai_widget(struct snd_soc_component *scomp,
}
static int sof_widget_load_dai(struct snd_soc_component *scomp, int index,
- struct snd_sof_widget *swidget,
+ struct snd_sof_widget *swidget, int core,
struct snd_soc_tplg_dapm_widget *tw,
struct sof_ipc_comp_reply *r,
struct snd_sof_dai *dai)
@@ -1377,6 +1377,7 @@ static int sof_widget_load_dai(struct snd_soc_component *scomp, int index,
comp_dai.comp.id = swidget->comp_id;
comp_dai.comp.type = SOF_COMP_DAI;
comp_dai.comp.pipeline_id = index;
+ comp_dai.comp.core = core;
comp_dai.config.hdr.size = sizeof(comp_dai.config);
ret = sof_parse_tokens(scomp, &comp_dai, dai_tokens,
@@ -1417,7 +1418,7 @@ static int sof_widget_load_dai(struct snd_soc_component *scomp, int index,
*/
static int sof_widget_load_buffer(struct snd_soc_component *scomp, int index,
- struct snd_sof_widget *swidget,
+ struct snd_sof_widget *swidget, int core,
struct snd_soc_tplg_dapm_widget *tw,
struct sof_ipc_comp_reply *r)
{
@@ -1436,6 +1437,7 @@ static int sof_widget_load_buffer(struct snd_soc_component *scomp, int index,
buffer->comp.id = swidget->comp_id;
buffer->comp.type = SOF_COMP_BUFFER;
buffer->comp.pipeline_id = index;
+ buffer->comp.core = core;
ret = sof_parse_tokens(scomp, buffer, buffer_tokens,
ARRAY_SIZE(buffer_tokens), private->array,
@@ -1487,7 +1489,7 @@ static int spcm_bind(struct snd_soc_component *scomp, struct snd_sof_pcm *spcm,
*/
static int sof_widget_load_pcm(struct snd_soc_component *scomp, int index,
- struct snd_sof_widget *swidget,
+ struct snd_sof_widget *swidget, int core,
enum sof_ipc_stream_direction dir,
struct snd_soc_tplg_dapm_widget *tw,
struct sof_ipc_comp_reply *r)
@@ -1507,6 +1509,7 @@ static int sof_widget_load_pcm(struct snd_soc_component *scomp, int index,
host->comp.id = swidget->comp_id;
host->comp.type = SOF_COMP_HOST;
host->comp.pipeline_id = index;
+ host->comp.core = core;
host->direction = dir;
host->config.hdr.size = sizeof(host->config);
@@ -1592,8 +1595,8 @@ int sof_load_pipeline_ipc(struct device *dev,
return ret;
}
-static int sof_widget_load_pipeline(struct snd_soc_component *scomp,
- int index, struct snd_sof_widget *swidget,
+static int sof_widget_load_pipeline(struct snd_soc_component *scomp, int index,
+ struct snd_sof_widget *swidget,
struct snd_soc_tplg_dapm_widget *tw,
struct sof_ipc_comp_reply *r)
{
@@ -1655,7 +1658,7 @@ static int sof_widget_load_pipeline(struct snd_soc_component *scomp,
*/
static int sof_widget_load_mixer(struct snd_soc_component *scomp, int index,
- struct snd_sof_widget *swidget,
+ struct snd_sof_widget *swidget, int core,
struct snd_soc_tplg_dapm_widget *tw,
struct sof_ipc_comp_reply *r)
{
@@ -1674,6 +1677,7 @@ static int sof_widget_load_mixer(struct snd_soc_component *scomp, int index,
mixer->comp.id = swidget->comp_id;
mixer->comp.type = SOF_COMP_MIXER;
mixer->comp.pipeline_id = index;
+ mixer->comp.core = core;
mixer->config.hdr.size = sizeof(mixer->config);
ret = sof_parse_tokens(scomp, &mixer->config, comp_tokens,
@@ -1702,7 +1706,7 @@ static int sof_widget_load_mixer(struct snd_soc_component *scomp, int index,
* Mux topology
*/
static int sof_widget_load_mux(struct snd_soc_component *scomp, int index,
- struct snd_sof_widget *swidget,
+ struct snd_sof_widget *swidget, int core,
struct snd_soc_tplg_dapm_widget *tw,
struct sof_ipc_comp_reply *r)
{
@@ -1721,6 +1725,7 @@ static int sof_widget_load_mux(struct snd_soc_component *scomp, int index,
mux->comp.id = swidget->comp_id;
mux->comp.type = SOF_COMP_MUX;
mux->comp.pipeline_id = index;
+ mux->comp.core = core;
mux->config.hdr.size = sizeof(mux->config);
ret = sof_parse_tokens(scomp, &mux->config, comp_tokens,
@@ -1750,7 +1755,7 @@ static int sof_widget_load_mux(struct snd_soc_component *scomp, int index,
*/
static int sof_widget_load_pga(struct snd_soc_component *scomp, int index,
- struct snd_sof_widget *swidget,
+ struct snd_sof_widget *swidget, int core,
struct snd_soc_tplg_dapm_widget *tw,
struct sof_ipc_comp_reply *r)
{
@@ -1779,6 +1784,7 @@ static int sof_widget_load_pga(struct snd_soc_component *scomp, int index,
volume->comp.id = swidget->comp_id;
volume->comp.type = SOF_COMP_VOLUME;
volume->comp.pipeline_id = index;
+ volume->comp.core = core;
volume->config.hdr.size = sizeof(volume->config);
ret = sof_parse_tokens(scomp, volume, volume_tokens,
@@ -1828,7 +1834,7 @@ static int sof_widget_load_pga(struct snd_soc_component *scomp, int index,
*/
static int sof_widget_load_src(struct snd_soc_component *scomp, int index,
- struct snd_sof_widget *swidget,
+ struct snd_sof_widget *swidget, int core,
struct snd_soc_tplg_dapm_widget *tw,
struct sof_ipc_comp_reply *r)
{
@@ -1847,6 +1853,7 @@ static int sof_widget_load_src(struct snd_soc_component *scomp, int index,
src->comp.id = swidget->comp_id;
src->comp.type = SOF_COMP_SRC;
src->comp.pipeline_id = index;
+ src->comp.core = core;
src->config.hdr.size = sizeof(src->config);
ret = sof_parse_tokens(scomp, src, src_tokens,
@@ -1887,7 +1894,7 @@ static int sof_widget_load_src(struct snd_soc_component *scomp, int index,
*/
static int sof_widget_load_asrc(struct snd_soc_component *scomp, int index,
- struct snd_sof_widget *swidget,
+ struct snd_sof_widget *swidget, int core,
struct snd_soc_tplg_dapm_widget *tw,
struct sof_ipc_comp_reply *r)
{
@@ -1906,6 +1913,7 @@ static int sof_widget_load_asrc(struct snd_soc_component *scomp, int index,
asrc->comp.id = swidget->comp_id;
asrc->comp.type = SOF_COMP_ASRC;
asrc->comp.pipeline_id = index;
+ asrc->comp.core = core;
asrc->config.hdr.size = sizeof(asrc->config);
ret = sof_parse_tokens(scomp, asrc, asrc_tokens,
@@ -1948,7 +1956,7 @@ static int sof_widget_load_asrc(struct snd_soc_component *scomp, int index,
*/
static int sof_widget_load_siggen(struct snd_soc_component *scomp, int index,
- struct snd_sof_widget *swidget,
+ struct snd_sof_widget *swidget, int core,
struct snd_soc_tplg_dapm_widget *tw,
struct sof_ipc_comp_reply *r)
{
@@ -1967,6 +1975,7 @@ static int sof_widget_load_siggen(struct snd_soc_component *scomp, int index,
tone->comp.id = swidget->comp_id;
tone->comp.type = SOF_COMP_TONE;
tone->comp.pipeline_id = index;
+ tone->comp.core = core;
tone->config.hdr.size = sizeof(tone->config);
ret = sof_parse_tokens(scomp, tone, tone_tokens,
@@ -2204,7 +2213,7 @@ static int sof_process_load(struct snd_soc_component *scomp, int index,
*/
static int sof_widget_load_process(struct snd_soc_component *scomp, int index,
- struct snd_sof_widget *swidget,
+ struct snd_sof_widget *swidget, int core,
struct snd_soc_tplg_dapm_widget *tw,
struct sof_ipc_comp_reply *r)
{
@@ -2219,6 +2228,7 @@ static int sof_widget_load_process(struct snd_soc_component *scomp, int index,
}
memset(&config, 0, sizeof(config));
+ config.comp.core = core;
/* get the process token */
ret = sof_parse_tokens(scomp, &config, process_tokens,
@@ -2283,6 +2293,9 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
struct snd_sof_dai *dai;
struct sof_ipc_comp_reply reply;
struct snd_sof_control *scontrol;
+ struct sof_ipc_comp comp = {
+ .core = SOF_DSP_PRIMARY_CORE,
+ };
int ret = 0;
swidget = kzalloc(sizeof(*swidget), GFP_KERNEL);
@@ -2313,8 +2326,8 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
return -ENOMEM;
}
- ret = sof_widget_load_dai(scomp, index, swidget, tw, &reply,
- dai);
+ ret = sof_widget_load_dai(scomp, index, swidget, comp.core,
+ tw, &reply, dai);
if (ret == 0) {
sof_connect_dai_widget(scomp, w, tw, dai);
list_add(&dai->list, &sdev->dai_list);
@@ -2324,10 +2337,12 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
}
break;
case snd_soc_dapm_mixer:
- ret = sof_widget_load_mixer(scomp, index, swidget, tw, &reply);
+ ret = sof_widget_load_mixer(scomp, index, swidget, comp.core,
+ tw, &reply);
break;
case snd_soc_dapm_pga:
- ret = sof_widget_load_pga(scomp, index, swidget, tw, &reply);
+ ret = sof_widget_load_pga(scomp, index, swidget, comp.core,
+ tw, &reply);
/* Find scontrol for this pga and set readback offset*/
list_for_each_entry(scontrol, &sdev->kcontrol_list, list) {
if (scontrol->comp_id == swidget->comp_id) {
@@ -2337,36 +2352,41 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
}
break;
case snd_soc_dapm_buffer:
- ret = sof_widget_load_buffer(scomp, index, swidget, tw, &reply);
+ ret = sof_widget_load_buffer(scomp, index, swidget, comp.core,
+ tw, &reply);
break;
case snd_soc_dapm_scheduler:
- ret = sof_widget_load_pipeline(scomp, index, swidget, tw,
- &reply);
+ ret = sof_widget_load_pipeline(scomp, index, swidget,
+ tw, &reply);
break;
case snd_soc_dapm_aif_out:
- ret = sof_widget_load_pcm(scomp, index, swidget,
+ ret = sof_widget_load_pcm(scomp, index, swidget, comp.core,
SOF_IPC_STREAM_CAPTURE, tw, &reply);
break;
case snd_soc_dapm_aif_in:
- ret = sof_widget_load_pcm(scomp, index, swidget,
+ ret = sof_widget_load_pcm(scomp, index, swidget, comp.core,
SOF_IPC_STREAM_PLAYBACK, tw, &reply);
break;
case snd_soc_dapm_src:
- ret = sof_widget_load_src(scomp, index, swidget, tw, &reply);
+ ret = sof_widget_load_src(scomp, index, swidget, comp.core,
+ tw, &reply);
break;
case snd_soc_dapm_asrc:
- ret = sof_widget_load_asrc(scomp, index, swidget, tw, &reply);
+ ret = sof_widget_load_asrc(scomp, index, swidget, comp.core,
+ tw, &reply);
break;
case snd_soc_dapm_siggen:
- ret = sof_widget_load_siggen(scomp, index, swidget, tw, &reply);
+ ret = sof_widget_load_siggen(scomp, index, swidget, comp.core,
+ tw, &reply);
break;
case snd_soc_dapm_effect:
- ret = sof_widget_load_process(scomp, index, swidget, tw,
- &reply);
+ ret = sof_widget_load_process(scomp, index, swidget, comp.core,
+ tw, &reply);
break;
case snd_soc_dapm_mux:
case snd_soc_dapm_demux:
- ret = sof_widget_load_mux(scomp, index, swidget, tw, &reply);
+ ret = sof_widget_load_mux(scomp, index, swidget, comp.core,
+ tw, &reply);
break;
case snd_soc_dapm_switch:
case snd_soc_dapm_dai_link:
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] ASoC: SOF: support topology components on secondary cores
2020-09-02 14:07 [PATCH 0/3] ASoC: SOF: multi core support for 5.10 Kai Vehmanen
2020-09-02 14:07 ` [PATCH 1/3] ASoC: SOF: add a "core" parameter to widget loading functions Kai Vehmanen
@ 2020-09-02 14:07 ` Kai Vehmanen
2020-09-02 14:07 ` [PATCH 3/3] ASoC: SOF: topology: fix core enable sequence Kai Vehmanen
2020-09-04 10:03 ` [PATCH 0/3] ASoC: SOF: multi core support for 5.10 Mark Brown
3 siblings, 0 replies; 5+ messages in thread
From: Kai Vehmanen @ 2020-09-02 14:07 UTC (permalink / raw)
To: alsa-devel, broonie
Cc: Guennadi Liakhovetski, kai.vehmanen, Pan Xiuli,
pierre-louis.bossart, ranjani.sridharan, daniel.baluta
From: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
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.
Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
---
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(-)
diff --git a/include/uapi/sound/sof/tokens.h b/include/uapi/sound/sof/tokens.h
index 5941e2eb1588..37f5aaa09c2b 100644
--- a/include/uapi/sound/sof/tokens.h
+++ b/include/uapi/sound/sof/tokens.h
@@ -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
diff --git a/sound/soc/sof/pm.c b/sound/soc/sof/pm.c
index 92e5f9b15f3a..a5f7c7f024a1 100644
--- a/sound/soc/sof/pm.c
+++ b/sound/soc/sof/pm.c
@@ -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;
}
diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c
index 33d84405cf9c..d05f99cd7919 100644
--- a/sound/soc/sof/sof-audio.c
+++ b/sound/soc/sof/sof-audio.c
@@ -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:
diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h
index 9629994fe463..7f8be8817e69 100644
--- a/sound/soc/sof/sof-audio.h
+++ b/sound/soc/sof/sof-audio.h
@@ -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);
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index d41df9337328..46468fb7b6d1 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -8,6 +8,9 @@
// Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
//
+#include <linux/bits.h>
+#include <linux/device.h>
+#include <linux/errno.h>
#include <linux/firmware.h>
#include <linux/workqueue.h>
#include <sound/tlv.h>
@@ -715,6 +718,13 @@ static const struct sof_topology_token sai_tokens[] = {
offsetof(struct sof_ipc_dai_sai_params, mclk_id), 0},
};
+/* Core tokens */
+static const struct sof_topology_token core_tokens[] = {
+ {SOF_TKN_COMP_CORE_ID,
+ SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
+ offsetof(struct sof_ipc_comp, core), 0},
+};
+
/*
* DMIC PDM Tokens
* SOF_TKN_INTEL_DMIC_PDM_CTRL_ID should be the first token
@@ -1278,6 +1288,65 @@ static int sof_control_unload(struct snd_soc_component *scomp,
* DAI Topology
*/
+/* Static DSP core power management so far, should be extended in the future */
+static int sof_core_enable(struct snd_sof_dev *sdev, int core)
+{
+ struct sof_ipc_pm_core_config pm_core_config = {
+ .hdr = {
+ .cmd = SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CORE_ENABLE,
+ .size = sizeof(pm_core_config),
+ },
+ .enable_mask = sdev->enabled_cores_mask | BIT(core),
+ };
+ int ret;
+
+ if (sdev->enabled_cores_mask & BIT(core))
+ return 0;
+
+ /* power up the core */
+ ret = snd_sof_dsp_core_power_up(sdev, BIT(core));
+ if (ret < 0) {
+ dev_err(sdev->dev, "error: %d powering up core %d\n",
+ ret, core);
+ return ret;
+ }
+
+ /* update enabled cores mask */
+ sdev->enabled_cores_mask |= BIT(core);
+
+ /* Now notify DSP that the core has been powered up */
+ 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)
+ dev_err(sdev->dev, "error: core %d enable ipc failure %d\n",
+ core, ret);
+
+ return ret;
+}
+
+int sof_pipeline_core_enable(struct snd_sof_dev *sdev,
+ const struct snd_sof_widget *swidget)
+{
+ const struct sof_ipc_pipe_new *pipeline;
+ int ret;
+
+ if (swidget->id == snd_soc_dapm_scheduler) {
+ pipeline = swidget->private;
+ } else {
+ pipeline = snd_sof_pipeline_find(sdev, swidget->pipeline_id);
+ if (!pipeline)
+ return -ENOENT;
+ }
+
+ /* First enable the pipeline core */
+ ret = sof_core_enable(sdev, pipeline->core);
+ if (ret < 0)
+ return ret;
+
+ return sof_core_enable(sdev, swidget->core);
+}
+
static int sof_connect_dai_widget(struct snd_soc_component *scomp,
struct snd_soc_dapm_widget *w,
struct snd_soc_tplg_dapm_widget *tw,
@@ -1553,44 +1622,15 @@ int sof_load_pipeline_ipc(struct device *dev,
struct sof_ipc_comp_reply *r)
{
struct snd_sof_dev *sdev = dev_get_drvdata(dev);
- struct sof_ipc_pm_core_config pm_core_config;
- int ret;
+ int ret = sof_core_enable(sdev, pipeline->core);
- ret = sof_ipc_tx_message(sdev->ipc, pipeline->hdr.cmd, pipeline,
- sizeof(*pipeline), r, sizeof(*r));
- if (ret < 0) {
- dev_err(dev, "error: load pipeline ipc failure\n");
- return ret;
- }
-
- /* power up the core that this pipeline is scheduled on */
- ret = snd_sof_dsp_core_power_up(sdev, 1 << pipeline->core);
- if (ret < 0) {
- dev_err(dev, "error: powering up pipeline schedule core %d\n",
- pipeline->core);
+ if (ret < 0)
return ret;
- }
- /* update enabled cores mask */
- sdev->enabled_cores_mask |= 1 << pipeline->core;
-
- /*
- * Now notify DSP that the core that this pipeline is scheduled on
- * has been powered up
- */
- memset(&pm_core_config, 0, sizeof(pm_core_config));
- pm_core_config.enable_mask = sdev->enabled_cores_mask;
-
- /* configure CORE_ENABLE ipc message */
- pm_core_config.hdr.size = sizeof(pm_core_config);
- pm_core_config.hdr.cmd = SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CORE_ENABLE;
-
- /* send ipc */
- 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));
+ ret = sof_ipc_tx_message(sdev->ipc, pipeline->hdr.cmd, pipeline,
+ sizeof(*pipeline), r, sizeof(*r));
if (ret < 0)
- dev_err(dev, "error: core enable ipc failure\n");
+ dev_err(dev, "error: load pipeline ipc failure\n");
return ret;
}
@@ -2316,6 +2356,26 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
strnlen(tw->sname, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) > 0
? tw->sname : "none");
+ ret = sof_parse_tokens(scomp, &comp, core_tokens,
+ ARRAY_SIZE(core_tokens), tw->priv.array,
+ le32_to_cpu(tw->priv.size));
+ if (ret != 0) {
+ dev_err(scomp->dev, "error: parsing core tokens failed %d\n",
+ ret);
+ kfree(swidget);
+ return ret;
+ }
+
+ swidget->core = comp.core;
+
+ /* default is primary core, safe to call for already enabled cores */
+ ret = sof_core_enable(sdev, comp.core);
+ if (ret < 0) {
+ dev_err(scomp->dev, "error: enable core: %d\n", ret);
+ kfree(swidget);
+ return ret;
+ }
+
/* handle any special case widgets */
switch (w->id) {
case snd_soc_dapm_dai_in:
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] ASoC: SOF: topology: fix core enable sequence
2020-09-02 14:07 [PATCH 0/3] ASoC: SOF: multi core support for 5.10 Kai Vehmanen
2020-09-02 14:07 ` [PATCH 1/3] ASoC: SOF: add a "core" parameter to widget loading functions Kai Vehmanen
2020-09-02 14:07 ` [PATCH 2/3] ASoC: SOF: support topology components on secondary cores Kai Vehmanen
@ 2020-09-02 14:07 ` Kai Vehmanen
2020-09-04 10:03 ` [PATCH 0/3] ASoC: SOF: multi core support for 5.10 Mark Brown
3 siblings, 0 replies; 5+ messages in thread
From: Kai Vehmanen @ 2020-09-02 14:07 UTC (permalink / raw)
To: alsa-devel, broonie
Cc: Guennadi Liakhovetski, kai.vehmanen, Keyon Jie,
pierre-louis.bossart, ranjani.sridharan, daniel.baluta,
Rander Wang
From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
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.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Keyon Jie <yang.jie@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
---
sound/soc/sof/topology.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 46468fb7b6d1..d47da407a1bd 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -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;
}
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] ASoC: SOF: multi core support for 5.10
2020-09-02 14:07 [PATCH 0/3] ASoC: SOF: multi core support for 5.10 Kai Vehmanen
` (2 preceding siblings ...)
2020-09-02 14:07 ` [PATCH 3/3] ASoC: SOF: topology: fix core enable sequence Kai Vehmanen
@ 2020-09-04 10:03 ` Mark Brown
3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2020-09-04 10:03 UTC (permalink / raw)
To: alsa-devel, Kai Vehmanen
Cc: daniel.baluta, ranjani.sridharan, pierre-louis.bossart
On Wed, 2 Sep 2020 17:07:53 +0300, Kai Vehmanen wrote:
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-09-04 10:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-02 14:07 [PATCH 0/3] ASoC: SOF: multi core support for 5.10 Kai Vehmanen
2020-09-02 14:07 ` [PATCH 1/3] ASoC: SOF: add a "core" parameter to widget loading functions Kai Vehmanen
2020-09-02 14:07 ` [PATCH 2/3] ASoC: SOF: support topology components on secondary cores Kai Vehmanen
2020-09-02 14:07 ` [PATCH 3/3] ASoC: SOF: topology: fix core enable sequence Kai Vehmanen
2020-09-04 10:03 ` [PATCH 0/3] ASoC: SOF: multi core support for 5.10 Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox