From nobody Mon Sep 07 13:04:37 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 4hdnNC5Ltqz6rNKG for ; Mon, 07 Sep 2026 13:04:43 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hdnNC2CC4z3k4p for ; Mon, 07 Sep 2026 13:04:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788786283; 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=MMP2CPNTNRfWIsbfwIZWKE5sDZI4vn5YAJgh5fezz5w=; b=WooweqFqQH24vhljXaJ95D84WivDecRN0QK3DpefiA22YSuoGnlzppmLidJ5Zq4YpIGvOq N+oJEqsgbPw6yN9QhzFF7zrrsq1EThPyjbuN28cCVFHR901Vk4G2ncuh/+xnEqUMFKdzFU 3k/RsgCoiHoQFYg60PTvOAg4ZAMq8qMtmXw5Y3TqZ3L3WwHZ0DKalmOC1ISjVO9rOpGR27 r/hLlC+dJ/WjVxoMI8HzqW18f4RxVzaXrex9WUDeDxLqCHzmOIYKO5klUBh6QywK2hcc5g rELt2DJCzdO8vlgaOsASeOIoFFQsazB16IrGhMhJctSCZw8N1ARJYeLEdoqTxw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1788786283; a=rsa-sha256; cv=none; b=MM15vjECp3SecFsGEknNrfpYbCIxh1rudc9DAJU3PftpakdfkiyBTPsabBFwDuTaU+FtZz eAAj5B3JrmKws8pZCaTka2KR8Dt3irgQWdiO/6COrmm+vBGGsGw0sT8oR8Dd/bBl7ZLXhZ /cqK9rMd6qW/Ac85lUho0gPVNYZMfVYrcxYzY16ZMLg9hffu7d3j1ZfUK2W+oKPg9P4Yp7 nv5LCfJVA8/wk2K0UShC40vYerV3/WZ6PYgY8P3FbXn/YwgIndE4ZHih192l6xOYCbG7nT gaUltYyMhmozBoJSeCy39FUUPYaP6Y4z03DUZEOWPCb3xS7r7hdYLMChZKgZuQ== 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=1788786283; 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=MMP2CPNTNRfWIsbfwIZWKE5sDZI4vn5YAJgh5fezz5w=; b=j9RRc+tbYS52Ed+EQFp3xbugEnFo8y479bRyhIJgE25fHZQRnZgkyufvVDbtgey2OU4NGk 0sE46qXmj6nL9aIsZBMXRhIAywGjIaYyRYyaADzMlsTrXg6B5nWxV2JeFCDvQ+5tJXQNpR ItfmwUFher+2RIy8nEVU+JFL2UAH2nIBouqt64EPo7VDd4YXMycqqg1iuIIGFrGpECaYyj RgcvHc+ERnkaV+JtvXA+EL+FBuqyyg/o4beG4LeD3tHMOSH1S7hhqrZ7AERJu/mh98Mb5x 4nkUtXO5/rC4JNt2R8ycajwkkiB0ZVtcmBCWQ1UuU2lPiq6cOlgHZJwR71Ybsw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hdnNC0f1vz3f7 for ; Mon, 07 Sep 2026 13:04:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 32a57 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 07 Sep 2026 13:04:37 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: 5e02679f03cd - main - sound: Prefer idle primary channels when allocating 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: 5e02679f03cda224f59adcf83d5308fffa6d11a1 Auto-Submitted: auto-generated Date: Mon, 07 Sep 2026 13:04:37 +0000 Message-Id: <6a9eb665.32a57.10237894@gitrepo.freebsd.org> The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=5e02679f03cda224f59adcf83d5308fffa6d11a1 commit 5e02679f03cda224f59adcf83d5308fffa6d11a1 Author: Christos Margiolis AuthorDate: 2026-09-07 13:04:09 +0000 Commit: Christos Margiolis CommitDate: 2026-09-07 13:04:09 +0000 sound: Prefer idle primary channels when allocating dsp_chn_alloc() stopped at the first primary channel that was either idle or already had vchans. Since the list is walked in order, the first channel matched both conditions once it had been used, so every client after the first was stacked onto it as a vchan and the remaining primary channels were never allocated at all. This is invisible on devices with a single primary channel, but not on those which provide several. snd_emu10kx(4), for instance, registers four primary channels for its front device, each able to run with its own rate. Look for an idle primary channel first, and only fall back to sharing one that already has vchans when there is none left. Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D59084 --- sys/dev/sound/pcm/dsp.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index c92c55b02cff..d32f83e3ae76 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -186,18 +186,28 @@ dsp_chn_alloc(struct snddev_info *d, struct pcm_channel **ch, int direction, (direction == PCMDIR_REC && d->flags & SD_F_RVCHANS); *ch = NULL; + + /* + * Prefer an idle primary channel, so that devices which provide more + * than one of them use them all, instead of stacking every client on + * the first one. + */ CHN_FOREACH(c, d, channels.pcm.primary) { CHN_LOCK(c); - if (c->direction != direction) { - CHN_UNLOCK(c); - continue; - } - /* Find an available primary channel to use. */ - if ((c->flags & CHN_F_BUSY) == 0 || - (vdir_enabled && (c->flags & CHN_F_HAS_VCHAN))) + if (c->direction == direction && (c->flags & CHN_F_BUSY) == 0) break; CHN_UNLOCK(c); } + /* Fall back to sharing a primary channel that already has vchans. */ + if (c == NULL && vdir_enabled) { + CHN_FOREACH(c, d, channels.pcm.primary) { + CHN_LOCK(c); + if (c->direction == direction && + (c->flags & CHN_F_HAS_VCHAN)) + break; + CHN_UNLOCK(c); + } + } if (c == NULL) return (EBUSY);