Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1876480lql; Wed, 13 Mar 2024 10:29:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVi2SeZnhs5SL68WexIY+3MVbsGclKtCG8uTR97K9H//AIqOjc9sFCzA+Z3ZQBhIaCKEwQ0OWMzZ4NBIZaLcOhq9YW3xPYoGdVxf0bbgQ== X-Google-Smtp-Source: AGHT+IEJ2JI6TwIeVan4w0X8trZ8pQ+5dTfpqNn2cVzS4FmMSMcwcqpWwA5O0Mqgckdza//tnOxn X-Received: by 2002:a05:6a20:3d06:b0:1a3:1276:1c38 with SMTP id y6-20020a056a203d0600b001a312761c38mr9539924pzi.12.1710350995410; Wed, 13 Mar 2024 10:29:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710350995; cv=pass; d=google.com; s=arc-20160816; b=j6R0mS2wD+KWHwksfvYrGgjTC3mTTmHSOl1yaB3i8BYBO/QQ2wX34no707WfB/p1Y5 J+XCr4374OWVcYul6Tt3fILq8TZJwXybnlF9EUntB1NPQYf69+t04neRiWTxAJfJ9oJm g6nJpbmvPSDiPF4ILi552gDJCDqnbt7gWWPVy9gti7xiklWv6gGgFzwG8wvU6yondoQ8 Bi2WCJXIFmAN2/uAhnEeUkfW0mn1iRJX2/Gl5ha0rmmaX/RZNxyFhV6wiqaH53eH5IeN UGdjEE1IZ9VZ0S/CINQbmWdyOEpldLF+nDkG7E0VECVduL55QmYCQ/Y/wZV8ej8h44Ik 6DIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=yI3guxzd19SuFf24D3pnJdt3V7Vqph/Shc+gqi9Hcwg=; fh=p1vo092rd9DTwwJMoZGUEmNKdg+L/EaoO/9sIfia0Tw=; b=uhlMgYrrekoSvUvXVDJ4IGFZUFGvhB1nbpuhKmDdlUPhW96XhSvWaLqV2qntM3mapX 3RgmN24A2uHs1DTsmsjjx6oziyJSrjW+P9i6fchHGwKzuHthyeFFmmY3aV0uazGxL3hW /69xVoD32gL+FqlfvbYt/mZYHbPsbXnjVZYff/a7pDEZMb/qw5IyPySG7KNVUZBJ/39P If7rpv6TMgkr6RSYzmCRRwkw9Kp4MLaFfNXDyPHPm4Ry5r/+IcaDHXtbivcuEvFncODk ta0WwAwBC/9o+ORdLS3eiQGst4Dup9VZgpftEm9Y0bNEPH+1kouY4Wp7udMJXAtkWeK1 M/Hg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ozhXXXKV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101969-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101969-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bw18-20020a17090af61200b0029c3e321f18si1817398pjb.71.2024.03.13.10.29.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:29:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101969-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ozhXXXKV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101969-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101969-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 274E528291D for ; Wed, 13 Mar 2024 17:28:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 477F61448D9; Wed, 13 Mar 2024 16:42:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ozhXXXKV" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4ACCD63411; Wed, 13 Mar 2024 16:42:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348178; cv=none; b=AS85gysB+MeGRV2o4xlDi+BlDdaf8CYWUerVv/roiox/e2/92R1DjoVUlY0aqUqk2gKuOl3gt0TbA8Hsw8l0JCo6WyM1n09uTgR+9T1SoVHh/4jSSahCWiHwu6x7YAUnkNuRa8kroNNvA93R/WrAGzzGC1XH1Hk9T9AD/ZpPrP8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348178; c=relaxed/simple; bh=8IImuHKCDLLJHUSZxoAxes0ahPbeQ6kuN9+Djzi8mbM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C+mw8t3zld3INY9+2BoGl9iQ7iySk4vI70gi38zPCmzxk/AhQVUY+WQ49NhwyokJlXrPWdQ7i1ZHGsgU+EB2e5AYQTmi0fqT3fyPgmFoHAcyiS9yrVTguxF72kc3JC6z2JMWLVyUrqQ/vvvmK2/IgINVGeyDFJ1xyhrcqh0U2zs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ozhXXXKV; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 679CBC43394; Wed, 13 Mar 2024 16:42:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348178; bh=8IImuHKCDLLJHUSZxoAxes0ahPbeQ6kuN9+Djzi8mbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ozhXXXKV1C8BpwXSn0ggOnXbjReceswAeRKPdDvgd+Ciczr1Lz5+pbaw4/BIsN1qL 3IAsFm5NN8t7D4ycnF2zSTcYzdei8y4tN50zzVwwtotd/Iy9qK7Bjt5kKv848UJ4Pa BYskbUntHgbLb3Kpn1lo642RWr9ZjRU/Y2hctx3mgz7W7ZtpOb/JffL8n4dIhHqosk /3ApWoYTVceBmSHRzwn/I/O8EKg2nNIqtFA1yChWrKDBeWzKblhXVVyoV+me6bfBFf nX9rjkevpNROZgPAUTvS5ignH1jwWdFk1+n9oJAxRYYjqPOZBT7ePHypHYcBHEdTcV 9lNqRZibBNygA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , "Jason A . Donenfeld" , Sasha Levin Subject: [PATCH 5.15 29/76] ALSA: usb-audio: Clear fixed clock rate at closing EP Date: Wed, 13 Mar 2024 12:41:36 -0400 Message-ID: <20240313164223.615640-30-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Takashi Iwai [ Upstream commit 809f44a0cc5ad4b1209467a6287f8ac0eb49d393 ] The recent commit c11117b634f4 ("ALSA: usb-audio: Refcount multiple accesses on the single clock") tries to manage the clock rate shared by several endpoints. This was intended for avoiding the unmatched rate by a different endpoint, but unfortunately, it introduced a regression for PulseAudio and pipewire, too; those applications try to probe the multiple possible rates (44.1k and 48kHz) and setting up the normal rate fails but only the last rate is applied. The cause is that the last sample rate is still left to the clock reference even after closing the endpoint, and this value is still used at the next open. It happens only when applications set up via PCM prepare but don't start/stop the stream; the rate is reset when the stream is stopped, but it's not cleared at close. This patch addresses the issue above, simply by clearing the rate set in the clock reference at the last close of each endpoint. Fixes: c11117b634f4 ("ALSA: usb-audio: Refcount multiple accesses on the single clock") Reported-by: Jason A. Donenfeld Tested-by: Jason A. Donenfeld Cc: Link: https://lore.kernel.org/all/YxXIWv8dYmg1tnXP@zx2c4.com/ Link: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2620 Link: https://lore.kernel.org/r/20220907100421.6443-1-tiwai@suse.de Signed-off-by: Takashi Iwai Stable-dep-of: 7822baa844a8 ("ALSA: usb-audio: add quirk for RODE NT-USB+") Signed-off-by: Sasha Levin --- sound/usb/endpoint.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 803053d4c9dbc..13c0264881499 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -932,6 +932,8 @@ void snd_usb_endpoint_close(struct snd_usb_audio *chip, endpoint_set_interface(chip, ep, false); if (!--ep->opened) { + if (ep->clock_ref && !atomic_read(&ep->clock_ref->locked)) + ep->clock_ref->rate = 0; ep->iface = 0; ep->altsetting = 0; ep->cur_audiofmt = NULL; -- 2.43.0