Re: [RFC PATCH 01/23] ASoC: soc-core: allow default ch_maps on links with more than 8 DAIs

From: Srinivas Kandagatla

Date: Sun Nov 15 2026 - 16:04:38 EST


On 11/15/26 5:36 PM, Mark Brown wrote:
>> snd_soc_compensate_channel_connection_map() builds the default channel
>> map from static 8-entry arrays and fails the card for links with more
>> DAIs. A speaker protection link carrying both the amplifier and the V/I
>> sense codec DAIs of four speakers has about sixteen.
>>
>> Keep the static arrays for links that fit, and allocate a per-link map
>> with the same 1:1, 1:N or N:1 layout for those that do not.
>
>> @@ -915,20 +915,40 @@ static int snd_soc_compensate_channel_connection_map(struct snd_soc_card *card,
>
>> + if (dai_link->num_cpus <= MAX_DEFAULT_CH_MAP_SIZE &&
>> + dai_link->num_codecs <= MAX_DEFAULT_CH_MAP_SIZE) {
>
>> + } else {
>> + int num_maps = max(dai_link->num_cpus, dai_link->num_codecs);
>> + ch_maps = devm_kcalloc(card->dev, num_maps, sizeof(*ch_maps),
>
> This is a dynamic allocation bound to the card's device but it ends up
> in the dai link which might be stored as static data in the machine
> driver and get reused on a rebind.

I missed that, am thinking of moving away from static entires and make
everything dyamic and add devm_action should set the ch_maps to NULL
which will make sure snd_soc_compensate_channel_connection_map gets
reallocated on rebind. This also makes it more consistent with the way
machine drivers allocate ch_maps too.

--srini


>