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=1796383033; b=18g4FrjobwaHBvgg5OHbLWK1Ibz1KJk7zDrWBM+Bk0WqBev/hsCFiZMxuGX8jMHh3p/A 12ojcdLhyOHLln5w/cVJcuf36FRcog5Ep3uAimAljCZ3LVrQsd+NAeVDQehKgwsg6vHlz n6ku6mbL+3WI0eZIJMxjiAjXGSxXkeFbUNJBYkBo/xw8OCjQZdKFlnaH5gSbYo9VVgtZL TTAbSx8wV1E+/gzTAj8SpOJSIhD8Jq12AjE+9BA4r3wuwg5TyFWvUC261UMl6Fj6BPEl5 1I8m6hslpfnBIuRJvfQSzaY82PAbuVln9s8prxrLPxNV94/+L0bDB/XeVHKLHqwkc/Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383033; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=9FQgSC7ISDhq8AMOfwuYg8NUiWY7dtGJio7MGZaWNOs=; b=LE0AS1xr24y8x0A6rrLwtc46m7kHkmU94cFit/6X72iozYOZCg3XmwvWFgRsKUwb1CDw nVk/vHzDJpMZjBvGrxJKdh7nm4IifUQFtxuTOVJOXPsAX0v9zv74SbiLgg0iNpNhHKlDP QCCFLzZKg36b8A7YzpdA444yM1WsMoZgZnkkcEHJXoBxsNmI8o8Y54cUTqZJsAUbY5Ahs Ykahy9Dz+5FIt6SZmFEiHxMw+iaDI+joxnRxgCxPP/W2iCK/tSBO6uGt8IQcdTnCNssmv xKEqXJsi1Fx0uqk0vZzXU7rHk/cXZgoiz0c90OtYIhqB7j8RW5MJh7MwyFgEwT81j1A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=sjcO5KbO; 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 D2E07606A330; Fri, 4 Dec 2026 11:17:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=sjcO5KbO Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F5DA1F00931; Fri, 4 Dec 2026 11:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383033; bh=9FQgSC7ISDhq8AMOfwuYg8NUiWY7dtGJio7MGZaWNOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sjcO5KbOQnqituzAwxJKVB5WYXSgrhlcvws3L5/ARWAE9wM0VToVnj3YO5jbbOwZM g8+9ahAMA1XtGXjzerQ/A6op8U7jz1SjFIwNABmWZj/+LhKu/pGAGLO4CDgLvTDozD YxEHC0RxVLkJYDw2C0ZpOl5yMjuPluD3s7p04q+g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Srinivas Kandagatla , Marc Herrero , Mark Brown , Sasha Levin Subject: [PATCH 6.18 698/703] ASoC: qcom: audioreach: use a 32-bit container for S24_LE PCM Date: Fri, 4 Dec 2026 19:09:57 +0900 Message-ID: <20261204100646.412213652@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ 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 PCM hunk to the older context, keeping the existing single memcpy for channel mapping instead of the newer logical-mapping loop. ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- sound/soc/qcom/qdsp6/audioreach.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -1143,7 +1143,12 @@ static int audioreach_pcm_set_media_form 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); @@ -1197,7 +1202,8 @@ static int audioreach_shmem_set_media_fo 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;