ASoC: SOF: enable multicore with dynamic pipelines
Kai Vehmanen
reviewercover ASoC: SOF: enable multicore with dynamic pipelines
Hi,
initial support for SOF dynamic pipelines was added in commit 5fcdbb2d45df ("ASoC: SOF: Add support for dynamic pipelines").
When a pipeline is marked dynamic in the SOF DSP firmware topology definition (the tplg file kernel loads from filesystem), it means the pipeline resources are not allocated when DSP is booted (at driver probe, or at runtime resume), but rather delayed until the pipeline is actually used.
Until now, it has not been possible to use multiple DSP cores in a topology that uses dynamic pipeline capability. This patchset addresses this gap and allows to freely mix dynamic pipelines and multicore usages in topology definitions.
The series was originally reviewed in
https://github.com/thesofproject/linux/pull/3019
Ranjani Sridharan (10):
ASoC: SOF: Intel: hda: expose get_chip_info()
ASoC: SOF: Introduce num_cores and ref count per core
ASoC: SOF: Add ops for core_get and core_put
ASoC: SOF: Intel: TGL: set core_get/put ops
ASoC: SOF: Intel: CNL/ICL/APL: set core_get/core_put ops
ASoC: SOF: topology: remove sof_load_pipeline_ipc()
ASoC: SOF: free widgets in sof_tear_down_pipelines() for static
pipelines
ASoC: SOF: hda: don't use the core op for power up/power down
ASoC: SOF: add support for dynamic pipelines with multi-core
ASoC: SOF: Intel: hda: free DAI widget during stop and suspend
sound/soc/sof/imx/imx8.c | 1 + sound/soc/sof/imx/imx8m.c | 1 + sound/soc/sof/intel/apl.c | 5 +- sound/soc/sof/intel/bdw.c | 9 +++ sound/soc/sof/intel/byt.c | 9 +++ sound/soc/sof/intel/cnl.c | 5 +- sound/soc/sof/intel/hda-dai.c | 23 +------ sound/soc/sof/intel/hda-dsp.c | 52 +++++++++++++++- sound/soc/sof/intel/hda-loader.c | 24 +++++--- sound/soc/sof/intel/hda.c | 17 ++---- sound/soc/sof/intel/hda.h | 1 + sound/soc/sof/intel/icl.c | 5 +- sound/soc/sof/intel/pci-tng.c | 9 +++ sound/soc/sof/intel/shim.h | 7 +++ sound/soc/sof/intel/tgl.c | 46 +++++++++++++- sound/soc/sof/ops.h | 71 ++++++++++++++++------ sound/soc/sof/sof-audio.c | 83 +++++++++++++++++++------ sound/soc/sof/sof-audio.h | 6 -- sound/soc/sof/sof-priv.h | 21 +++++-- sound/soc/sof/topology.c | 100 ------------------------------- 20 files changed, 294 insertions(+), 201 deletions(-)
base-commit: 626a3dfbdb5d11f92e709680135abf272057ef59
Signature · 1 line
2.33.0
Kai Vehmanen
reviewerPATCH 1/10 ASoC: SOF: Intel: hda: expose get_chip_info()
From: Ranjani Sridharan <[email protected]>
expose get_chip_info().
--- sound/soc/sof/intel/hda.c | 11 ----------- sound/soc/sof/intel/shim.h | 7 +++++++ 2 files changed, 7 insertions(+), 11 deletions(-)
sound/soc/sof/intel/hda.c +0 -11
@@ -127,17 +127,6 @@ int hda_ctrl_dai_widget_free(struct snd_soc_dapm_widget *w)return sof_widget_free (sdev, swidget); } -static const struct sof_intel_dsp_desc - *get_chip_info (struct snd_sof_pdata *pdata) -{ -const struct sof_dev_desc *desc = pdata->desc; -const struct sof_intel_dsp_desc *chip_info; - - chip_info = desc->chip_info; - -return chip_info; -} -#if IS_ENABLED (CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE )/*
sound/soc/sof/intel/shim.h +7 -0
@@ -177,4 +177,11 @@ struct sof_intel_stream { size_t posn_offset; }; +static inline const struct sof_intel_dsp_desc *get_chip_info (struct snd_sof_pdata *pdata) +{ +const struct sof_dev_desc *desc = pdata->desc; + +return desc->chip_info; +} +#endif
Signature · 1 line
2.33.0
Kai Vehmanen
reviewerPATCH 2/10 ASoC: SOF: Introduce num_cores and ref count per core
In reply to Kai VehmanenFrom: Ranjani Sridharan <[email protected]>
Add two fields num_cores and dsp_cores_ref_count to struct snd_sof_dev. These will be used to maintain the ref count for each core to determine when it should be powered up or down.
--- sound/soc/sof/imx/imx8.c | 1 + sound/soc/sof/imx/imx8m.c | 1 + sound/soc/sof/intel/bdw.c | 9 +++++++++ sound/soc/sof/intel/byt.c | 9 +++++++++ sound/soc/sof/intel/hda.c | 2 ++ sound/soc/sof/intel/pci-tng.c | 9 +++++++++ sound/soc/sof/sof-priv.h | 15 +++++++++++++++ 7 files changed, 46 insertions(+)
sound/soc/sof/imx/imx8.c +1 -0
@@ -188,6 +188,7 @@ static int imx8_probe(struct snd_sof_dev *sdev)if (!priv)return -ENOMEM ; + sdev->num_cores =1 ; sdev->pdata->hw_pdata = priv; priv->dev = sdev->dev; priv->sdev = sdev;
sound/soc/sof/imx/imx8m.c +1 -0
@@ -108,6 +108,7 @@ static int imx8m_probe(struct snd_sof_dev *sdev)if (!priv)return -ENOMEM ; + sdev->num_cores =1 ; sdev->pdata->hw_pdata = priv; priv->dev = sdev->dev; priv->sdev = sdev;
sound/soc/sof/intel/bdw.c +9 -0
@@ -412,10 +412,19 @@ static int bdw_probe(struct snd_sof_dev *sdev)const struct sof_dev_desc *desc = pdata->desc;struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev); +const struct sof_intel_dsp_desc *chip;struct resource *mmio;u32 base, size;int ret; + chip =get_chip_info (sdev->pdata); +if (!chip) { +dev_err (sdev->dev,"error: no such device supported\n" ); +return -EIO ; + } + + sdev->num_cores = chip->cores_num; +/* LPE base */ mmio =platform_get_resource (pdev,IORESOURCE_MEM , desc->resindex_lpe_base);
sound/soc/sof/intel/byt.c +9 -0
@@ -113,10 +113,19 @@ static int byt_acpi_probe(struct snd_sof_dev *sdev)const struct sof_dev_desc *desc = pdata->desc;struct platform_device *pdev = container_of(sdev->dev, struct platform_device, dev); +const struct sof_intel_dsp_desc *chip;struct resource *mmio;u32 base, size;int ret; + chip =get_chip_info (sdev->pdata); +if (!chip) { +dev_err (sdev->dev,"error: no such device supported\n" ); +return -EIO ; + } + + sdev->num_cores = chip->cores_num; +/* DSP DMA can only access low 31 bits of host memory */ ret =dma_coerce_mask_and_coherent (sdev->dev,DMA_BIT_MASK (31 ));if (ret <0 ) {
sound/soc/sof/intel/hda.c +2 -0
@@ -897,6 +897,8 @@ int hda_dsp_probe(struct snd_sof_dev *sdev) goto err; } + sdev->num_cores = chip->cores_num; + hdev =devm_kzalloc (sdev->dev,sizeof (*hdev),GFP_KERNEL );if (!hdev)return -ENOMEM ;
sound/soc/sof/intel/pci-tng.c +9 -0
@@ -55,9 +55,18 @@ static int tangier_pci_probe(struct snd_sof_dev *sdev)struct snd_sof_pdata *pdata = sdev->pdata;const struct sof_dev_desc *desc = pdata->desc;struct pci_dev *pci =to_pci_dev (sdev->dev); +const struct sof_intel_dsp_desc *chip;u32 base, size;int ret; + chip =get_chip_info (sdev->pdata); +if (!chip) { +dev_err (sdev->dev,"error: no such device supported\n" ); +return -EIO ; + } + + sdev->num_cores = chip->cores_num; +/* DSP DMA can only access low 31 bits of host memory */ ret =dma_coerce_mask_and_coherent (&pci->dev,DMA_BIT_MASK (31 ));if (ret <0 ) {
sound/soc/sof/sof-priv.h +15 -0
@@ -71,6 +71,9 @@ extern int sof_core_debug;/* So far the primary core on all DSPs has ID 0 */ #define SOF_DSP_PRIMARY_CORE 0 +/* max number of DSP cores */ +#define SOF_MAX_DSP_NUM_CORES 8 +/* DSP power state */ enum sof_dsp_power_states {SOF_DSP_PM_D0 ,
@@ -477,6 +480,18 @@ struct snd_sof_dev {bool msi_enabled; +/* DSP core context */ +u32 num_cores; + +/* +* ref count per core that will be modified during system suspend/resume and during pcm +* hw_params/hw_free. This doesn't need to be protected with a mutex because pcm +* hw_params/hw_free are already protected by the PCM mutex in the ALSA framework in +* sound/core/ when streams are active and during system suspend/resume, streams are +* already suspended. +*/ +int dsp_core_ref_count[SOF_MAX_DSP_NUM_CORES ]; +void *private;/* core does not touch this */ };
Signature · 1 line
2.33.0
Kai Vehmanen
reviewerPATCH 3/10 ASoC: SOF: Add ops for core_get and core_put
In reply to Kai VehmanenFrom: Ranjani Sridharan <[email protected]>
Add ops to get/put a core that will be used to power up/down a core along with incrementing/decrementing its ref_count.
--- sound/soc/sof/ops.h | 63 ++++++++++++++++++++++++++++++++++++++++ sound/soc/sof/sof-priv.h | 2 ++ 2 files changed, 65 insertions(+)
sound/soc/sof/ops.h +63 -0
@@ -103,6 +103,69 @@ static inline int snd_sof_dsp_core_power_down(struct snd_sof_dev *sdev,return ret; } +static inline int snd_sof_dsp_core_get (struct snd_sof_dev *sdev,int core) +{ +if (core > sdev->num_cores -1 ) { +dev_err (sdev->dev,"invalid core id: %d for num_cores: %d\n" , core, + sdev->num_cores); +return -EINVAL ; + } + +if (sof_ops (sdev)->core_get) { +int ret; + +/* if current ref_count is > 0, increment it and return */ +if (sdev->dsp_core_ref_count[core] >0 ) { + sdev->dsp_core_ref_count[core]++; +return 0 ; + } + +/* power up the core */ + ret =sof_ops (sdev)->core_get (sdev, core); +if (ret <0 ) +return ret; + +/* increment ref_count */ + sdev->dsp_core_ref_count[core]++; + +/* and update enabled_cores_mask */ + sdev->enabled_cores_mask |=BIT (core); + +dev_dbg (sdev->dev,"Core %d powered up\n" , core); + } + +return 0 ; +} + +static inline int snd_sof_dsp_core_put (struct snd_sof_dev *sdev,int core) +{ +if (core > sdev->num_cores -1 ) { +dev_err (sdev->dev,"invalid core id: %d for num_cores: %d\n" , core, + sdev->num_cores); +return -EINVAL ; + } + +if (sof_ops (sdev)->core_put) { +int ret; + +/* decrement ref_count and return if it is > 0 */ +if (--(sdev->dsp_core_ref_count[core]) >0 ) +return 0 ; + +/* power down the core */ + ret =sof_ops (sdev)->core_put (sdev, core); +if (ret <0 ) +return ret; + +/* and update enabled_cores_mask */ + sdev->enabled_cores_mask &= ~BIT (core); + +dev_dbg (sdev->dev,"Core %d powered down\n" , core); + } + +return 0 ; +} +/* pre/post fw load */ static inline int snd_sof_dsp_pre_fw_run (struct snd_sof_dev *sdev) {
sound/soc/sof/sof-priv.h +2 -0
@@ -134,6 +134,8 @@ struct snd_sof_dsp_ops { unsigned int core_mask); /* optional */int (*core_power_down)(struct snd_sof_dev *sof_dev,unsigned int core_mask);/* optional */ +int (*core_get)(struct snd_sof_dev *sof_dev,int core);/* optional */ +int (*core_put)(struct snd_sof_dev *sof_dev,int core);/* optional */ /* * Register IO: only used by respective drivers themselves,
Signature · 1 line
2.33.0
Kai Vehmanen
reviewerPATCH 4/10 ASoC: SOF: Intel: TGL: set core_get/put ops
In reply to Kai VehmanenFrom: Ranjani Sridharan <[email protected]>
Set core_get/put() ops for TGL. When core_get() is requested for a core, its ref_count is incremented and the PM_CORE_ENABLE IPC sent to the firmware to power up the core if the current ref_count is 1. Conversely, the ref_count is decremented in core_put() and an IPC is sent to the DSP to power off the core if the ref_count is 0.
--- sound/soc/sof/intel/tgl.c | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
sound/soc/sof/intel/tgl.c +42 -0
@@ -20,6 +20,46 @@ static const struct snd_sof_debugfs_map tgl_dsp_debugfs[] = { {"dsp", HDA_DSP_BAR, 0, 0x10000, SOF_DEBUGFS_ACCESS_ALWAYS}, }; +static int tgl_dsp_core_get (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), + }; + +/* power up primary core if not already powered up and return */ +if (core ==SOF_DSP_PRIMARY_CORE ) +return hda_dsp_enable_core (sdev,BIT (core)); + +/* notify DSP for secondary cores */ +return 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)); +} + +static int tgl_dsp_core_put (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), + }; + +/* power down primary core and return */ +if (core ==SOF_DSP_PRIMARY_CORE ) +return hda_dsp_core_reset_power_down (sdev,BIT (core)); + +/* notify DSP for secondary cores */ +return 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)); +} +/* Tigerlake ops */ const struct snd_sof_dsp_ops sof_tgl_ops = { /* probe/remove/shutdown */
@@ -96,6 +136,8 @@ const struct snd_sof_dsp_ops sof_tgl_ops = {/* dsp core power up/down */ .core_power_up = hda_dsp_enable_core, .core_power_down = hda_dsp_core_reset_power_down, + .core_get = tgl_dsp_core_get, + .core_put = tgl_dsp_core_put,/* firmware run */ .run = hda_dsp_cl_boot_firmware_iccmax,
Signature · 1 line
2.33.0
Kai Vehmanen
reviewerPATCH 5/10 ASoC: SOF: Intel: CNL/ICL/APL: set core_get/core_put ops
In reply to Kai VehmanenFrom: Ranjani Sridharan <[email protected]>
Set core_get/put ops for CNL/ICL platforms. These platforms do not support enabling/disabling secondary cores dynamically. So skip sending the IPC to power off the cores in the core_put op.
--- sound/soc/sof/intel/apl.c | 1 + sound/soc/sof/intel/cnl.c | 1 + sound/soc/sof/intel/hda-dsp.c | 44 +++++++++++++++++++++++++++++++++++ sound/soc/sof/intel/hda.h | 1 + sound/soc/sof/intel/icl.c | 1 + 5 files changed, 48 insertions(+)
sound/soc/sof/intel/apl.c +1 -0
@@ -104,6 +104,7 @@ const struct snd_sof_dsp_ops sof_apl_ops = {/* dsp core power up/down */ .core_power_up = hda_dsp_enable_core, .core_power_down = hda_dsp_core_reset_power_down, + .core_get = hda_dsp_core_get,/* trace callback */ .trace_init = hda_dsp_trace_init,
sound/soc/sof/intel/cnl.c +1 -0
@@ -306,6 +306,7 @@ const struct snd_sof_dsp_ops sof_cnl_ops = {/* dsp core power up/down */ .core_power_up = hda_dsp_enable_core, .core_power_down = hda_dsp_core_reset_power_down, + .core_get = hda_dsp_core_get,/* firmware run */ .run = hda_dsp_cl_boot_firmware,
sound/soc/sof/intel/hda-dsp.c +44 -0
47 lines not on this page · raw message
sound/soc/sof/intel/hda.h +1 -0
@@ -496,6 +496,7 @@ int hda_dsp_core_run(struct snd_sof_dev *sdev, unsigned int core_mask);int hda_dsp_enable_core (struct snd_sof_dev *sdev,unsigned int core_mask);int hda_dsp_core_reset_power_down (struct snd_sof_dev *sdev,unsigned int core_mask); +int hda_dsp_core_get (struct snd_sof_dev *sdev,int core);void hda_dsp_ipc_int_enable (struct snd_sof_dev *sdev);void hda_dsp_ipc_int_disable (struct snd_sof_dev *sdev);
sound/soc/sof/intel/icl.c +1 -0
@@ -100,6 +100,7 @@ const struct snd_sof_dsp_ops sof_icl_ops = {/* dsp core power up/down */ .core_power_up = hda_dsp_enable_core, .core_power_down = hda_dsp_core_reset_power_down, + .core_get = hda_dsp_core_get,/* firmware run */ .run = hda_dsp_cl_boot_firmware_iccmax,
Signature · 1 line
2.33.0
Kai Vehmanen
reviewerPATCH 6/10 ASoC: SOF: topology: remove sof_load_pipeline_ipc()
In reply to Kai VehmanenFrom: Ranjani Sridharan <[email protected]>
Remove the function sof_load_pipeline_ipc() and directly send the IPC instead. The pipeline core is already enabled with the call to sof_pipeline_core_enable() in sof_widget_setup().
--- sound/soc/sof/sof-audio.c | 3 ++- sound/soc/sof/sof-audio.h | 4 ---- sound/soc/sof/topology.c | 17 ----------------- 3 files changed, 2 insertions(+), 22 deletions(-)
sound/soc/sof/sof-audio.c +2 -1
@@ -203,7 +203,8 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget)break ;case snd_soc_dapm_scheduler: pipeline = swidget->private; - ret =sof_load_pipeline_ipc (sdev, pipeline, &r); + ret =sof_ipc_tx_message (sdev->ipc, pipeline->hdr.cmd, pipeline, +sizeof (*pipeline), &r,sizeof (r));break ;default : hdr = swidget->private;
sound/soc/sof/sof-audio.h +0 -4
@@ -184,10 +184,6 @@ void snd_sof_control_notify(struct snd_sof_dev *sdev,int snd_sof_load_topology (struct snd_soc_component *scomp,const char *file);int snd_sof_complete_pipeline (struct snd_sof_dev *sdev,struct snd_sof_widget *swidget); - -int sof_load_pipeline_ipc (struct snd_sof_dev *sdev, -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);
sound/soc/sof/topology.c +0 -17
@@ -1707,23 +1707,6 @@ static int sof_widget_load_pcm(struct snd_soc_component *scomp, int index,/* * Pipeline Topology */ -int sof_load_pipeline_ipc (struct snd_sof_dev *sdev, -struct sof_ipc_pipe_new *pipeline, -struct sof_ipc_comp_reply *r) -{ -int ret =sof_core_enable (sdev, pipeline->core); - -if (ret <0 ) -return ret; - - ret =sof_ipc_tx_message (sdev->ipc, pipeline->hdr.cmd, pipeline, -sizeof (*pipeline), r,sizeof (*r)); -if (ret <0 ) -dev_err (sdev->dev,"error: load pipeline ipc failure\n" ); - -return ret; -} -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)
Signature · 1 line
2.33.0
Kai Vehmanen
reviewerPATCH 7/10 ASoC: SOF: free widgets in sof_tear_down_pipelines() for static pipelines
In reply to Kai VehmanenFrom: Ranjani Sridharan <[email protected]>
Free widgets for static pipelines in sof_tear_down_pipelines(). But this feature is unavailable in older firmware with ABI < 3.19. Just reset widget use_count's for this case. This would ensure that the secondary cores enabled required for topology setup are powered down properly before the primary core is powered off during system suspend.
--- sound/soc/sof/sof-audio.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
sound/soc/sof/sof-audio.c +10 -3
@@ -665,11 +665,12 @@ int sof_set_up_pipelines(struct snd_sof_dev *sdev, bool verify) }/* -* This function doesn't free widgets during suspend. It only resets the set up status for all -* routes and use_count for all widgets. +* For older firmware, this function doesn't free widgets for static pipelines during suspend. +* It only resets use_count for all widgets. */ int sof_tear_down_pipelines (struct snd_sof_dev *sdev,bool verify) { +struct sof_ipc_fw_version *v = &sdev->fw_ready.version;struct snd_sof_widget *swidget;struct snd_sof_route *sroute;int ret;
@@ -681,8 +682,14 @@ int sof_tear_down_pipelines(struct snd_sof_dev *sdev, bool verify)* loading the sound card unavailable to open PCMs. */ list_for_each_entry_reverse (swidget, &sdev->widget_list, list) { -if (!verify) { +if (swidget->dynamic_pipeline_widget) +continue ; + +/* Do not free widgets for static pipelines with FW ABI older than 3.19 */ +if (!verify && !swidget->dynamic_pipeline_widget && + v->abi_version <SOF_ABI_VER (3 ,19 ,0 )) { swidget->use_count =0 ; + swidget->complete =0 ;continue ; }
Signature · 1 line
2.33.0
Kai Vehmanen
reviewerPATCH 8/10 ASoC: SOF: hda: don't use the core op for power up/power down
In reply to Kai VehmanenFrom: Ranjani Sridharan <[email protected]>
The core_power_up/down() ops will be deprecated. Use the HDA platform-specific functions for powering up/down the cores during probe/suspend/remove. The enabled_cores_mask and the core ref_count's are manually updated in each of these functions.
--- sound/soc/sof/intel/hda-dsp.c | 8 ++++++-- sound/soc/sof/intel/hda-loader.c | 24 +++++++++++++++++------- sound/soc/sof/intel/hda.c | 4 ++-- 3 files changed, 25 insertions(+), 11 deletions(-)
sound/soc/sof/intel/hda-dsp.c +6 -2
@@ -614,7 +614,7 @@ static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA )struct hdac_bus *bus =sof_to_bus (sdev);#endif -int ret; +int ret, j;hda_sdw_int_enable (sdev, false);
@@ -629,13 +629,17 @@ static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)#endif /* power down DSP */ - ret =snd_sof_dsp_core_power_down (sdev, chip->host_managed_cores_mask); + ret =hda_dsp_core_reset_power_down (sdev, chip->host_managed_cores_mask);if (ret <0 ) {dev_err (sdev->dev,"error: failed to power down core during suspend\n" );return ret; } +/* reset ref counts for all cores */ +for (j =0 ; j < chip->cores_num; j++) + sdev->dsp_core_ref_count[j] =0 ; +/* disable ppcap interrupt */ hda_dsp_ctrl_ppcap_enable (sdev, false);hda_dsp_ctrl_ppcap_int_enable (sdev, false);
sound/soc/sof/intel/hda-loader.c +17 -7
@@ -88,12 +88,13 @@ static int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag)struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;const struct sof_intel_dsp_desc *chip = hda->desc;unsigned int status; -u32 flags; +unsigned long mask; +u32 flags, j;int ret;int i;/* step 1: power up corex */ - ret =snd_sof_dsp_core_power_up (sdev, chip->host_managed_cores_mask); + ret =hda_dsp_enable_core (sdev, chip->host_managed_cores_mask);if (ret <0 ) {if (hda->boot_iteration ==HDA_FW_BOOT_ATTEMPTS )dev_err (sdev->dev,"error: dsp core 0/1 power up failed\n" );
@@ -148,8 +149,8 @@ static int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag) chip->ipc_ack_mask);/* step 5: power down cores that are no longer needed */ - ret =snd_sof_dsp_core_power_down (sdev, chip->host_managed_cores_mask & - ~(chip->init_core_mask)); + ret =hda_dsp_core_reset_power_down (sdev, chip->host_managed_cores_mask & + ~(chip->init_core_mask));if (ret <0 ) {if (hda->boot_iteration ==HDA_FW_BOOT_ATTEMPTS ) dev_err(sdev->dev,
@@ -168,8 +169,14 @@ static int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag)HDA_DSP_REG_POLL_INTERVAL_US , chip->rom_init_timeout * USEC_PER_MSEC); -if (!ret) +if (!ret) { +/* set enabled cores mask and increment ref count for cores in init_core_mask */ + sdev->enabled_cores_mask |= chip->init_core_mask; + mask = sdev->enabled_cores_mask; +for_each_set_bit (j, &mask,SOF_MAX_DSP_NUM_CORES ) + sdev->dsp_core_ref_count[j]++;return 0 ; + }if (hda->boot_iteration ==HDA_FW_BOOT_ATTEMPTS ) dev_err(sdev->dev,
@@ -184,7 +191,7 @@ static int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag) flags &= ~SOF_DBG_DUMP_OPTIONAL ;snd_sof_dsp_dbg_dump (sdev, flags); -snd_sof_dsp_core_power_down (sdev, chip->host_managed_cores_mask); +hda_dsp_core_reset_power_down (sdev, chip->host_managed_cores_mask);return ret; }
@@ -501,12 +508,15 @@ int hda_dsp_post_fw_run_icl(struct snd_sof_dev *sdev)* the host whereas on TGL it is handled by the firmware. */ if (!hda->clk_config_lpro) { - ret =snd_sof_dsp_core_power_up (sdev,BIT (3 )); + ret =hda_dsp_enable_core (sdev,BIT (3 ));if (ret <0 ) {dev_err (sdev->dev,"error: dsp core power up failed on core 3\n" );return ret; } + sdev->enabled_cores_mask |=BIT (3 ); + sdev->dsp_core_ref_count[3 ]++; +snd_sof_dsp_stall (sdev,BIT (3 )); }
sound/soc/sof/intel/hda.c +2 -2
@@ -1034,9 +1034,9 @@ int hda_dsp_probe(struct snd_sof_dev *sdev)int hda_dsp_remove (struct snd_sof_dev *sdev) {struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; +const struct sof_intel_dsp_desc *chip = hda->desc;struct hdac_bus *bus =sof_to_bus (sdev);struct pci_dev *pci =to_pci_dev (sdev->dev); -const struct sof_intel_dsp_desc *chip = hda->desc;/* cancel any attempt for DSP D0I3 */ cancel_delayed_work_sync (&hda->d0i3_work);
@@ -1061,7 +1061,7 @@ int hda_dsp_remove(struct snd_sof_dev *sdev)/* disable cores */ if (chip) -snd_sof_dsp_core_power_down (sdev, chip->host_managed_cores_mask); +hda_dsp_core_reset_power_down (sdev, chip->host_managed_cores_mask);/* disable DSP */ snd_sof_dsp_update_bits(sdev, HDA_DSP_PP_BAR, SOF_HDA_REG_PP_PPCTL,
Signature · 1 line
2.33.0
Kai Vehmanen
reviewerPATCH 9/10 ASoC: SOF: add support for dynamic pipelines with multi-core
In reply to Kai VehmanenFrom: Ranjani Sridharan <[email protected]>
This patch adds support for dynamic pipelines with multi-core by using the platform-specific core_get/put() ops to power up/down a core when a widget is set up/freed.
Along with this, a few redundant functions are removed:
1. sof_pipeline_core_enable() is no longer needed as the pipeline core will be set up when the pipeline widget is set up
2. sof_core_enable() is replaced with snd_sof_core_get()
4. core_power_up/down() DSP ops are deprecated and replaced with core get/put ops.
5. Core power down in sof_widget_unload() during topology removal is also removed as it is not really needed. For dynamic pipelines, the cores will be powered off when they are not used. For static pipelines, the cores will be powered off in the device remove callback.
--- sound/soc/sof/intel/apl.c | 4 +- sound/soc/sof/intel/cnl.c | 4 +- sound/soc/sof/intel/icl.c | 4 +- sound/soc/sof/intel/tgl.c | 4 +- sound/soc/sof/ops.h | 32 +-------------- sound/soc/sof/sof-audio.c | 67 +++++++++++++++++++++++++------ sound/soc/sof/sof-audio.h | 2 - sound/soc/sof/sof-priv.h | 4 -- sound/soc/sof/topology.c | 83 --------------------------------------- 9 files changed, 59 insertions(+), 145 deletions(-)
sound/soc/sof/intel/apl.c +1 -3
@@ -101,9 +101,7 @@ const struct snd_sof_dsp_ops sof_apl_ops = {/* parse platform specific extended manifest */ .parse_platform_ext_manifest = hda_dsp_ext_man_get_cavs_config_data, -/* dsp core power up/down */ - .core_power_up = hda_dsp_enable_core, - .core_power_down = hda_dsp_core_reset_power_down, +/* dsp core get/put */ .core_get = hda_dsp_core_get,/* trace callback */
sound/soc/sof/intel/cnl.c +1 -3
@@ -303,9 +303,7 @@ const struct snd_sof_dsp_ops sof_cnl_ops = {/* parse platform specific extended manifest */ .parse_platform_ext_manifest = hda_dsp_ext_man_get_cavs_config_data, -/* dsp core power up/down */ - .core_power_up = hda_dsp_enable_core, - .core_power_down = hda_dsp_core_reset_power_down, +/* dsp core get/put */ .core_get = hda_dsp_core_get,/* firmware run */
sound/soc/sof/intel/icl.c +1 -3
@@ -97,9 +97,7 @@ const struct snd_sof_dsp_ops sof_icl_ops = {/* parse platform specific extended manifest */ .parse_platform_ext_manifest = hda_dsp_ext_man_get_cavs_config_data, -/* dsp core power up/down */ - .core_power_up = hda_dsp_enable_core, - .core_power_down = hda_dsp_core_reset_power_down, +/* dsp core get/put */ .core_get = hda_dsp_core_get,/* firmware run */
sound/soc/sof/intel/tgl.c +1 -3
@@ -133,9 +133,7 @@ const struct snd_sof_dsp_ops sof_tgl_ops = {/* parse platform specific extended manifest */ .parse_platform_ext_manifest = hda_dsp_ext_man_get_cavs_config_data, -/* dsp core power up/down */ - .core_power_up = hda_dsp_enable_core, - .core_power_down = hda_dsp_core_reset_power_down, +/* dsp core get/put */ .core_get = tgl_dsp_core_get, .core_put = tgl_dsp_core_put,
sound/soc/sof/ops.h +1 -31
@@ -72,37 +72,7 @@ static inline int snd_sof_dsp_reset(struct snd_sof_dev *sdev)return 0 ; } -/* dsp core power up/power down */ -static inline int snd_sof_dsp_core_power_up (struct snd_sof_dev *sdev, -unsigned int core_mask) -{ -int ret =0 ; - - core_mask &= ~sdev->enabled_cores_mask; -if (sof_ops (sdev)->core_power_up && core_mask) { - ret =sof_ops (sdev)->core_power_up (sdev, core_mask); -if (!ret) - sdev->enabled_cores_mask |= core_mask; - } - -return ret; -} - -static inline int snd_sof_dsp_core_power_down (struct snd_sof_dev *sdev, -unsigned int core_mask) -{ -int ret =0 ; - - core_mask &= sdev->enabled_cores_mask; -if (sof_ops (sdev)->core_power_down && core_mask) { - ret =sof_ops (sdev)->core_power_down (sdev, core_mask); -if (!ret) - sdev->enabled_cores_mask &= ~core_mask; - } - -return ret; -} - +/* dsp core get/put */ static inline int snd_sof_dsp_core_get (struct snd_sof_dev *sdev,int core) {if (core > sdev->num_cores -1 ) {
sound/soc/sof/sof-audio.c +54 -13
147 lines not on this page · raw message
sound/soc/sof/sof-audio.h +0 -2
@@ -184,8 +184,6 @@ void snd_sof_control_notify(struct snd_sof_dev *sdev,int snd_sof_load_topology (struct snd_soc_component *scomp,const char *file);int snd_sof_complete_pipeline (struct snd_sof_dev *sdev,struct snd_sof_widget *swidget); -int sof_pipeline_core_enable (struct snd_sof_dev *sdev, -const struct snd_sof_widget *swidget);/* * Stream IPC
sound/soc/sof/sof-priv.h +0 -4
@@ -130,10 +130,6 @@ struct snd_sof_dsp_ops {int (*run)(struct snd_sof_dev *sof_dev);/* mandatory */ int (*stall)(struct snd_sof_dev *sof_dev,unsigned int core_mask);/* optional */ int (*reset)(struct snd_sof_dev *sof_dev);/* optional */ -int (*core_power_up)(struct snd_sof_dev *sof_dev, -unsigned int core_mask);/* optional */ -int (*core_power_down)(struct snd_sof_dev *sof_dev, -unsigned int core_mask);/* optional */ int (*core_get)(struct snd_sof_dev *sof_dev,int core);/* optional */ int (*core_put)(struct snd_sof_dev *sof_dev,int core);/* optional */
sound/soc/sof/topology.c +0 -83
103 lines not on this page · raw message
Signature · 1 line
2.33.0
Kai Vehmanen
reviewerPATCH 10/10 ASoC: SOF: Intel: hda: free DAI widget during stop and suspend
In reply to Kai VehmanenFrom: Ranjani Sridharan <[email protected]>
To keep the widget use_counts balanced, free the DAI widget during suspend and also during the stop trigger.
--- sound/soc/sof/intel/hda-dai.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-)
sound/soc/sof/intel/hda-dai.c +2 -21
@@ -182,24 +182,6 @@ static struct sof_ipc_dai_config *hda_dai_update_config(struct snd_soc_dapm_widgreturn config; } -static int hda_link_config_ipc (struct sof_intel_hda_stream *hda_stream, -struct snd_soc_dapm_widget *w,int channel) -{ -struct snd_sof_dev *sdev = hda_stream->sdev; -struct sof_ipc_dai_config *config; -struct sof_ipc_reply reply; - - config =hda_dai_update_config (w, channel); -if (!config) { -dev_err (sdev->dev,"error: no config for DAI %s\n" , w->name); -return -ENOENT ; - } - -/* send DAI_CONFIG IPC */ -return sof_ipc_tx_message (sdev->ipc, config->hdr.cmd, config, config->hdr.size, - &reply,sizeof (reply)); -} -static int hda_link_dai_widget_update (struct sof_intel_hda_stream *hda_stream,struct snd_soc_dapm_widget *w,int channel,bool widget_setup)
@@ -353,10 +335,9 @@ static int hda_link_pcm_trigger(struct snd_pcm_substream *substream, w = dai->capture_widget;/* -* clear link DMA channel. It will be assigned when -* hw_params is set up again after resume. +* free DAI widget during stop/suspend to keep widget use_count's balanced. */ - ret =hda_link_config_ipc (hda_stream, w,DMA_CHAN_INVALID ); + ret =hda_link_dai_widget_update (hda_stream, w,DMA_CHAN_INVALID , false);if (ret <0 )return ret;
Signature · 1 line
2.33.0
Mark Brown
maintainerQuoted 10 lines · Kai Vehmanen
initial support for SOF dynamic pipelines was added in commit
5fcdbb2d45df("ASoC: SOF: Add support for dynamic pipelines").When a pipeline is marked dynamic in the SOF DSP firmware topology definition (the tplg file kernel loads from filesystem), it means the pipeline resources are not allocated when DSP is booted (at driver probe, or at runtime resume), but rather delayed until the pipeline is actually used.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/10] ASoC: SOF: Intel: hda: expose get_chip_info()
commit: 81ed6770ba67358b07e96a277206f6c742737dab
[02/10] ASoC: SOF: Introduce num_cores and ref count per core
commit: 5974f6843203f0061d9df05c32262a10359740a6
[03/10] ASoC: SOF: Add ops for core_get and core_put
commit: c414d5df9d05471aa47f50fca7fa4412daca7ac7
[04/10] ASoC: SOF: Intel: TGL: set core_get/put ops
commit: 41dd63cccb42ec26f555cbb2495d85828a4b0e96
[05/10] ASoC: SOF: Intel: CNL/ICL/APL: set core_get/core_put ops
commit: 9cdcbc9f6788661fb02fb2340032a5c8115aaf9b
[06/10] ASoC: SOF: topology: remove sof_load_pipeline_ipc()
commit: 7cc7b9ba21d4978d19f0e3edc2b00d44c9d66ff6
[07/10] ASoC: SOF: free widgets in sof_tear_down_pipelines() for static pipelines
commit: b2ebcf42a48f4560862bb811f3268767d17ebdcd
[08/10] ASoC: SOF: hda: don't use the core op for power up/power down
commit: d416519982cb1d25358f558a4e68d9d254c9ca53
[09/10] ASoC: SOF: add support for dynamic pipelines with multi-core
commit: 9ea807488cdaef83da702d4a02d54138b88f4377
[10/10] ASoC: SOF: Intel: hda: free DAI widget during stop and suspend
commit: 05827a1537f35221d84b8f5606f2f4c1371c69f3All 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