Re: [PATCH v7 13/13] ASoC: qcom: q6apm: Add support for early buffer mapping on DSP
From: Srinivas Kandagatla
Date: Wed Mar 25 2026 - 07:55:37 EST
On 3/24/26 7:09 PM, Mark Brown wrote:
> On Mon, Mar 23, 2026 at 10:38:45PM +0000, Srinivas Kandagatla wrote:
>> Buffers are allocated on pcm_new and mapped in the dsp on every
>> prepare call, which is inefficient and unnecessary.
>>
>> Add new functions q6apm_[un]map_memory_fixed_region to map it on
>> to dsp only once after allocation.
>
>> static int q6apm_dai_pcm_new(struct snd_soc_component *component, struct snd_soc_pcm_runtime *rtd)
>
>> + if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
>> + substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
>> + ret = q6apm_dai_memory_map(component, substream, graph_id);
>> + if (ret) {
>> + if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream)
>> + q6apm_unmap_memory_fixed_region(component->dev, graph_id);
>
> This looks like it's handling bidirectional DAIs but...
TBH, we only have one dai and one direction per graph, this check was
added for completeness.
We can not have bi-directional dais, as all the be-dais are uni-directional.
>
>> +int q6apm_map_memory_fixed_region(struct device *dev, unsigned int graph_id, phys_addr_t phys,
>> + size_t sz)
>> +{
>
>> + info = idr_find(&apm->graph_info_idr, graph_id);
>> + if (!info)
>> + return -ENODEV;
>> +
>> + if (info->mem_map_handle)
>> + return 0;
>
> ...we have one memory map handle per graph ID, silently ignoring
> attempts to add a second one?
there is no second one.
--srini