Skip to contentSkip to conversation

ASoC: qcom: qdsp6: clear stale channel_map entries

PATCH In review Fabian Renn-Giles 2 participants 2 messages Oct 28

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: qcom: qdsp6: clear stale channel_map entries

Since commit c663014e452d ("ASoC: qcom: audioreach: compute active channel maps from channel_map"), the codec DMA active_channels_mask is built from the non-zero entries of the channel_map instead of from num_channels.

audioreach_set_default_channel_mapping() only writes the first num_channels entries, and q6dma_set_channel_map() only the first tx_num/rx_num entries. The per-DAI module_config in q6apm-lpass-dais is persistent, so entries written by an earlier, wider configuration survive a later narrower one. E.g. after a 4 channel setup, a 2 channel capture on VA_CODEC_DMA_TX_0 keeps the map 01 02 04 05 and sends active_channels_mask = 0xf with num_channels = 2. The DSP rejects the graph start:

qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1 q6apm-lpass-dais ...: Failed to start APM port 110 MultiMedia4 Capture: ASoC error (-22): at dpcm_be_dai_trigger()

which breaks the built-in DMIC capture on the Lenovo Yoga Slim 7x (X1E80100).

Clear the whole channel_map before filling it in both places.

Note: this is my very first contribution to the linux kernel so I may be new to some of the processes. I apologize in advance.

Fixes c663014e452d ("ASoC: qcom: audioreach: compute active channel maps from channel_map")
Assisted-by Claude:claude-sonnet-5-5

---
Tested on a Lenovo Yoga Slim 7x (X1E80100): built-in DMIC capture on VA_CODEC_DMA_TX_0 (MultiMedia4 Capture) failed with the DSP error above; with this patch repeated arecord runs work. Based on broonie/sound.git for-next (d34a818a331f).

 sound/soc/qcom/qdsp6/audioreach.c       | 6 ++++++
 sound/soc/qcom/qdsp6/q6apm-lpass-dais.c | 2 ++
 2 files changed, 8 insertions(+)
sound/soc/qcom/qdsp6/audioreach.c +6 -0
index d2dc5d37bccf..4ac65d9b5543 100644
@@ -308,6 +308,12 @@ EXPORT_SYMBOL_GPL(audioreach_alloc_apm_cmd_pkt);
 
 void audioreach_set_default_channel_mapping(u8 *ch_map, int num_channels)
 {
+	/*
+	 * The active channel mask is derived from the non-zero entries, so
+	 * stale entries from a previous, wider configuration must not survive.
+	 */
+	memset(ch_map, 0, AR_PCM_MAX_NUM_CHANNEL);
+
 	if (num_channels == 1) {
 		ch_map[0] =  PCM_CHANNEL_FL;
 	} else if (num_channels == 2) {
sound/soc/qcom/qdsp6/q6apm-lpass-dais.c +2 -0
index 83f2711bceea..12f139af8ca0 100644
@@ -99,6 +99,7 @@ static int q6dma_set_channel_map(struct snd_soc_dai *dai,
 				tx_num);
 			return -EINVAL;
 		}
+		memset(cfg->channel_map, 0, sizeof(cfg->channel_map));
 		for (i = 0; i < tx_num; i++)
 			cfg->channel_map[i] = tx_ch_mask[i];
 
@@ -123,6 +124,7 @@ static int q6dma_set_channel_map(struct snd_soc_dai *dai,
 				rx_num);
 			return -EINVAL;
 		}
+		memset(cfg->channel_map, 0, sizeof(cfg->channel_map));
 		for (i = 0; i < rx_num; i++)
 			cfg->channel_map[i] = rx_ch_mask[i];
 

base-commit: d34a818a331f7e270fa9dc3db3d96f6a0d4fa7ab

Signature · 1 line
2.55.0
#1 lore raw
Quoted 18 lines · Fabian Renn-Giles

Since commit c663014e452d ("ASoC: qcom: audioreach: compute active channel maps from channel_map"), the codec DMA active_channels_mask is built from the non-zero entries of the channel_map instead of from num_channels.

audioreach_set_default_channel_mapping() only writes the first num_channels entries, and q6dma_set_channel_map() only the first tx_num/rx_num entries. The per-DAI module_config in q6apm-lpass-dais is persistent, so entries written by an earlier, wider configuration survive a later narrower one. E.g. after a 4 channel setup, a 2 channel capture on VA_CODEC_DMA_TX_0 keeps the map 01 02 04 05 and sends active_channels_mask = 0xf with num_channels = 2. The DSP rejects the graph start:

qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1 q6apm-lpass-dais ...: Failed to start APM port 110 MultiMedia4 Capture: ASoC error (-22): at dpcm_be_dai_trigger()

Quoted 7 lines

which breaks the built-in DMIC capture on the Lenovo Yoga Slim 7x (X1E80100).

Clear the whole channel_map before filling it in both places.

Note: this is my very first contribution to the linux kernel so I may be new to some of the processes. I apologize in advance.

Thanks for sending the patch and Welcome.
You can move this comment after --- as it does not make sense to be in the commit log.

Quoted 19 lines
Fixes c663014e452d ("ASoC: qcom: audioreach: compute active channel maps from channel_map")
Assisted-by Claude:claude-sonnet-5-5

---
Tested on a Lenovo Yoga Slim 7x (X1E80100): built-in DMIC capture on VA_CODEC_DMA_TX_0 (MultiMedia4 Capture) failed with the DSP error above; with this patch repeated arecord runs work. Based on broonie/sound.git for-next (d34a818a331f).

 sound/soc/qcom/qdsp6/audioreach.c       | 6 ++++++
 sound/soc/qcom/qdsp6/q6apm-lpass-dais.c | 2 ++
 2 files changed, 8 insertions(+)
sound/soc/qcom/qdsp6/audioreach.c +0 -0
index d2dc5d37bccf..4ac65d9b5543 100644

sound/soc/qcom/qdsp6/audioreach.c EXPORT_SYMBOL_GPL(audioreach_alloc_apm_cmd_pkt); · line 309

Quoted 2 lines
sound/soc/qcom/qdsp6/audioreach.c +0 -0
@@ -308,6 +308,12 @@ EXPORT_SYMBOL_GPL(audioreach_alloc_apm_cmd_pkt);
 
 void audioreach_set_default_channel_mapping(u8 *ch_map, int num_channels)

there is patch on the list to remove this function, could you please take a look at
https://lore.kernel.org/all/[email protected]/

q6dsp_map_channels() already does the memset, pl recheck with that patch.

If your patch might be still relevant, please send patch against it.

--srini

Quoted 32 lines
sound/soc/qcom/qdsp6/audioreach.c +6 -0
 {
+	/*
+	 * The active channel mask is derived from the non-zero entries, so
+	 * stale entries from a previous, wider configuration must not survive.
+	 */
+	memset(ch_map, 0, AR_PCM_MAX_NUM_CHANNEL);
+
 	if (num_channels == 1) {
 		ch_map[0] =  PCM_CHANNEL_FL;
 	} else if (num_channels == 2) {
sound/soc/qcom/qdsp6/q6apm-lpass-dais.c +2 -0
index 83f2711bceea..12f139af8ca0 100644
@@ -99,6 +99,7 @@ static int q6dma_set_channel_map(struct snd_soc_dai *dai,
 				tx_num);
 			return -EINVAL;
 		}
+		memset(cfg->channel_map, 0, sizeof(cfg->channel_map));
 		for (i = 0; i < tx_num; i++)
 			cfg->channel_map[i] = tx_ch_mask[i];
 
@@ -123,6 +124,7 @@ static int q6dma_set_channel_map(struct snd_soc_dai *dai,
 				rx_num);
 			return -EINVAL;
 		}
+		memset(cfg->channel_map, 0, sizeof(cfg->channel_map));
 		for (i = 0; i < rx_num; i++)
 			cfg->channel_map[i] = rx_ch_mask[i];
 

base-commit: d34a818a331f7e270fa9dc3db3d96f6a0d4fa7ab