ASoC: SOF: ipc4/intel: Support for ChainDMA
Subsystems (3)
Peter Ujfalusi
maintainerv2 cover ASoC: SOF: ipc4/intel: Support for ChainDMA
Hi,
Changes since v1:
- Fix missed mutex unlocking in sof_ipc4_widget_free() Reported by Dan Carpenter (thank you!)
On a platform when the DSP is in use, we cannot select individual links to use or not use the DSP, it is either all or none.
On some audio endpoint, like HDMI/DP, it is preferred to not use any processing in DSP to reduce the latency and to allow bytestream pass-through (DTS, DD, etc)
IPC4 introduces a new type of end-to-end connection within the DSP which is using the host DMA and link DMA in a single buffer, working back-to-back, passing the received data without looking at it or trying to understand the format, content.
This mode reduces the latency and allows non PCM streams to be sent from userspace.
The feature is enabled per PCM bases, signalled in topology.
Regards,
Peter
---
*** BLURB HERE ***
Jyri Sarha (2):
ASoC: SOF: ipc4: Add macros for chain-dma message bits
ASoC: SOF: ipc4/intel: Add support for chained DMA
Ranjani Sridharan (1):
ASoC: SOF: topology: Set pipeline widget before updating IPC
structures
include/sound/sof/ipc4/header.h | 29 +++++++ include/uapi/sound/sof/tokens.h | 1 + sound/soc/sof/intel/hda-dai-ops.c | 18 ++++- sound/soc/sof/ipc4-pcm.c | 122 +++++++++++++++++++++++++++++- sound/soc/sof/ipc4-topology.c | 122 +++++++++++++++++++++++++++++- sound/soc/sof/ipc4-topology.h | 2 + sound/soc/sof/topology.c | 48 ++++++------ 7 files changed, 310 insertions(+), 32 deletions(-)
Signature · 1 line
2.40.0
Peter Ujfalusi
maintainerPATCH v2 2/3 ASoC: SOF: ipc4: Add macros for chain-dma message bits
From: Jyri Sarha <[email protected]>
In the chained DMA mode, the firmware allocates buffers for the host and link DMA, and takes care of copying data between host- and link-DMA buffers in a low-latency thread. This is different to a regular pipeline, no processing is allowed, and the connection between host- and link DMA is handled with a dedicated IPC.
This patch exposes the macros needed to create the required IPC messages.
--- include/sound/sof/ipc4/header.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
include/sound/sof/ipc4/header.h +29 -0
@@ -196,6 +196,35 @@ enum sof_ipc4_pipeline_state {#define SOF_IPC4_GLB_LOAD_LIBRARY_LIB_ID_SHIFT 16#define SOF_IPC4_GLB_LOAD_LIBRARY_LIB_ID (x) ((x) << SOF_IPC4_GLB_LOAD_LIBRARY_LIB_ID_SHIFT) +/* chain dma ipc message */ +#define SOF_IPC4_GLB_CHAIN_DMA_HOST_ID_SHIFT 0 +#define SOF_IPC4_GLB_CHAIN_DMA_HOST_ID_MASK GENMASK(4, 0) +#define SOF_IPC4_GLB_CHAIN_DMA_HOST_ID (x) (((x) << SOF_IPC4_GLB_CHAIN_DMA_HOST_ID_SHIFT) & \ + SOF_IPC4_GLB_CHAIN_DMA_HOST_ID_MASK) + +#define SOF_IPC4_GLB_CHAIN_DMA_LINK_ID_SHIFT 8 +#define SOF_IPC4_GLB_CHAIN_DMA_LINK_ID_MASK GENMASK(12, 8) +#define SOF_IPC4_GLB_CHAIN_DMA_LINK_ID (x) (((x) << SOF_IPC4_GLB_CHAIN_DMA_LINK_ID_SHIFT) & \ + SOF_IPC4_GLB_CHAIN_DMA_LINK_ID_MASK) + +#define SOF_IPC4_GLB_CHAIN_DMA_ALLOCATE_SHIFT 16 +#define SOF_IPC4_GLB_CHAIN_DMA_ALLOCATE_MASK BIT(16) +#define SOF_IPC4_GLB_CHAIN_DMA_ALLOCATE (x) (((x) & 1) << SOF_IPC4_GLB_CHAIN_DMA_ALLOCATE_SHIFT) + +#define SOF_IPC4_GLB_CHAIN_DMA_ENABLE_SHIFT 17 +#define SOF_IPC4_GLB_CHAIN_DMA_ENABLE_MASK BIT(17) +#define SOF_IPC4_GLB_CHAIN_DMA_ENABLE (x) (((x) & 1) << SOF_IPC4_GLB_CHAIN_DMA_ENABLE_SHIFT) + +#define SOF_IPC4_GLB_CHAIN_DMA_SCS_SHIFT 18 +#define SOF_IPC4_GLB_CHAIN_DMA_SCS_MASK BIT(18) +#define SOF_IPC4_GLB_CHAIN_DMA_SCS (x) (((x) & 1) << SOF_IPC4_GLB_CHAIN_DMA_SCS_SHIFT) + +#define SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE_SHIFT 0 +#define SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE_MASK GENMASK(24, 0) +#define SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE (x) (((x) << \ + SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE_SHIFT) & \ + SOF_IPC4_GLB_EXT_CHAIN_DMA_FIFO_SIZE_MASK) +enum sof_ipc4_channel_config {/* one channel only. */ SOF_IPC4_CHANNEL_CONFIG_MONO ,
Signature · 1 line
2.40.0
Peter Ujfalusi
maintainerPATCH v2 1/3 ASoC: SOF: topology: Set pipeline widget before updating IPC structures
In reply to Peter UjfalusiFrom: Ranjani Sridharan <[email protected]>
Set up the IPC structure for scheduler widgets and set the pipeline widget before updating the IPC structures for all widgets. This will be needed to look up pipeline information during IPC structure set up.
--- sound/soc/sof/topology.c | 48 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-)
sound/soc/sof/topology.c +24 -24
@@ -2126,7 +2126,6 @@ static int sof_complete(struct snd_soc_component *scomp) {struct snd_sof_dev *sdev =snd_soc_component_get_drvdata (scomp);const struct sof_ipc_tplg_ops *tplg_ops =sof_ipc_get_ops (sdev, tplg); -struct snd_sof_widget *swidget, *comp_swidget;const struct sof_ipc_tplg_widget_ops *widget_ops;struct snd_sof_control *scontrol;struct snd_sof_pipeline *spipe;
@@ -2145,37 +2144,38 @@ static int sof_complete(struct snd_soc_component *scomp) } } -/* -* then update all widget IPC structures. If any of the ipc_setup callbacks fail, the -* topology will be removed and all widgets will be unloaded resulting in freeing all -* associated memories. -*/ -list_for_each_entry (swidget, &sdev->widget_list, list) { -if (widget_ops && widget_ops[swidget->id].ipc_setup) { - ret = widget_ops[swidget->id].ipc_setup (swidget); +/* set up the IPC structures for the pipeline widgets */ +list_for_each_entry (spipe, &sdev->pipeline_list, list) { +struct snd_sof_widget *pipe_widget = spipe->pipe_widget; +struct snd_sof_widget *swidget; + +/* Update the scheduler widget's IPC structure */ +if (widget_ops && widget_ops[pipe_widget->id].ipc_setup) { + ret = widget_ops[pipe_widget->id].ipc_setup (pipe_widget);if (ret <0 ) {dev_err (sdev->dev,"failed updating IPC struct for %s\n" , - swidget->widget->name); + pipe_widget->widget->name);return ret; } } - } -/* set the pipe_widget and apply the dynamic_pipeline_widget_flag */ -list_for_each_entry (spipe, &sdev->pipeline_list, list) { -struct snd_sof_widget *pipe_widget = spipe->pipe_widget; - -/* -* Apply the dynamic_pipeline_widget flag and set the pipe_widget field -* for all widgets that have the same pipeline ID as the scheduler widget. -* Skip the scheduler widgets as they have their pipeline set during widget_ready -*/ -list_for_each_entry (comp_swidget, &sdev->widget_list, list) -if (comp_swidget->widget->id != snd_soc_dapm_scheduler && - comp_swidget->pipeline_id == pipe_widget->pipeline_id) { - ret =sof_set_widget_pipeline (sdev, spipe, comp_swidget); +/* set the pipeline and update the IPC structure for the non scheduler widgets */ +list_for_each_entry (swidget, &sdev->widget_list, list) +if (swidget->widget->id != snd_soc_dapm_scheduler && + swidget->pipeline_id == pipe_widget->pipeline_id) { + ret =sof_set_widget_pipeline (sdev, spipe, swidget);if (ret <0 )return ret; + +if (widget_ops && widget_ops[swidget->id].ipc_setup) { + ret = widget_ops[swidget->id].ipc_setup (swidget); +if (ret <0 ) { +dev_err (sdev->dev, +"failed updating IPC struct for %s\n" , + swidget->widget->name); +return ret; + } + } } }
Signature · 1 line
2.40.0
Peter Ujfalusi
maintainerPATCH v2 3/3 ASoC: SOF: ipc4/intel: Add support for chained DMA
In reply to Peter UjfalusiFrom: Jyri Sarha <[email protected]>
Add logic for setting up and tearing down chained DMA connections.
Since pipelines are not used, all the logic to set the pipeline states can be bypassed, with only the DMA programming sequences remaining. In addition the same format needs to be used for host- and link-DMA, without the usual fixup to use the S32_LE format on the link.
Note however that for convenience and compatibility with existing definitions, the topology relies on the concept of pipelines with a 'USE_CHAIN_DMA' token indicating that all the logic shall be bypassed.
Unlike 'normal' ALSA sequences, the chain DMA is not programmed in hw_params/hw_free. The IPC message to set-up and tear-down chained DMA are sent in sof_ipc4_trigger_pipelines(), but the contents prepared earlier.
Chained DMA is only supported by the Intel HDA DAI for now, and only S16_LE and S32_LE formats are supported for now.
--- include/uapi/sound/sof/tokens.h | 1 + sound/soc/sof/intel/hda-dai-ops.c | 18 ++++- sound/soc/sof/ipc4-pcm.c | 122 +++++++++++++++++++++++++++++- sound/soc/sof/ipc4-topology.c | 122 +++++++++++++++++++++++++++++- sound/soc/sof/ipc4-topology.h | 2 + 5 files changed, 257 insertions(+), 8 deletions(-)
include/uapi/sound/sof/tokens.h +1 -0
@@ -54,6 +54,7 @@#define SOF_TKN_SCHED_DYNAMIC_PIPELINE 206#define SOF_TKN_SCHED_LP_MODE 207#define SOF_TKN_SCHED_MEM_USAGE 208 +#define SOF_TKN_SCHED_USE_CHAIN_DMA 209/* volume */ #define SOF_TKN_VOLUME_RAMP_STEP_TYPE 250
sound/soc/sof/intel/hda-dai-ops.c +17 -1
@@ -277,6 +277,15 @@ static const struct hda_dai_widget_dma_ops hda_ipc4_dma_ops = { .post_trigger = hda_ipc4_post_trigger }; +static const struct hda_dai_widget_dma_ops hda_ipc4_chain_dma_ops = { + .get_hext_stream = hda_get_hext_stream, + .assign_hext_stream = hda_assign_hext_stream, + .release_hext_stream = hda_release_hext_stream, + .setup_hext_stream = hda_setup_hext_stream, + .reset_hext_stream = hda_reset_hext_stream, + .trigger = hda_trigger, +}; +static int hda_ipc3_post_trigger (struct snd_sof_dev *sdev,struct snd_soc_dai *cpu_dai,struct snd_pcm_substream *substream,int cmd) {
@@ -331,8 +340,15 @@ hda_select_dai_widget_ops(struct snd_sof_dev *sdev, struct snd_sof_widget *swidg {struct sof_ipc4_copier *ipc4_copier = sdai->private; -if (ipc4_copier->dai_type ==SOF_DAI_INTEL_HDA ) +if (ipc4_copier->dai_type ==SOF_DAI_INTEL_HDA ) { +struct snd_sof_widget *pipe_widget = swidget->spipe->pipe_widget; +struct sof_ipc4_pipeline *pipeline = pipe_widget->private; + +if (pipeline->use_chain_dma) +return &hda_ipc4_chain_dma_ops; +return &hda_ipc4_dma_ops; + }break ; }default :
sound/soc/sof/ipc4-pcm.c +118 -4
153 lines not on this page · raw message
sound/soc/sof/ipc4-topology.c +119 -3
237 lines not on this page · raw message
sound/soc/sof/ipc4-topology.h +2 -0
@@ -126,6 +126,7 @@ struct sof_ipc4_copier_config_set_sink_format {* @mem_usage: Memory usage * @core_id: Target core for the pipeline * @state: Pipeline state +* @use_chain_dma: flag to indicate if the firmware shall use chained DMA * @msg: message structure for pipeline * @skip_during_fe_trigger: skip triggering this pipeline during the FE DAI trigger */
@@ -135,6 +136,7 @@ struct sof_ipc4_pipeline {uint32_t mem_usage;uint32_t core_id;int state; +bool use_chain_dma;struct sof_ipc4_msg msg;bool skip_during_fe_trigger; };
Signature · 1 line
2.40.0
Mark Brown
maintainerQuoted 5 lines · Peter Ujfalusi
Hi,
Changes since v1:
- Fix missed mutex unlocking insof_ipc4_widget_free()Reported by Dan Carpenter (thank you!)
Please do not submit new versions of already applied patches, please submit incremental updates to the existing code. Modifying existing commits creates problems for other users building on top of those commits so it's best practice to only change pubished git commits if absolutely essential.
Mark Brown
maintainerQuoted 11 lines · Jyri
Quoted 5 lines · Mark Brown
Please do not submit new versions of already applied patches, please submit incremental updates to the existing code. Modifying existing commits creates problems for other users building on top of those commits so it's best practice to only change pubished git commits if absolutely essential.
Hi Mark,
Would a git fixup patch do at this phase, or should we do just a regular patch with
To repeat what's quoted above "please submit incremental updates to the existing code".
Péter Ujfalusi
maintainerHi Mark,
Quoted 7 lines · Mark Brown
Quoted 5 lines · Peter Ujfalusi
Hi,
Changes since v1:
- Fix missed mutex unlocking insof_ipc4_widget_free()Reported by Dan Carpenter (thank you!)
Quoted 5 lines
Please do not submit new versions of already applied patches, please submit incremental updates to the existing code. Modifying existing commits creates problems for other users building on top of those commits so it's best practice to only change pubished git commits if absolutely essential.
I'm aware of that and checked my mailbox several times that I don't have your applied notification mail. I would have sent a fix patch instead otherwise.
Sorry for the inconvenience.
Signature · 1 line
Péter
Quoted 7 lines · Mark Brown
Quoted 5 lines · Peter Ujfalusi
Hi,
Changes since v1:
- Fix missed mutex unlocking insof_ipc4_widget_free()Reported by Dan Carpenter (thank you!)
Quoted 5 lines
Please do not submit new versions of already applied patches, please submit incremental updates to the existing code. Modifying existing commits creates problems for other users building on top of those commits so it's best practice to only change pubished git commits if absolutely essential.
Hi Mark,
Would a git fixup patch do at this phase, or should we do just a regular patch with
DMA")
line?
Best regards,
Jyri
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki
Business Identity Code: 0357606 - 4
Domiciled in Helsinki
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.