From nobody Wed May 27 15:33:28 2026 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 4gQYYN4MGjz6fCqS for ; Wed, 27 May 2026 15:33:28 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gQYYN2lKlz3X8s for ; Wed, 27 May 2026 15:33:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779896008; 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=Mst7fsqNhKOfNiCbyQF06HPVH/piXD5KBMG7+iRDkkk=; b=eoel0mTP7pZDTzFWc3Ray1aDtvgeXFwkWyrBsT9Yp3uKO8IeeAFjEHyNYCW+3Q6rWMkjGr PIILsmdgsWftY1t1REvwhFeHiu8dEaIXcocA29d2x/l38eyiyTLZL4t3V6hmLJidY5P5if XsP+jRY1banjvzghEl1wd9SvlfLO07Qxhij44M9PP+Bj1OkLyIGeH6tX4VC3PWL+dOyegz lD2jH4IPwSubgAGPWhO/Aao8+WA5szkgBHMiiXtxVeXrWg4D2oT6i6hDaZ+rklS1oHpGXn Z9Ax7HjQWQS6vBALo+m1nlI/r1Szu1IUG2hHvuU0CwMIdSm7wUEU4ITf9NYWzQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1779896008; a=rsa-sha256; cv=none; b=VqUVy7RyA1oASMrGkfGG7Rq03gBRVuafg+1oL8zyohzZG4MvV9UWUK9m5q2e17IF0nLp9a wZy76bKASeUbv3ZOMqZd/xWfRBxP6P1UoVeMjLtqmYEEJAyrEYVeRGnW4LvZY5XYaBLxRq yx9TIbWOZrTHwIWCG04dkYl1CFQsduAuKr/KxwpN43tiKWyVlZRbreU1g85cnyH1UNiL1r /+C8B81lg3W6Jc/0ERUQ2XNDVpiRdn8/z7g4v2V29zd6sz/N9oreRpAXxAjgYih0iuS70/ 3PBi9hIkJmgcc8gT8XHuHtmhj/gG8IByBfrG+ql4mqeZ+jZCjOW5sCNhn8XGoQ== 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=1779896008; 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=Mst7fsqNhKOfNiCbyQF06HPVH/piXD5KBMG7+iRDkkk=; b=nNFwiTw9BwIYO5eWNWLV6bxm600IZ4pKa5d0LoqpwV8YG8twMx3XuwQMjkCU7eBNWV16uT LOStauAY5lf/PT0NWmhX71gv2gBdzKlFof7VulY9G1xOIwNqDWk/VBtCQCKrY6b+g+G9Bo iYoEkDyLJS1qkJnk/wx1DcJuXenElSzibVy8HoNjnwD7/QEnKdGXbUFyMFQEdxpiwtmNAh OjjRtgGRVtHLwhIRj+qwdZXtBM0HV940XRj1Lz0zTmesUAINgpFmHiamCQkF4yQFUT13QM QLryFFIj/2FuJC3Pnkh5yiNrMrYHwNojUc3IBec07zXiAWArfsabDp/svowxgg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gQYYN265fz14H7 for ; Wed, 27 May 2026 15:33:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 30ba9 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 27 May 2026 15:33:28 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: f61e65e1b2ac - main - sound: Retire mixer_ioctl_channel() 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 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: f61e65e1b2ac74034bfc5d1230ae23ea4b9faa60 Auto-Submitted: auto-generated Date: Wed, 27 May 2026 15:33:28 +0000 Message-Id: <6a170ec8.30ba9.3ab5233a@gitrepo.freebsd.org> The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=f61e65e1b2ac74034bfc5d1230ae23ea4b9faa60 commit f61e65e1b2ac74034bfc5d1230ae23ea4b9faa60 Author: Christos Margiolis AuthorDate: 2026-04-16 11:00:16 +0000 Commit: Christos Margiolis CommitDate: 2026-05-27 15:32:11 +0000 sound: Retire mixer_ioctl_channel() This function never succeeds when it is not called from the same process that has opened the file descriptor (e.g., mixer(8)). The reason is that the CHN_FOREACH() loop tries to match the pid of each channel with the pid of the process performing the ioctl, which will not be the same, unless it's the same process that both opened the channel and performed the ioctl. In the case that the same process opens the channels and performs the ioctl, however, we still do not need to worry, because mixer_ioctl_cmd() essentially does the same thing anyway. Additionally, this scenario should be quite rare, given that most applications do not open both /dev/dsp* and /dev/mixer*, and in fact, it is actively encouraged by the official OSSv4 specification not to do that. Sponsored by: The FreeBSD Foundation MFC after: 1 week Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/18 --- sys/dev/sound/pcm/mixer.c | 117 +--------------------------------------------- 1 file changed, 1 insertion(+), 116 deletions(-) diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index 7ccb57c205ba..be4447b13964 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -1032,113 +1032,6 @@ mixer_close(struct cdev *i_dev, int flags, int mode, struct thread *td) return (0); } -static int -mixer_ioctl_channel(struct cdev *dev, u_long cmd, caddr_t arg, int mode, - struct thread *td, int from) -{ - struct snddev_info *d; - struct snd_mixer *m; - struct pcm_channel *c, *rdch, *wrch; - pid_t pid; - int j, ret; - - if (td == NULL || td->td_proc == NULL) - return (-1); - - m = dev->si_drv1; - d = device_get_softc(m->dev); - j = cmd & 0xff; - - switch (j) { - case SOUND_MIXER_PCM: - case SOUND_MIXER_RECLEV: - case SOUND_MIXER_DEVMASK: - case SOUND_MIXER_CAPS: - case SOUND_MIXER_STEREODEVS: - break; - default: - return (-1); - } - - pid = td->td_proc->p_pid; - rdch = NULL; - wrch = NULL; - c = NULL; - ret = -1; - - /* - * This is unfair. Imagine single proc opening multiple - * instances of same direction. What we do right now - * is looking for the first matching proc/pid, and just - * that. Nothing more. Consider it done. - * - * The better approach of controlling specific channel - * pcm or rec volume is by doing mixer ioctl - * (SNDCTL_DSP_[SET|GET][PLAY|REC]VOL / SOUND_MIXER_[PCM|RECLEV] - * on its open fd, rather than cracky mixer bypassing here. - */ - CHN_FOREACH(c, d, channels.pcm.opened) { - CHN_LOCK(c); - if (c->pid != pid || - !(c->feederflags & (1 << FEEDER_VOLUME))) { - CHN_UNLOCK(c); - continue; - } - if (rdch == NULL && c->direction == PCMDIR_REC) { - rdch = c; - if (j == SOUND_MIXER_RECLEV) - goto mixer_ioctl_channel_proc; - } else if (wrch == NULL && c->direction == PCMDIR_PLAY) { - wrch = c; - if (j == SOUND_MIXER_PCM) - goto mixer_ioctl_channel_proc; - } - CHN_UNLOCK(c); - if (rdch != NULL && wrch != NULL) - break; - } - - if (rdch == NULL && wrch == NULL) - return (-1); - - if ((j == SOUND_MIXER_DEVMASK || j == SOUND_MIXER_CAPS || - j == SOUND_MIXER_STEREODEVS) && - (cmd & ~0xff) == MIXER_READ(0)) { - mtx_lock(&m->lock); - *(int *)arg = mix_getdevs(m); - mtx_unlock(&m->lock); - if (rdch != NULL) - *(int *)arg |= SOUND_MASK_RECLEV; - if (wrch != NULL) - *(int *)arg |= SOUND_MASK_PCM; - ret = 0; - } - - return (ret); - -mixer_ioctl_channel_proc: - - KASSERT(c != NULL, ("%s(): NULL channel", __func__)); - CHN_LOCKASSERT(c); - - if ((cmd & ~0xff) == MIXER_WRITE(0)) { - int left, right, center; - - left = *(int *)arg & 0x7f; - right = (*(int *)arg >> 8) & 0x7f; - center = (left + right) >> 1; - chn_setvolume_multi(c, SND_VOL_C_PCM, left, right, center); - } else if ((cmd & ~0xff) == MIXER_READ(0)) { - *(int *)arg = chn_getvolume_matrix(c, SND_VOL_C_PCM, SND_CHN_T_FL); - *(int *)arg |= - chn_getvolume_matrix(c, SND_VOL_C_PCM, SND_CHN_T_FR) << 8; - } - - CHN_UNLOCK(c); - - return (0); -} - static int mixer_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td) @@ -1156,15 +1049,7 @@ mixer_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, PCM_GIANT_ENTER(d); PCM_ACQUIRE_QUICK(d); - ret = -1; - - if (mixer_bypass != 0 && (d->flags & SD_F_VPC)) - ret = mixer_ioctl_channel(i_dev, cmd, arg, mode, td, - MIXER_CMD_CDEV); - - if (ret == -1) - ret = mixer_ioctl_cmd(i_dev, cmd, arg, mode, td, - MIXER_CMD_CDEV); + ret = mixer_ioctl_cmd(i_dev, cmd, arg, mode, td, MIXER_CMD_CDEV); PCM_RELEASE_QUICK(d); PCM_GIANT_LEAVE(d);