Date: Sun, 27 Oct 2024 16:33:13 GMT From: Christos Margiolis <christos@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: bf3a355a874a - stable/14 - sound: Remove redundant refcount checks in vchan_setnew() Message-ID: <202410271633.49RGXDrr035513@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=bf3a355a874abfcf7ab77bff84bc355ef79ef0a6 commit bf3a355a874abfcf7ab77bff84bc355ef79ef0a6 Author: Christos Margiolis <christos@FreeBSD.org> AuthorDate: 2024-10-25 11:36:51 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> 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--;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202410271633.49RGXDrr035513>