Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1880410lql; Wed, 13 Mar 2024 10:37:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU4GKSmRQh1lBL09OwmDeQsy5pL2HZnCMxR8KGyOWpfqZPslVX16lqDdChuF+OOAX5L3PTKMT7n/ovjQxvHqAlIQ4OvV76ddVrgmCXLJg== X-Google-Smtp-Source: AGHT+IFMKjGh6KQJLTnglwE2lo+2wu6U7xT859dNiVV7CuXL5qPibvABY2umjzcMvop/ZVD8Qj81 X-Received: by 2002:a50:d75e:0:b0:567:56a4:3940 with SMTP id i30-20020a50d75e000000b0056756a43940mr8209364edj.19.1710351430209; Wed, 13 Mar 2024 10:37:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710351430; cv=pass; d=google.com; s=arc-20160816; b=MYOX8Jk+oYW6SuKgqTPEtAXkpm5oPRLeOhAKfxoHb+rfjiwcEF40D1E5bqv/I59SwA 1jm3UEWEdPv30AOTDmIIWouJ4FsjFLA8ZLPLcetmxolNDgv20G73Bqs7I/zptOG+q32X dW4yDV0gE/tH8sFSPdQ4A0jY0W0dgbIvaDi7NJrcltYM9bAUUSFXLfmkTF1IgA7l7FVX ja9zBJk2cqn04aURdUCTureHftwqWtvN9LROFzJJolH8dTuyVzVNYC8oxXbUB6qqiFNe N7wRlpuwj5uldJtxyUvPrcV9zf7j3LZutgM2GGG0zJdOUWRC44ftt07Gl+ZPfVImF1Gt PqfQ== 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=Oonh/008fQAGWVfuQj1RjsLcQG31QRlcnIgtJuyxvA0=; fh=rFbiR8o32NX4gr7DGGl175mQ6fTp8DLkQApotarON0U=; b=ipjR0wIgx0iUU9VA8IoTU/r3zLrm9vBq0kXItHBe104Hjvva3ezylMcH3oSclRlgdo 2LppG/E/wk1Ike5kNw2pUrIKF9GC7hCyj6+5o1AOJY+tNhGG2XXDu7WfFhxB/AXoL31g Ov1zAkLDCYVuYJS3xQJUfxZsIJcS/D66bPrXayXUrjkp3eETFT5ZuI/QcPOF7CF4285k WPLogxj2Zhr1t70CZhh6XiMcXCpStVrCO1TsYMXGLjXk+JMwhvdpeXsaDwB798gAsHpz aBXDyNBvQOXviqvO40anL/uTILjUU8aSfa/g0eNJQ5D/M7ImuYojUJsSLURXO2Fx0Hgt sLwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NZPR2Cyw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101974-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w19-20020a056402269300b0056844cfffefsi4016400edd.121.2024.03.13.10.37.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:37:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NZPR2Cyw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-101974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101974-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 87F2E1F25D00 for ; Wed, 13 Mar 2024 17:29:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1FE52145679; Wed, 13 Mar 2024 16:43:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NZPR2Cyw" 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 3497C145654; Wed, 13 Mar 2024 16:43:03 +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=1710348183; cv=none; b=u0iOWOoc4mPydkSSx9sUyPfxB/VhFpGrO28VDeCCUuZZPvMb9FiKE/klRiCbEspu+Dg7cmg7ZUtstVjrbjL9wRiGlC9BkhpxHfwR6Ug67SC4/1Q66nB4B91lEmrZ1vFk/GrvwGiqC51w8obzD91oiXlOM7unvLpv9ksMyBYt+po= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348183; c=relaxed/simple; bh=VZ5yNX8+WYqIibWi5E1WJBgVxjEbmgdMKVjOC7DiaS8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PS31BJkK0Px9TktXJiMr6//Va1MWBZg5Kzfn0qa9mlRE6n+L9ifaEqqCkXLkVSVjX8T/LBkWfXDETd2k5csILWq1Zq4VVMxPJOX5nrTwIvBdQcagWB971EihyS4wOJYPhCuwlVvhEdhWyChig8/lCyyVLFN2jCrQAChpFjo1I+w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NZPR2Cyw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77416C43394; Wed, 13 Mar 2024 16:43:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348183; bh=VZ5yNX8+WYqIibWi5E1WJBgVxjEbmgdMKVjOC7DiaS8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NZPR2CywYdEbo5yYNV7lGR4K7I/L5jgiHUTc/DYz7KM3ENYcRCxDQEzOuz/UoIVxF 5l1Ywe1Byk1asq5I1uKqsf7knG83AJzCD/jBHDHGm/mk4a600GWeCSqroyNJh3ZDNP NPM+FfNd+B2Ff6D6osPK+bqi7eUOLZ+ihh89PGwo4zZetSWKK0BSeBDn/WeIAibHaV UQaerb9rfmliF1jQRLOCTY8406n7oQLYx8/a49X463odmeUPoxah8wLVt4V42/P+31 UMl340HOva9PrTMQkS3g0h9qOiWz/FGUG7lDpKi1rq8go/YIkqNXFQ0+YHvetS98Qt rD1YbzZpYsYNg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 34/76] ALSA: usb-audio: Avoid superfluous endpoint setup Date: Wed, 13 Mar 2024 12:41:41 -0400 Message-ID: <20240313164223.615640-35-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 1045f5f1ff0751423aeb65648e5e1abd7a7a8672 ] After splitting to snd_usb_endpoint_set_params() and *_prepare(), the skip of each function should be checked with different flags, while we still use ep->need_setup as the single one. Introduce ep->need_prepare for indicating the need of prepare, and also add the missing check of ep->need_setup at the set_params. Fixes: 2be79d586454 ("ALSA: usb-audio: Split endpoint setups for hw_params and prepare (take#2)") Link: https://lore.kernel.org/r/20221009104212.18877-5-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/card.h | 3 ++- sound/usb/endpoint.c | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/sound/usb/card.h b/sound/usb/card.h index ca75f2206170f..40061550105ac 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -129,7 +129,8 @@ struct snd_usb_endpoint { in a stream */ bool implicit_fb_sync; /* syncs with implicit feedback */ bool lowlatency_playback; /* low-latency playback mode */ - bool need_setup; /* (re-)need for configure? */ + bool need_setup; /* (re-)need for hw_params? */ + bool need_prepare; /* (re-)need for prepare? */ /* for hw constraints */ const struct audioformat *cur_audiofmt; diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 80ead3db4d1c7..cf48d7ccc496e 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -829,6 +829,7 @@ snd_usb_endpoint_open(struct snd_usb_audio *chip, ep->implicit_fb_sync = fp->implicit_fb; ep->need_setup = true; + ep->need_prepare = true; usb_audio_dbg(chip, " channels=%d, rate=%d, format=%s, period_bytes=%d, periods=%d, implicit_fb=%d\n", ep->cur_channels, ep->cur_rate, @@ -954,7 +955,7 @@ void snd_usb_endpoint_close(struct snd_usb_audio *chip, /* Prepare for suspening EP, called from the main suspend handler */ void snd_usb_endpoint_suspend(struct snd_usb_endpoint *ep) { - ep->need_setup = true; + ep->need_prepare = true; if (ep->iface_ref) ep->iface_ref->need_setup = true; if (ep->clock_ref) @@ -1337,9 +1338,12 @@ int snd_usb_endpoint_set_params(struct snd_usb_audio *chip, struct snd_usb_endpoint *ep) { const struct audioformat *fmt = ep->cur_audiofmt; - int err; + int err = 0; mutex_lock(&chip->mutex); + if (!ep->need_setup) + goto unlock; + /* release old buffers, if any */ err = release_urbs(ep, false); if (err < 0) @@ -1388,8 +1392,11 @@ int snd_usb_endpoint_set_params(struct snd_usb_audio *chip, ep->curframesize = ep->curpacksize / ep->cur_frame_bytes; err = update_clock_ref_rate(chip, ep); - if (err >= 0) + if (err >= 0) { + ep->need_setup = false; err = 0; + } + unlock: mutex_unlock(&chip->mutex); return err; @@ -1439,7 +1446,7 @@ int snd_usb_endpoint_prepare(struct snd_usb_audio *chip, mutex_lock(&chip->mutex); if (WARN_ON(!ep->iface_ref)) goto unlock; - if (!ep->need_setup) + if (!ep->need_prepare) goto unlock; /* If the interface has been already set up, just set EP parameters */ @@ -1493,7 +1500,7 @@ int snd_usb_endpoint_prepare(struct snd_usb_audio *chip, ep->iface_ref->need_setup = false; done: - ep->need_setup = false; + ep->need_prepare = false; err = 1; unlock: -- 2.43.0