aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamjan Jovanovic <damjan.jov@gmail.com>2025-09-15 17:42:41 +0000
committerChristos Margiolis <christos@FreeBSD.org>2025-09-15 17:42:41 +0000
commite8b5025c3880b04c1c2139fe73b65fbd6deb41d4 (patch)
tree448193745957bbad0f189f3c61871829043c7fff
parent246d7e9fc23928be22db38220f5439f5cdee5264 (diff)
sound: Honor CHN_F_NBIO
If the device is opened with O_NONBLOCK, even though we check for it in order to set CHN_F_NBIO, the subsequent chn_reset() calls will clear all flags, except those set in CHN_F_RESET, which does not include CHN_F_NBIO. Add CHN_F_NBIO to CHN_F_RESET. Additionally, because primary channels can be reused, make sure we do not unintentionally keep CHN_F_NBIO set if the channel is re-opened, but without O_NONBLOCK. PR: 289441 MFC after: 2 days Reviewed by: christos, markj Differential Revision: https://reviews.freebsd.org/D52493
-rw-r--r--sys/dev/sound/pcm/channel.h2
-rw-r--r--sys/dev/sound/pcm/dsp.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/sys/dev/sound/pcm/channel.h b/sys/dev/sound/pcm/channel.h
index fab182b22774..9ad21d219001 100644
--- a/sys/dev/sound/pcm/channel.h
+++ b/sys/dev/sound/pcm/channel.h
@@ -408,7 +408,7 @@ enum {
#define CHN_F_RESET (CHN_F_BUSY | CHN_F_DEAD | \
CHN_F_VIRTUAL | CHN_F_HAS_VCHAN | \
- CHN_F_VCHAN_DYNAMIC | \
+ CHN_F_VCHAN_DYNAMIC | CHN_F_NBIO | \
CHN_F_PASSTHROUGH | CHN_F_EXCLUSIVE)
#define CHN_F_MMAP_INVALID (CHN_F_DEAD | CHN_F_RUNNING)
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
index aa6ad4a59778..da38f52021ae 100644
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -299,7 +299,7 @@ dsp_close(void *data)
CHN_LOCK(rdch);
chn_abort(rdch); /* won't sleep */
rdch->flags &= ~(CHN_F_RUNNING | CHN_F_MMAP |
- CHN_F_DEAD | CHN_F_EXCLUSIVE);
+ CHN_F_DEAD | CHN_F_EXCLUSIVE | CHN_F_NBIO);
chn_reset(rdch, 0, 0);
chn_release(rdch);
if (rdch->flags & CHN_F_VIRTUAL) {
@@ -323,7 +323,7 @@ dsp_close(void *data)
CHN_LOCK(wrch);
chn_flush(wrch); /* may sleep */
wrch->flags &= ~(CHN_F_RUNNING | CHN_F_MMAP |
- CHN_F_DEAD | CHN_F_EXCLUSIVE);
+ CHN_F_DEAD | CHN_F_EXCLUSIVE | CHN_F_NBIO);
chn_reset(wrch, 0, 0);
chn_release(wrch);
if (wrch->flags & CHN_F_VIRTUAL) {