From nobody Sat Jun 20 19:05:33 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 4gjP713hcFz6hNH5 for ; Sat, 20 Jun 2026 19:05:33 +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 4gjP712spKz3sS1 for ; Sat, 20 Jun 2026 19:05:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781982333; 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=H3qgXgi2EUR9AnhZM3rI1uwvLiqODeNuSnXvbInnqBw=; b=mrLm7p7H3RUL0VP9X/akB9kye0vShXMgAdZSHzYHtZualuM+Q+iTcL+fOdQWSoimOAbWKn UGl/0HDN3qiprzW8a+jsHzNJhI6PuDYhyWjtORFvp3HbOaZ8mulGNKWXS6wEaJlwaSHLVn P16/Nv2pqqwNZ5pYtjjb3Sy8mZB1W/fmXmu5C8Mox8tTSGYsb1nVMY3rkM+O8G7BcfvwfC gHz7WNivbLZqEiAZUOK+0cjpgXTQ0ubZfI/QXLKlflHgFtFpxFqTNhnM+VXQo0dsR6EgPQ vvLa8zt3W829F4EswL5cvm029cM47+FH+fhx9KMhWSe09N+Z42i1QDjMkiKl0w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781982333; a=rsa-sha256; cv=none; b=cMjuPPr8WwHWYiZoe39zQnukqJtsexrg1B6DjRigdirr7+aByvCvOlpAnqrx/hEZBzCR9/ MyCbShAj/IO2YsX8qsJmWYDzL2DpF1K90clH6HawjpFj6jBiH+9al4KGhQO45WrpqrNdij OX9wnIxRhYwNkTfT8yCXekirgfpgPvzrQcfuP9NCeS8WUjiS2nK+wjZGs3ZS6066T1Xpqa cRkpJSqyhUDYGne9yAF+D8KCv0DyCuddXabbSW683rxvxtdejCwDKea+FUrDD6tjI+ENst icN0flTZ0eQ0TvJ8dqCRC+W96Yl0HZbqVCxgHzRNAgzl9xZr6P7+SsZF12UExQ== 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=1781982333; 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=H3qgXgi2EUR9AnhZM3rI1uwvLiqODeNuSnXvbInnqBw=; b=ynaFjtnZQtbrBF4TQF2m8BHpipEYM3/OD+pUbfOHXbgYfngEu6h4gO3IPoyX+B+g4sQOhm 3CvPYOlC2m3pHuzShSf5d5UUKbQxPFo6FdoWSjK3DYtz473GqJv3gC3iy7ad/DfkGFCU92 VoOPqgfMlSWmxVnF8x7pcelyuqX1jMWPRpk9s0Tk80FCglby8dk+QfpKQaNBIQftfZoxP5 rv3+m71yGuClbsjL6IRYKCTZEinM1CN43o6lJvnBQqoV2FkgwpsQhW59M3/dqaJGZe8+Jl Gss7m+twIJowloHOYQyZGYjNXPSG/G9sgpu+9fDAGAssSaZDhB2Qj1TgiqCCKg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gjP711rYVzkNq for ; Sat, 20 Jun 2026 19:05:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3361d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 20 Jun 2026 19:05:33 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: bbb37ddf3669 - main - 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/main X-Git-Reftype: branch X-Git-Commit: bbb37ddf3669f77d78446b9f1e37f58c63dc0a1c Auto-Submitted: auto-generated Date: Sat, 20 Jun 2026 19:05:33 +0000 Message-Id: <6a36e47d.3361d.28199768@gitrepo.freebsd.org> The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=bbb37ddf3669f77d78446b9f1e37f58c63dc0a1c commit bbb37ddf3669f77d78446b9f1e37f58c63dc0a1c Author: Christos Margiolis AuthorDate: 2026-06-12 06:14:05 +0000 Commit: Christos Margiolis CommitDate: 2026-06-20 19:04:49 +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 --- 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 df9e241881c0..337eb4e175b2 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;