From nobody Mon Sep 07 13:04:37 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 4hdnN62YN0z6rNDG for ; Mon, 07 Sep 2026 13:04:38 +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 4hdnN60pKkz3jl8 for ; Mon, 07 Sep 2026 13:04:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788786278; 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=qSHvkJJxyVda6aiWVXFjSwKL63czrJ8XbbYCuKV2So4xf+1+YqkG0TSM/k+LtKfQOtJ+19 fWzRvkF1Mt6CZ92cFnEi5AdEbjRWQ49CABDW2ruNpAp059fqxcnqojetOAin5zu+C3T2t7 Inw37HmZmVhwVyxmt/gcvmj2Xd+2lraUrIavaEUpVf8VO0q2Qh961hVaJjCX3m6jh1JeeZ CF/+YR0MVdpL4PJvGu1gUuA4zj2vHUtheAXpiXmkmfwKEzYKO7QYLED+IgIGlK2ZR8cJD+ k3zgStjWgPrM6sAkBSaX75CAUkhl5gEZALuR6dKf5XMp+L9VONwOQoBI2Zcw/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1788786278; a=rsa-sha256; cv=none; b=NRbBnNLdmKY/NQ953+KUEukODF0/M7J8wRYAzzQNEM71Ww4Y0opUPAUpOCc4qzldT/pTCr eBxslMdlVUGpJCCWFmvu2Dkfco400BsKbARfGY+7DmLlSnsIog2t3xGL7DToYcxeSZrOro VMkX+Nkf/ZSoEnITBP3trU7gzuea4gJrZVKoNVxjaynEC2yjS9ncJn3vC0d2Y3g+iyH8Uz rC0GN1PiWhXvcNuCqTAI5OQH/E4+la2gl0uWRMQbM7GFUV8dKtC+xU9WAxXgqPoWk3xGPU AWbwT2oYuhVOBxJrct13FzUoD006unj8yhluj2n8aFBlYVHdLe26VyKPYdsHOg== 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=1788786278; 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=jdATe8H26EKlIsGRrTSH4hVDxs11rmZ+19iEjBqRzLkAZxUrw4y0QoNgWkXqolaRxuVqG5 djwp+l71SP9ziyk3/2bdetzt50Q3vJmd8FFVRscGrAEZBkLCXSwCYjmo3ox5q7uxzC33nN nmnowr4FiawFzTElEFhZdT5GibXuVN0DvxUPjXKV1nIwbmuzFYQZJNtZjLk3PK40wD1q6Q JCdwvgSwytRu9c5Q5pDZe8AKKcwJcm5sYPPSulgUa8VW9DqhRJP/E+6SOawDSoV5Yj9IbY WiLAbL0r1ZAZxgFGvQY+pXfjZ9kRUr480XkvwDlIEv5lmWx5ge7j9NajmkPSeg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hdnN56TxYz3f6 for ; Mon, 07 Sep 2026 13:04:37 +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 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: 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);