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=1795033028; b=hbQ1Y6M6BQ3Mr7dq8SJOLtI/UU5Luue4+ApoKVmLtakl/DEoEivN+oayW7cwdTE0EDjo J0ga2kSdnwsrq/M78tLtYtEGc/GfdnVlk6tRuk47B3XLxk3vGI1eDCvpn6vGY5beKGZHY Hpk0nElQCgSGWB7WFOfE9wOmuAcAiandrfgv7J68vMqAM5M9QQVvFC5QcAxmSm+NFt3GQ O8ciPzjUsk2AEdDBKZp2qCn0iUEuX+iYUjS8KvQDmcEQxvhi/SJ06y39XT/ElKRoTQQs8 19yfQpAF76IWD/KnadP0T+csdXRycuJ4H+Uvi9Ycvwoz1rCLe8s5NwNarXxBBjqlfpA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795033028; 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=ErZqnGCcv4P6Rv3Pm7wjk8Es6GJg0oJ8iN4IKOhJUMg=; b=AeKyjfPTuSLZuIG+3mMA0GwA4c10v3d6iAkzb4lamdcrs2vFoXt/XaAWPZuutY2RFXRg ICkuPWc/TUX4EbDSufH9PwgSgq8VFuAS4Fa+0jMRJsGPVyatTbeIbgozf4WEzGKjn/zE8 HDnSPpAT7ZJcQlI6phG9mCp8+WJZjf2hppkgdZWDH0BO1M1z+dFmvJrbWsRGCdjP1kmGZ rLXzSbSvlGrM9TqcdQKLTauhfSnlmtsjh0Oe9XKMQ3F9457QpiVsko355ro2v08T4onI1 VIO9Ya/oZXUrqHyX2WlDghtn4fhgNVOITqO2RZ316x5v/oK1l/Z3wqrIm8dZ4XcYDkg== 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=QhUyiECf; 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 73D6C606A31C; Wed, 18 Nov 2026 20:17:08 +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=QhUyiECf Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB8221F000C4; Wed, 18 Nov 2026 20:17:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795033028; bh=ErZqnGCcv4P6Rv3Pm7wjk8Es6GJg0oJ8iN4IKOhJUMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QhUyiECfv4AExdY/BnvZ1s0my6CpFgHJsE5VHzHgBDdtyXgCB3AVDbk339mxr5g4c JK89NpKQBDSFLcnDtm4RHh2Qkrr7ssnxdomLiwTyVHe8hH6EcLm7OrpdtYFfQMKppu BroziyLu9h74+VmgxNpmfajqKOFexeOIRQBvfKt4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, bui duc phuc , "Gaddipati, Naveen" , Mark Brown , Sasha Levin Subject: [PATCH 6.12 1622/1756] ASoC: xilinx: formatter_pcm: Fix read-modify-write of AUD_CTRL in hw_params Date: Wed, 18 Nov 2026 16:02:29 +0100 Message-ID: <20261118150114.395694779@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150007.957976754@linuxfoundation.org> References: <20261118150007.957976754@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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: bui duc phuc [ Upstream commit 3b54e739273752b370e49b09976da152fa3b802c ] xlnx_formatter_pcm_hw_params() does a read-modify-write on XLNX_AUD_CTRL but only ORs in the new data width and active channel values without clearing the old ones. If hw_params is called more than once on an open stream, these fields may retain bits from the previous configuration, resulting in an incorrect sample width or channel count. Clear both fields before writing the new values, and use FIELD_PREP() so the values cannot spill into neighbouring bits. Fixes: 6f6c3c36f091 ("ASoC: xlnx: add pcm formatter platform driver") Signed-off-by: bui duc phuc Reviewed-by: Gaddipati, Naveen Link: https://patch.msgid.link/20261023102818.523331-1-phucduc.bui@gmail.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/xilinx/xlnx_formatter_pcm.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sound/soc/xilinx/xlnx_formatter_pcm.c b/sound/soc/xilinx/xlnx_formatter_pcm.c index 4d90e96a677c9..0f7cb911eb4e3 100644 --- a/sound/soc/xilinx/xlnx_formatter_pcm.c +++ b/sound/soc/xilinx/xlnx_formatter_pcm.c @@ -6,6 +6,7 @@ // // Author: Maruthi Srinivas Bayyavarapu +#include #include #include #include @@ -57,8 +58,8 @@ #define CFG_S2MM_XFER_SHIFT 29 #define CFG_S2MM_PKG_MASK BIT(28) -#define AUD_CTRL_DATA_WIDTH_SHIFT 16 -#define AUD_CTRL_ACTIVE_CH_SHIFT 19 +#define AUD_CTRL_DATA_WIDTH_MASK GENMASK(18, 16) +#define AUD_CTRL_ACTIVE_CH_MASK GENMASK(22, 19) #define PERIOD_CFG_PERIODS_SHIFT 16 #define PERIODS_MIN 2 @@ -509,28 +510,29 @@ static int xlnx_formatter_pcm_hw_params(struct snd_soc_component *component, writel(high, stream_data->mmio + XLNX_AUD_BUFF_ADDR_MSB); val = readl(stream_data->mmio + XLNX_AUD_CTRL); + val &= ~(AUD_CTRL_DATA_WIDTH_MASK | AUD_CTRL_ACTIVE_CH_MASK); bits_per_sample = params_width(params); switch (bits_per_sample) { case 8: - val |= (BIT_DEPTH_8 << AUD_CTRL_DATA_WIDTH_SHIFT); + val |= FIELD_PREP(AUD_CTRL_DATA_WIDTH_MASK, BIT_DEPTH_8); break; case 16: - val |= (BIT_DEPTH_16 << AUD_CTRL_DATA_WIDTH_SHIFT); + val |= FIELD_PREP(AUD_CTRL_DATA_WIDTH_MASK, BIT_DEPTH_16); break; case 20: - val |= (BIT_DEPTH_20 << AUD_CTRL_DATA_WIDTH_SHIFT); + val |= FIELD_PREP(AUD_CTRL_DATA_WIDTH_MASK, BIT_DEPTH_20); break; case 24: - val |= (BIT_DEPTH_24 << AUD_CTRL_DATA_WIDTH_SHIFT); + val |= FIELD_PREP(AUD_CTRL_DATA_WIDTH_MASK, BIT_DEPTH_24); break; case 32: - val |= (BIT_DEPTH_32 << AUD_CTRL_DATA_WIDTH_SHIFT); + val |= FIELD_PREP(AUD_CTRL_DATA_WIDTH_MASK, BIT_DEPTH_32); break; default: return -EINVAL; } - val |= active_ch << AUD_CTRL_ACTIVE_CH_SHIFT; + val |= FIELD_PREP(AUD_CTRL_ACTIVE_CH_MASK, active_ch); writel(val, stream_data->mmio + XLNX_AUD_CTRL); val = (params_periods(params) << PERIOD_CFG_PERIODS_SHIFT) -- 2.53.0