Re: [PATCH v3 3/3] ASoC: qcom: q6apm-dai: add SCM buffer assignment for mDSP platforms

From: Rob Herring

Date: Fri Sep 18 2026 - 17:23:01 EST


On Fri, Sep 18, 2026 at 07:19:37PM +0530, Ajay Kumar Nandam wrote:
> On platforms such as Qualcomm Shikra, audio is served by the modem DSP
> (mDSP) which runs in a stage-2 protected context. Unlike ADSP targets
> where SMMU-mapped system RAM is directly accessible, the mDSP cannot
> reach the PCM buffers unless they are explicitly SCM-assigned to the
> appropriate Virtual Machine IDs (VMIDs). Without this assignment, audio
> does not function on these platforms.
>
> At probe time, the driver reads the GPR domain_id from the parent APM
> device to determine which DSP serves audio. When domain_id matches
> GPR_DOMAIN_ID_ADSP the existing SMMU/iommus path is taken and no new
> code is exercised. When domain_id matches GPR_DOMAIN_ID_MODEM, the
> driver verifies that qcom_scm is available (deferring otherwise) and
> that iommus is absent (the two mechanisms are mutually exclusive), then
> enables the SCM assignment path.
>
> In the SCM path the driver parses the optional memory-region entries in
> DT. The first entry (memory-region[0] / audio_heap_mem) is the
> control-path carveout used by the DSP firmware for command traffic; since
> the mDSP operates on stage-2 protected memory, this carveout must be
> SCM-assigned at probe time itself for the firmware to function. It is
> SCM-assigned to HLOS (retained as source owner, RW) plus MSS_MSA and
> LPASS (consumer VMIDs, both RW) and restored to HLOS-only ownership via
> devm_add_action_or_reset() at device removal. The second entry
> (memory-region[1]) is the data-path buffer pool from which per-stream
> DMA buffers are carved out. This pool is attached via
> of_reserved_mem_device_init_by_idx() so that PCM buffers allocate
> directly from the carveout instead of system RAM. Individual buffer
> slices are SCM-assigned in pcm_new() after allocation and unassigned in
> pcm_free(), so only the actively used slices are shared with the modem
> and unused carveout memory remains HLOS-owned.
>
> The VMIDs are static per SoC and hardcoded in the driver (HLOS, MSS_MSA,
> LPASS) rather than read from DT, following the upstream pattern used by
> rmtfs_mem and qcom_q6v5_pas. Buffer constraints are capped at
> reserved_buf_size when the data-path pool is present, and
> snd_pcm_set_fixed_buffer_all() is used for both paths so the carveout is
> not subject to the preallocate_dma module parameter.
>
> The DT binding is updated to add an optional memory-region property (1-2
> entries) and to make iommus optional (removed from the required list),
> since mDSP platforms have neither IOMMU nor VMID DT properties.
>
> All new code paths are gated on use_scm_assign (false when domain_id is
> not GPR_DOMAIN_ID_MODEM), ensuring existing ADSP/iommus targets are
> completely unaffected.
>
> Signed-off-by: Ajay Kumar Nandam <ajay.nandam@xxxxxxxxxxxxxxxx>
> ---
> .../devicetree/bindings/sound/qcom,q6apm-dai.yaml | 12 +-

Bindings are separate patches. Run checkpatch.pl, it will tell you this.

> sound/soc/qcom/Kconfig | 1 +
> sound/soc/qcom/qdsp6/q6apm-dai.c | 260 +++++++++++++++++++--
> 3 files changed, 252 insertions(+), 21 deletions(-)