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=1795062118; b=L130+0wx3d++6xT1tCVyLI3PmzhWDGuoSrszt+5s9CheVSUFUDob+eQoZk8tf0iDF8Kr 2lG0Gb3BIkPQRce3IruZ2iLcXhLmfKXrw9/OSDHNylavuseoNB7Pjx9Xw/3rTzV++I9b4 fil8IUSuSzHsi/yTXnvnqZ/ZsfUAcPQOgSjjOJ+CYi2duaTe+PAAIUtEzgc+klNLdlbZt 9dPryOIzGDij6gJmuSwUfC9bK1rtHem07/BG4++hxjuw529LgWqMvkG/g/9BlreZaeoU5 8Vzb2PYxVWMCXWBUGisK2vnu5K+LrWxF1rk4BK8jKxYOeLruvAegcCFi9GyzLKrfoQQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795062118; 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=IWZF+cRhImMY01o8pzL54uLhYfzJyXpTOAvqUvlRVPw=; b=LaR6vvvIwNY6889FwfEsFbtHmiuDTZXBFQrrXjqb6FJWI9wt4ifAQGgMvZliSP3FxVAI FDCbbrHZ30wgVkEK+R4gCixy8SfSjHA9QMpcdUIeNmN4/cTATURBm4HjzCeulLYt/xUlF ONja/2gkawh3XXsJAqzdqeWZq1FdyviM9q7u8499xCMZpYAK/1uHGxW85EYD6VG8BnHVy 5MTkDK+B/X3Uw/0q+K9UvqzxYl6V1q9lbM2N+I87Xamt9NjehsfdHx3bSJEHK1++Glbp1 za7dalUcv3/1oxz9bmdORN7KECqKc9DIXdrjlF4FSDFACGI3q93+E6NUi/DeEwIRQpw== 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=wzVq0RUG; 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 DA260606A32A; Thu, 19 Nov 2026 04:21:58 +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=wzVq0RUG Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DF071F000C4; Thu, 19 Nov 2026 04:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795062118; bh=IWZF+cRhImMY01o8pzL54uLhYfzJyXpTOAvqUvlRVPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wzVq0RUGScsaSEKoI19FlW3DjGQXKGcLZXqU79wPz1Psq++0aDzTLJk+nTCvcrlfk 6i13ssFosVsDyw+Qfa49pWGmaTAsnvRDDwVGS99CmtPkh0BLwQ1IscNu6a5KrkiXKS 6274pdDO3rfIyxxhlC0FhdekNZy+P3EDQ2V1BUkM= 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 5.10 1796/1848] ASoC: xilinx: formatter_pcm: Fix read-modify-write of AUD_CTRL in hw_params Date: Wed, 18 Nov 2026 16:03:54 +0100 Message-ID: <20261118150034.456955954@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118145911.150052362@linuxfoundation.org> References: <20261118145911.150052362@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 5.10-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 74a7c8e5998df..d0d1d17dadd63 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