From nobody Sun Oct 27 16:33:13 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Xc2Bd65DNz5bBSH; Sun, 27 Oct 2024 16:33:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xc2Bd3w9cz4PgB; Sun, 27 Oct 2024 16:33:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730046793; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dLqrpQE/wtTsFHEEdgl1cVqUU/XXIVZl4Wt8tWtnG3k=; b=qa7F2JT77Nfcp5zvYGISrQmgrPXOyxvmhRvT0qBa7xNh9PvDxSl26bjYIsjN9P4Kt1N2Tp SkAeTtFhVuccN+3ISXWL9Rh7nS2TA7Hshg3tpM0qzmbfR4Zx/T5PcffSYIPNu1OfW0N9K3 TbHspS1kqxepelW3lxeRb2bmelLKZ49B42wgtpeBWlyHVWEP1kYDyhy//b3WAUBFUYjJ83 3TxR+h1ra5/1gZljY5u1Miii2klgObqrAhuztQKknTDnWPlMJiH2nhW8a88jAxIwSJMEZQ jInxpnbKpmXEoAg7hD2Awi4Pe25xydLxGIuF/kzHUvN27kRugcpH0XMRne9uOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730046793; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dLqrpQE/wtTsFHEEdgl1cVqUU/XXIVZl4Wt8tWtnG3k=; b=K1Gafbe99LiV+4RWe+X5AEnTwZuym3EzkRDsIzC7RUYqLtbSKTQDlSfUo1pQjrF9DbC+MV qTVFoX4aDNzT5eqbRI4LWjv0qQss5V8q5c4fR4mrXJ6bjY+YTaL3StlaFS8q22VZ0ZywGB 6pGLN8klslvcV1OK++jNTzmhHe++FKQSYteTgFn9TvT1n5BnMnYGJ4YhobtLBBssmwtudS n0YVPbdDZGeoHOD/LCGQKYWf8pvf+qcEpWKT4bXaFv4jc3ppl8y4xsb2c3lk4bo0fP8d0i zrbdD+p3p0kND76SkKKRT1SrXj0pxM31h+xYTnQr2o9h3Hhum3cNJM3RKc1LiA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730046793; a=rsa-sha256; cv=none; b=pIJBeWgMg01/7CCOmqVp6ZDyX4d40F776gAT5zzS/s9NG3ey1W1+juHbA0BBMsRqccjhGm 5p0RkuC+6ErC3xeAUyCu4XpLJZTbI04p8DhqENJrD4vEcheA9uRvnBfBdcDK7ElIPx+6H1 005sodYGLvky63LUbCnaK+zb2F83XV9/WyJ1KOrasb/DDaZzK7aRpnprZ8ega3+6W7mEy+ 1Ym1AqfkWC1tqZDgLaD6EM8wx/bm4p0vd+osfjncDiv2W0ERCEBSA2r7tyATANkFqFOsFu j0xDHHRTplFhCq2HCP3cCwAzLwMgOOuA0G9gPe9zOJaT78y4Eh8+VzxhGOYFiw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Xc2Bd3XY7z12kJ; Sun, 27 Oct 2024 16:33:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49RGXDvx035516; Sun, 27 Oct 2024 16:33:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49RGXDrr035513; Sun, 27 Oct 2024 16:33:13 GMT (envelope-from git) Date: Sun, 27 Oct 2024 16:33:13 GMT Message-Id: <202410271633.49RGXDrr035513@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: bf3a355a874a - stable/14 - sound: Remove redundant refcount checks in vchan_setnew() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: christos X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: bf3a355a874abfcf7ab77bff84bc355ef79ef0a6 Auto-Submitted: auto-generated The branch stable/14 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=bf3a355a874abfcf7ab77bff84bc355ef79ef0a6 commit bf3a355a874abfcf7ab77bff84bc355ef79ef0a6 Author: Christos Margiolis AuthorDate: 2024-10-25 11:36:51 +0000 Commit: Christos Margiolis CommitDate: 2024-10-27 16:32:30 +0000 sound: Remove redundant refcount checks in vchan_setnew() When adding a new vchan, we are looking for a parent channel which either already has vchans (i.e CHN_F_HAS_VCHAN), or does not, but is also not being used (i.e !CHN_F_BUSY). Since CHN_F_BUSY essentially tells us if the channel is currently being used or not, there is no need to check if the channel's refcount is 0 as well. When removing a vchan, we first check if we have only 1 vchan allocated that is also being used (so we cannot remove it at the moment), and then we check if the vchan is not busy and remove it. Again, checking CHN_F_BUSY is enough. Sponsored by: The FreeBSD Foundation MFC after: 2 days Reviewed by: dev_submerge.ch Differential Revision: https://reviews.freebsd.org/D47268 (cherry picked from commit 43c0b593c2c3b2c07009c031a0e7e8190a45b31a) --- sys/dev/sound/pcm/vchan.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sys/dev/sound/pcm/vchan.c b/sys/dev/sound/pcm/vchan.c index c9db9d79847b..ed13a3c55961 100644 --- a/sys/dev/sound/pcm/vchan.c +++ b/sys/dev/sound/pcm/vchan.c @@ -928,7 +928,6 @@ vchan_setnew(struct snddev_info *d, int direction, int newcnt) CHN_LOCK(c); if (c->direction == direction && ((c->flags & CHN_F_HAS_VCHAN) || (vcnt == 0 && - c->refcount < 1 && !(c->flags & (CHN_F_BUSY | CHN_F_VIRTUAL))))) { /* * Reuse hw channel with vchans already @@ -987,12 +986,11 @@ vchan_setnew(struct snddev_info *d, int direction, int newcnt) } CHN_FOREACH_SAFE(ch, c, nch, children) { CHN_LOCK(ch); - if (vcnt == 1 && c->refcount > 0) { + if (vcnt == 1 && ch->flags & CHN_F_BUSY) { CHN_UNLOCK(ch); break; } - if (!(ch->flags & CHN_F_BUSY) && - ch->refcount < 1) { + if (!(ch->flags & CHN_F_BUSY)) { err = vchan_destroy(ch); if (err == 0) vcnt--;