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=1796390740; b=IB3eSSW6F8c/SHt4GXcfZhsXmDxUiDmvZmclv2vDpFIJ3w9Cbo/fC6LmI+pPaqVFpEmg ndgUSNrJrtixNouAg6DBr1rkQDnHYutVSsFX+qh3BhZMXIYG9MF7j8QvqtC8LZQ1k58f0 sJ3CA8V1D6kanvfipB4nnDEC3QS2pOoS+ZYoJp9a4P9hOaNMb5T7z5KZkCO9WoAWwFv8k bU9TeKY4taRygkowAhSOF6k+wab6mHO8YIk7UFtxxDUelEQceiuQo6Ap5+oZ/bGtzd8tw U4iY+kmPzqRFoH3jBl/Mxms2kxhn0fi8eLJcAqcl5E5/VLlvL6aoY8ncT2hcNsWEfGQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796390740; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=UZGC52A0dmaF/liszf2fO8PHPylTy8soLOhwEE8Enpk=; b=N29wgbiEEeYQnOrrlhuU2wDT4z6nW0LzZMug4QD+cQKf169j3L/ya9MoLnjt+SB5tcvb tMrYnxn+qFVN01hHD1BpuCWFBItlX+sCg3sH1RdjQrl+F4lfIVid0n8bq4RJSuSwV81Kn X17vGlQ54hsQI5jbgiB4bl3vh4Qxw0Xh+kjrfi8OQOGGfGwBnvXg18DZIwM1DJN2aV6++ jczBwZBk7kpxiMRFCaENqONQAM7gWfTNX/8jGdi4D5GwPbpxLlaw0S7y/6OSu08yeq6Mi dwar9hhBOMHu17zaoVmOSllfFV8e8drttmqLKpXAe2dBxL+3SrOt+AtzsdYzteGpdRA== 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=epFQCGtu; 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 70F47606A685 for ; Fri, 4 Dec 2026 13:25:40 +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=epFQCGtu Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EC451F0092C; Fri, 4 Dec 2026 13:25:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796390739; bh=UZGC52A0dmaF/liszf2fO8PHPylTy8soLOhwEE8Enpk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=epFQCGtuWxYDwuukGgSLJ3kvHHfytLuGSsG1mTmE8Iintpt0D2s+WpXtEBfM7zs9u jGUY8+CtmKB87o8h3MNnveQBJTcbcvT5F2ap23t18FXAkubqAbacanoivgjpkuN+Ws zNXMgHI6jFL8xkw3kK9xWvfItRZrco9pNca3aOMIXWRIu19/FpDM5QTQrM6HnQ0fD4 XlAdId1bhMOSOTyfjU9siOx4v8Fba0aFXHSGqfwxhs3LyygK7FuKgMPXgdPRTqBz1G TOVoJ0skl1RwVqE6sgX1c4nyMaCi4liqLKFkuNSI19Xj6dVihryBiYPUfnaCoJ/uCz llAbR7IG+qIgA== From: Sasha Levin To: stable@vger.kernel.org Cc: Hengyu Liang , Takashi Iwai , Sasha Levin Subject: [PATCH 6.12.y 2/2] ALSA: pcm: oss: Refine slave hw_params after setting format Date: Fri, 4 Dec 2026 08:25:36 -0500 Message-ID: <20261204132529.3144338-2-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261204132529.3144338-1-sashal@kernel.org> References: <2026120327-shelf-earwig-cafa@gregkh> <20261204132529.3144338-1-sashal@kernel.org> 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: Hengyu Liang [ Upstream commit ddea524e437eae0d5581482a90565b4c1e6d4b24 ] Commit 93d7d38fa61d ("ALSA: aloop: add DSD formats") added DSD_U8 to the formats of snd-aloop. Before that, its narrowest format had 16 bits. However, snd_pcm_oss_change_params_locked() sets the slave format with _snd_pcm_hw_param_set(), which does not refine the parameters, while the access, rate and channels before it are set with refining helpers. snd_pcm_oss_period_size() then reads a buffer size maximum that is still computed for the narrowest format, now DSD_U8, so the OSS period doubles. With the default U8 client format, the doubled period no longer fits in the format plugin, and snd_pcm_plugin_alloc() returns -ENOMEM. As of now, an OSS program that asks snd-aloop for 8 channels at 192 kHz gets ENOMEM from SNDCTL_DSP_SPEED and from every later ioctl on the same file. The issue can be reproduced with this program, where card 1 is snd-aloop: #include #include #include #include int main(void) { int fd = open("/dev/dsp1", O_WRONLY | O_NONBLOCK); int ch = 8, rate = 192000, blk = 0; ioctl(fd, SNDCTL_DSP_CHANNELS, &ch); if (ioctl(fd, SNDCTL_DSP_SPEED, &rate) < 0) perror("SNDCTL_DSP_SPEED"); if (ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &blk) < 0) perror("SNDCTL_DSP_GETBLKSIZE"); printf("block size %d\n", blk); return 0; } Before that commit, it prints "block size 65536". After that commit, the result is: SNDCTL_DSP_SPEED: Cannot allocate memory SNDCTL_DSP_GETBLKSIZE: Cannot allocate memory block size 0 This patch will set the format with snd_pcm_hw_param_set(), which refines the parameters, as is done for the channels just before. Fixes: 93d7d38fa61d ("ALSA: aloop: add DSD formats") Cc: Signed-off-by: Hengyu Liang Link: https://patch.msgid.link/20261125181005.3683575-1-hengyul@cs.unc.edu Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/core/oss/pcm_oss.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 4e8fdfdedbd01..d0f7a7ca8a221 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -919,7 +919,8 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream) goto failure; } format_found: - err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, sformat, 0); + err = snd_pcm_hw_param_set(substream, sparams, + SNDRV_PCM_HW_PARAM_FORMAT, sformat, 0); if (err < 0) goto failure; -- 2.53.0