From nobody Fri Oct 25 11:37:04 2024 X-Original-To: dev-commits-src-main@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 4XZgjr68gJz5ZcnY; Fri, 25 Oct 2024 11:37:04 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XZgjr57Bbz48vZ; Fri, 25 Oct 2024 11:37:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729856224; 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=Aijl9Zj0AnCBSyTzkwT4Fy5gvoPi+amZMIphrD4HDYw=; b=rjyQgRqbGlYWPpHZc/MY+VnU5ARKKcwv1EYr6o57pahZcv5sCoWT+9EUH7ouyJR0g/Tflq cvEMDdamFiHhxp4YCpsT8vwC0kx6msE6q2HpDtnIz5U00AO8jEcABOc6UU2cEO8WagPEZm KCvZBfAKHZTU+2Fu1TziTu4PrILW2OcbiLmAZDUfLClwDBye5cYDwOV5TaWPPgLmik05DU zdYUCJjsrTkKnBEfWn9hfyZSS5mNhYaYD4l5DxMmocIc9OBVcgssfJfNX3lFlehIlIIxsZ aiwFiKCqOl2OA4CC4HyE3ooow9IClyqnPNraKwcK+C4FL88Ddb5dQxKDQETj6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729856224; 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=Aijl9Zj0AnCBSyTzkwT4Fy5gvoPi+amZMIphrD4HDYw=; b=gcbu5SJ2oHw3M1VEBT9iS9J502yjKqIaTIw2P85C+VCAPtxTtsrQ4u05zYyzIIacKH9d8w sxPl7M+usjUlo02BiXCOc+C/7juifE08b1WUn96Zb8pQRF8BFtAvKcO38fFC6nFemj1x+f pu+DECRZW/Xj4CvYdzQoS7+j7lAX6u+LrfZmEaEoBqcaHTwYz98iU/TYHE69Oe4hLuqP80 KTEFO4hluwNWFhc9UReTEmg3cziLEHNzaWBOiGGjkjFR+fnAb8u9vFPxAhYIvRcdh5Yb/+ a5jYdFTADPF5Blj3VPcvGC/RUrN1uorm+P9Hytqm4lqYHYwoqzLBcjgYdo/u+A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729856224; a=rsa-sha256; cv=none; b=TOuehrFKO5ibYvos13Ng+IF+9reYLYXdq6kaYh5byAdw19KCAmAX7/FN7/yxXyoiwwGuAA rteneYcdJXImK/yIs9XmH1shObUaLfrEeuZMBctRG/OdK1zneZbtKQk1EDwVSLONd0afC2 PWPf4aB5rnB/LOvnPsQfvcbtdX9mcenGd/teuZvCujvMrJ7ZxykTeAIOyQynhVm/aueiIz cOx+vyZzojKPoFD2Zcw6D9sYu+9Gc46WK/nf/poSJ3Vjg5IgoGAkHUDgrzRJ+tp37I+uKa RWAw8Qnnd3imSt1JOyuc/tVDo1zgbqTp8NuA90jDVT8xPIbg8vBmlZMOHEYCCA== 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 4XZgjr4cWJzPbd; Fri, 25 Oct 2024 11:37:04 +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 49PBb4IY039233; Fri, 25 Oct 2024 11:37:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49PBb4m1039230; Fri, 25 Oct 2024 11:37:04 GMT (envelope-from git) Date: Fri, 25 Oct 2024 11:37:04 GMT Message-Id: <202410251137.49PBb4m1039230@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: 43c0b593c2c3 - main - sound: Remove redundant refcount checks in vchan_setnew() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 43c0b593c2c3b2c07009c031a0e7e8190a45b31a Auto-Submitted: auto-generated The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=43c0b593c2c3b2c07009c031a0e7e8190a45b31a commit 43c0b593c2c3b2c07009c031a0e7e8190a45b31a Author: Christos Margiolis AuthorDate: 2024-10-25 11:36:51 +0000 Commit: Christos Margiolis CommitDate: 2024-10-25 11:36:51 +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 --- 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--;