From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796324824; b=MkpW1UDPHSukptI3AcQ12+fSO1YJ8wDsP/XE/QMEp6dPw15bJshQatPrp6tf7KKPo7go QJVJg8lr/6aKuBuXIkkopkWhAWPZxY+NGaGzWpXOSc+HLJ5EhAyM5zgTt5+QxDGFOKZgH OzPbfmLVN0TlSTFizo1AtMjExSMfSQM9n9D5d0URHDJxF8B7iZEXqQSBNYpIaCfytO4dq rlChBBa75zYDqMjR3uClEXC8IviwptC9LLNAyt0Yvv+aDEvrZzgRzmgzDZRGABg1BCBcy RrXIphz5Qorwq2t1wQ+1+Uvwm/poVYf+2/JrMrUv/QowSqNbmYBH1WEm/Zhd9rCz/Mg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796324824; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=aUyBxwy/HwM/CW+SM2wq7fIw7x8TnW47IyZMINjCOvE=; b=mOpx/vWEqgWlDysUMB2XwsuhGWqIWGa8dLyzRfsLegiWifzvSXZPA8vm9aW3tZC3t/O8 73gnlK0g8SV+X2EuEZpqI3dRdxzvGR1lS/SMr7AC82Ty1TBwjqXusRk+WebhRBCwFhDxu v92zferdE4OL0y91pHU1m3oNnEawi+z66AKLkT3NQaxEp2w2NWDJ8aiC1PPrCfbfKJ5I6 hSfu9cOpbM/v2EvDTQVs+jHg4rPYclE+HI+BrSw++gF4Qs11w6hQM3rjax5WnHMBwgc2q kx81TUplBHar7pPBc0hfHkj8L8M7HbS7s3z95PoUQ+r9h14wNzy/HeYtAXTdg/2uiAg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="d/UmW3Si"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E644606A330 for ; Thu, 3 Dec 2026 19:07:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=d/UmW3Si Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DADF1F000CE; Thu, 3 Dec 2026 19:07:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796324824; bh=aUyBxwy/HwM/CW+SM2wq7fIw7x8TnW47IyZMINjCOvE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=d/UmW3SiEU3Y5wJzF/NgaqjJjEKbOJcJSFxzciBCt4w3SQ1kc2fA/OPlgQht3tfBi 5SL7EOlwIvFLzgLjaqkPuIYp+JlTOBHxIVDGtvv3KxVgcaUI6S7akkMfX2UA6fgr09 TBeH6B2mz40oEIGsAMqbeepXn1JRdcbO9EtnIX53hTAX+8iLr16mAL+tRTVDmt2Jtn fs5cSSzCyuAJvz1uA/PX1vIpyLJJrEGpy7+LFOaxV5ryTESlf4tbDzt8OqY++IXNS7 vpAZgIYrvvaBc9gSH3k5MqoqDPIx0WOI232+OIguNBuDHoomjkKbU4CXS7wzd5LURr Aqfcv2+j3jNuQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Marc Herrero , Srinivas Kandagatla , Mark Brown , Sasha Levin Subject: [PATCH 6.12.y] ASoC: qcom: audioreach: use a 32-bit container for S24_LE PCM Date: Thu, 3 Dec 2026 14:07:01 -0500 Message-ID: <20261203190629.596850-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120224-feeble-fit-4dd8@gregkh> References: <2026120224-feeble-fit-4dd8@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Marc Herrero [ Upstream commit feb416ba626e95b12fc238587f8fee93cae66c9c ] SNDRV_PCM_FORMAT_S24_LE carries 24 valid bits in a 32-bit container, but audioreach_shmem_set_media_format() and audioreach_pcm_set_media_format() set bits_per_sample = bit_width = 24 in PARAM_ID_MEDIA_FORMAT and PARAM_ID_PCM_OUTPUT_FORMAT_CFG, which tells the DSP that the samples are packed 3-byte words. q6apm-dai advertises S24_LE, so with a topology that allows it on a playback front end the DSP walks the buffer with the wrong stride. On QCS6490 (Radxa Dragon Q6A) this crashes the ADSP audio_process: PDM: service 'audio_process' crash: 'EX:audio_process:0x2:...' q6apm-lpass-dais ...: Failed to start APM port 113 remoteproc remoteproc0: crash detected in adsp: type fatal error Use the container size (32) for 24-bit data and keep bit_width = 24, alignment = PCM_LSB_ALIGNED and q_factor = 23. With this change S24_LE playback works on the headphone path (codec DMA RX -> LPASS RX macro -> WCD9385), tested with the back end at S16_LE, S24_LE and S32_LE and at 48, 96 and 192 kHz. The DSP then reads each 32-bit word as Q23, so S24_LE samples must be sign-extended into the top byte, as alsa-lib's conversions do. Fixes: 25ab80db6b13 ("ASoC: qdsp6: audioreach: add module configuration command helpers") Cc: stable@vger.kernel.org Reviewed-by: Srinivas Kandagatla Signed-off-by: Marc Herrero Link: https://patch.msgid.link/20261116-q6apm-fixes-v2-1-ea89fb43316a@proton.me Signed-off-by: Mark Brown [ sashal: adapted the context lines because the surrounding code lacks the channel-mapping loop and uses a simple memcpy of the channel map instead ] Signed-off-by: Sasha Levin --- sound/soc/qcom/qdsp6/audioreach.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c index 3f5eed5afce55..edf3837aac98f 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -1092,7 +1092,12 @@ static int audioreach_pcm_set_media_format(struct q6apm_graph *graph, media_cfg->interleaved = module->interleave_type; media_cfg->num_channels = mcfg->num_channels; media_cfg->q_factor = mcfg->bit_width - 1; - media_cfg->bits_per_sample = mcfg->bit_width; + /* + * bit_width is the number of valid bits in a sample, bits_per_sample + * the size of the container it is stored in. S24_LE keeps 24 valid + * bits in a 32-bit container, so it is 24/32, not packed 24/24. + */ + media_cfg->bits_per_sample = mcfg->bit_width == 24 ? 32 : mcfg->bit_width; memcpy(media_cfg->channel_mapping, mcfg->channel_map, mcfg->num_channels); rc = q6apm_send_cmd_sync(graph->apm, pkt, 0); @@ -1146,7 +1151,8 @@ static int audioreach_shmem_set_media_format(struct q6apm_graph *graph, cfg->sample_rate = mcfg->sample_rate; cfg->bit_width = mcfg->bit_width; cfg->alignment = PCM_LSB_ALIGNED; - cfg->bits_per_sample = mcfg->bit_width; + /* S24_LE: 24 valid bits in a 32-bit container, see above */ + cfg->bits_per_sample = mcfg->bit_width == 24 ? 32 : mcfg->bit_width; cfg->q_factor = mcfg->bit_width - 1; cfg->endianness = PCM_LITTLE_ENDIAN; cfg->num_channels = mcfg->num_channels; -- 2.53.0