From nobody Sat Jun 27 09:55:58 2026 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 4gnSbf3VGqz6jGvc for ; Sat, 27 Jun 2026 09:55:58 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gnSbf16mFz46bd for ; Sat, 27 Jun 2026 09:55:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782554158; 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=ll745av/c8BXtFJ9fn8wDERq6CuQanNc8X5kYEOFGRs=; b=x9b2/eY/yI5qeoliLBMOf4DeEmaQmyie6l0xrYD31HLyQG8z9TVSJhiauXlJJNmFnZq+Hg e/N++TVVh3oLtTb2RFpowJhaGYt06LT+d7ji9inmBkSvZTY7kJmqIoc8guWZIJW6JmW5Th jWZz7inbnTomzTUZ8o/L4xU01VZyf1O6190GYpOJtIPOMImEtNphjjkBbOYWkRhnBhoaTX 6+vWYAtRbKv7fiZrwVj+ITHfkNJqe83+4xKq0Y9Td0IHKTWnhkdXdfSX1fc6oPJXplwqq3 H3QwskYtXDekBAXUfXZFrPDNIZRaZcv+af3EW7Jcp5bB29p26hkN8Wvi7iK7Qg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782554158; a=rsa-sha256; cv=none; b=qMr1nk9hOtRV3IGHwD+QJrwQJQhAEdf0bJhj2nIjZGlIlSwMLENx7RjY7/1oWuUMSv9lXb 0qz/4Vle8vDvUSrG4cJAaXOpx2YjSUPhqcHmEFErqoinZOjM+1E/pMu6Tx6XnPaZxmOlEa 3f5Oecqn6pWp0x8DNTeI4V0fbw0kfj1qPrd196xprQ5wotY9zIajspsgJ/JwtJ/1Qmq6rW K8EgE+5wK/9bWK2Yy4v8kQlHrnSkOh+9toxvSOCO/Xbtj8wf5Fr/Y2ph58oU+F9Y/uPz8g Wd9iK9fyX4kOqhZltyRWz4ZjEMPenOzupCnpHAzGm4xUx5MZ9pj4YD5UJfgVLg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782554158; 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=ll745av/c8BXtFJ9fn8wDERq6CuQanNc8X5kYEOFGRs=; b=Tz6LRa+Cxd5876E8FlSlp0gSPPOM0KwbGravDUPW/k7uPiX6xxsWElyrTnmQZHMR1oy3/h SamWpTXpcZv++XVANM+kK6VVBYYvaq5fQ4B8b7PfryaOzbW5dJbryNwevGtoZonlQBrzgW oSdoFHFkG3DEvVc32vjVdk/FUp8725J4ay5vhlobzvYibNwzqxVWdBWPMr5yunxgHGJHJd WhNbDMkCniRVc47Kcz9KcBDUw1YXWzRDURfhiBWFcdDSO3K0g+dHN/X22wyBVN/CtUiqIH Q+tl8+M0tNrDtcA5VNf1mSmdovz8m0DOBFoKYt45TlPZ6K8pMrwI8cIl/c/Kwg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gnSbf07g0z490 for ; Sat, 27 Jun 2026 09:55:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 31e8d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 27 Jun 2026 09:55:58 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: 2c21445c6cbb - stable/15 - sound: Use and lock only the appropriate channel in dsp_mmap_single() 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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/15 X-Git-Reftype: branch X-Git-Commit: 2c21445c6cbbfcd9652d2db282ee6773cd4e0721 Auto-Submitted: auto-generated Date: Sat, 27 Jun 2026 09:55:58 +0000 Message-Id: <6a3f9e2e.31e8d.60520ba6@gitrepo.freebsd.org> The branch stable/15 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=2c21445c6cbbfcd9652d2db282ee6773cd4e0721 commit 2c21445c6cbbfcd9652d2db282ee6773cd4e0721 Author: Christos Margiolis AuthorDate: 2026-06-12 06:14:05 +0000 Commit: Christos Margiolis CommitDate: 2026-06-27 09:55:21 +0000 sound: Use and lock only the appropriate channel in dsp_mmap_single() dsp_mmap_single() mmaps one of the channels associated with a dsp_cdevpriv, based on the nprot argument. PROT_WRITE and PROT_READ|PROT_WRITE select the output channel for mmaping, and PROT_READ the input one. Instead of locking and modifying the flags of all dsp_cdevpriv channels, do it only for the one we actually use. While here, retire the now unused dsp_lock_chans() and dsp_unlock_chans(). Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: markj, kib Pull-Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/30 (cherry picked from commit bbb37ddf3669f77d78446b9f1e37f58c63dc0a1c) --- sys/dev/sound/pcm/dsp.c | 57 +++++++++++++++---------------------------------- 1 file changed, 17 insertions(+), 40 deletions(-) diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index 0557b03484dc..31d28245d7a8 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -144,24 +144,6 @@ dsp_destroy_dev(device_t dev) destroy_dev(d->dsp_dev); } -static void -dsp_lock_chans(struct dsp_cdevpriv *priv, uint32_t prio) -{ - if (priv->rdch != NULL && DSP_F_READ(prio)) - CHN_LOCK(priv->rdch); - if (priv->wrch != NULL && DSP_F_WRITE(prio)) - CHN_LOCK(priv->wrch); -} - -static void -dsp_unlock_chans(struct dsp_cdevpriv *priv, uint32_t prio) -{ - if (priv->rdch != NULL && DSP_F_READ(prio)) - CHN_UNLOCK(priv->rdch); - if (priv->wrch != NULL && DSP_F_WRITE(prio)) - CHN_UNLOCK(priv->wrch); -} - static int dsp_chn_alloc(struct snddev_info *d, struct pcm_channel **ch, int direction, int flags, struct thread *td) @@ -1973,7 +1955,7 @@ dsp_mmap_single(struct cdev *cdev, vm_ooffset_t *offset, struct dsp_mmap_handle *handle; struct dsp_cdevpriv *priv; struct snddev_info *d; - struct pcm_channel *wrch, *rdch, *c; + struct pcm_channel *c; int err; if (*offset >= *offset + size) @@ -1987,11 +1969,6 @@ dsp_mmap_single(struct cdev *cdev, vm_ooffset_t *offset, SV_CURPROC_ABI() != SV_ABI_LINUX))) return (EINVAL); - /* - * PROT_READ (alone) selects the input buffer. - * PROT_WRITE (alone) selects the output buffer. - * PROT_WRITE|PROT_READ together select the output buffer. - */ if ((nprot & (PROT_READ | PROT_WRITE)) == 0) return (EINVAL); @@ -2003,27 +1980,27 @@ dsp_mmap_single(struct cdev *cdev, vm_ooffset_t *offset, PCM_GIANT_ENTER(d); - dsp_lock_chans(priv, FREAD | FWRITE); - wrch = priv->wrch; - rdch = priv->rdch; - - c = ((nprot & PROT_WRITE) != 0) ? wrch : rdch; - if (c == NULL || (c->flags & CHN_F_MMAP_INVALID) || - (*offset + size) > c->bufsoft->allocsize || - (wrch != NULL && (wrch->flags & CHN_F_MMAP_INVALID)) || - (rdch != NULL && (rdch->flags & CHN_F_MMAP_INVALID))) { - dsp_unlock_chans(priv, FREAD | FWRITE); + /* + * PROT_READ (alone) selects the input buffer. + * PROT_WRITE (alone) selects the output buffer. + * PROT_WRITE|PROT_READ together select the output buffer. + */ + c = ((nprot & PROT_WRITE) != 0) ? priv->wrch : priv->rdch; + if (c == NULL) { PCM_GIANT_EXIT(d); return (EINVAL); } - if (wrch != NULL) - wrch->flags |= CHN_F_MMAP; - if (rdch != NULL) - rdch->flags |= CHN_F_MMAP; - + CHN_LOCK(c); + if ((c->flags & CHN_F_MMAP_INVALID) || + *offset + size > c->bufsoft->allocsize) { + CHN_UNLOCK(c); + PCM_GIANT_EXIT(d); + return (EINVAL); + } + c->flags |= CHN_F_MMAP; *offset = (uintptr_t)sndbuf_getbufofs(c->bufsoft, *offset); - dsp_unlock_chans(priv, FREAD | FWRITE); + CHN_UNLOCK(c); handle = malloc(sizeof(*handle), M_DEVBUF, M_WAITOK); handle->cdev = cdev;