From nobody Wed Nov 18 10:24:44 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 4jTyQN4scHz71JKY for ; Wed, 18 Nov 2026 10:24:44 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jTyQN2zqzz4fkx for ; Wed, 18 Nov 2026 10:24:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794997484; 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=sfUohRc3VA0ke64ZrOGhDSetQZ+GgF6LOhSYcG2hUmg=; b=VvsT1q6JDGkS2Z1DUqpN0VjqY/o2sYSZ2jNBaYwV9GKO7z+2s3iBw/R/gFBzTaf2THHOja q+TEs/zmACBvzqxXVot/adAUp4N1ApgiDTKFhNbJnZ5rehOYRsQJfgpz9vjQ+br9QIp95p X026DhplFizNWwqVSGhyChj7HqM0T6DjH/AjHZGAz+YoKAuiRIrbokdJuerDt12WSf6v2w hP7jFMi9oW/U/F4ScsAFUnjbOqoXvqlWPa4S2+AEf6ChNRuXCmY3KAekqww7GcwUHVt7Yy 5eLOeFT+3vpJdvDRClYas5yHhl35itGLrMnt+4A+xGaBuIcEjmQNNP1ObpT4MA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794997484; b=reWt7u5Qkab1lQtqMQ15Qupzi6EyjemQ3WA3/CvvOayCJq/bZicYBbsYCUyFCmm7kAcILo MjVuAJN4umFU26hrugwUmquoKNXy41qsUHOS64KxGhauXlSCHcbj4JgdQhPvzUBL1WbT1l ymTcVMpbkPQoE1cODH4NADw54lIpPOM5Fna4z/Ohf4436usJlcYgVvI5kFHMU8+oUfROKl FonqjOlbqtyNDlbX/Bbdvcbof7e8M2ikSm8g6W63iwXzgMTRTvpQ/L4OtbsLBn1rrzVT3Z BcSK93NTzE95WlXcWNwampHl9B0GGfs/i/PKtC6HN5GfasySufu6WujO6etX6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794997484; 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=sfUohRc3VA0ke64ZrOGhDSetQZ+GgF6LOhSYcG2hUmg=; b=bv679tQmdF2MS8obrz/VL91QXpF7HDTIRja4ongYJiSqkHcLq96Ju/s7A3YKNca40RWhSB TgUwCuxL48JWxpRktFvAbYO02QYrweC92AVpBYfGw1yWtse2AMtJuVox7KPuuLEpDxxd4d tFp/apUPqVNLkttAQQf9f5MG+KMHcJq9iXB5fdK6ay+I68/vVYB78N2/2K954A7ceTUm24 mJ0/rF4Mw44qul3zcf0Y5dy0fQLmdhoG0WT8MZgHpvFkO6WYq8LCb4f9oVTDhIbYsuoqlo xwKPeTfI/4nElxXozySJQU/3lxLzARIDhCokwnmKdygZJc71Zc40HYaRS1/UrA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jTyQN1w0Cz1PDl for ; Wed, 18 Nov 2026 10:24:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3edc by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 18 Nov 2026 10:24:44 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: 7e1ff1592c39 - main - sound: Busy the device in mixer_oss_mixerinfo() List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org List-Id: Commit messages for the main branch of the src repository 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: 7e1ff1592c396da88dfd4a61631a88af69154043 Auto-Submitted: auto-generated Date: Wed, 18 Nov 2026 10:24:44 +0000 Message-Id: <6afd7cec.3edc.65f26c51@gitrepo.freebsd.org> The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=7e1ff1592c396da88dfd4a61631a88af69154043 commit 7e1ff1592c396da88dfd4a61631a88af69154043 Author: Christos Margiolis AuthorDate: 2026-11-18 10:23:07 +0000 Commit: Christos Margiolis CommitDate: 2026-11-18 10:23:07 +0000 sound: Busy the device in mixer_oss_mixerinfo() Rather than hold the topology lock across the whole handler, which blocks detach of every device in the system, busy the one being selected and used, and drop the topology lock, as the other SNDCTL_*INFO handlers do. The mutex now covers only the mixer fields. mixer->cdev is set once in mixer_init() and never cleared, so reading does not need the lock. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D60518 --- sys/dev/sound/pcm/mixer.c | 190 ++++++++++++++++++++++------------------------ 1 file changed, 92 insertions(+), 98 deletions(-) diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index 47411870ed75..462e434ad310 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -1129,7 +1129,6 @@ mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo *mi) return (EINVAL); d = NULL; - m = NULL; /* * There's a 1:1 relationship between mixers and PCM devices, so @@ -1137,123 +1136,118 @@ mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo *mi) */ bus_topo_lock(); for (i = 0; pcm_devclass != NULL && - i < devclass_get_maxunit(pcm_devclass); i++) { + i < devclass_get_maxunit(pcm_devclass); i++, d = NULL) { d = devclass_get_softc(pcm_devclass, i); if (!PCM_REGISTERED(d)) { if ((mi->dev == -1 && i == snd_unit) || mi->dev == i) { mixer_oss_mixerinfo_unavail(mi, i); bus_topo_unlock(); return (0); - } else - continue; + } + d = NULL; + continue; } - /* XXX Need Giant magic entry */ - - /* See the note in function docblock. */ - PCM_UNLOCKASSERT(d); - PCM_LOCK(d); - if (!MIXER_REGISTERED(d->mixer)) { if (mi->dev == i) { mixer_oss_mixerinfo_unavail(mi, i); - PCM_UNLOCK(d); bus_topo_unlock(); return (0); } - PCM_UNLOCK(d); + d = NULL; continue; } - if (!((d->mixer->cdev == i_dev && mi->dev == -1) || - mi->dev == i)) { - PCM_UNLOCK(d); - continue; - } - - m = d->mixer; - - /* - * At this point, the following synchronization stuff - * has happened: - * - a specific PCM device is locked. - * - a specific mixer device has been locked, so be - * sure to unlock when existing. - */ - bzero((void *)mi, sizeof(*mi)); - mi->dev = i; - snprintf(mi->id, sizeof(mi->id), "mixer%d", i); - strlcpy(mi->name, m->name, sizeof(mi->name)); - /** - * Counter is incremented when applications change any of this - * mixer's controls. A change in value indicates that - * persistent mixer applications should update their displays. - */ - mi->modify_counter = m->modify_counter; - mi->card_number = i; - /* - * Currently, FreeBSD assumes 1:1 relationship between - * a pcm and mixer devices, so this is hardcoded to 0. - */ - mi->port_number = 0; - - /** - * @todo Fill in @sa oss_mixerinfo::mixerhandle. - * @note From 4Front: "mixerhandle is an arbitrary - * string that identifies the mixer better than - * the device number (mixerinfo.dev). Device - * numbers may change depending on the order the - * drivers are loaded. However the handle should - * remain the same provided that the sound card - * is not moved to another PCI slot." - */ - - /** - * @note - * @sa oss_mixerinfo::magic is a reserved field. - * - * @par - * From 4Front: "magic is usually 0. However some - * devices may have dedicated setup utilities and the - * magic field may contain an unique driver specific - * value (managed by [4Front])." - */ - - mi->enabled = device_is_attached(m->dev) ? 1 : 0; - /** - * The only flag for @sa oss_mixerinfo::caps is - * currently MIXER_CAP_VIRTUAL, which I'm not sure we - * really worry about. - */ - /** - * Mixer extensions currently aren't supported, so - * leave @sa oss_mixerinfo::nrext blank for now. - */ - - /** - * @todo Fill in @sa oss_mixerinfo::priority (requires - * touching drivers?) - * @note The priority field is for mixer applets to - * determine which mixer should be the default, with 0 - * being least preferred and 10 being most preferred. - * From 4Front: "OSS drivers like ICH use higher - * values (10) because such chips are known to be used - * only on motherboards. Drivers for high end pro - * devices use 0 because they will never be the - * default mixer. Other devices use values 1 to 9 - * depending on the estimated probability of being the - * default device. - */ - - snprintf(mi->devnode, sizeof(mi->devnode), "/dev/mixer%d", i); - mi->legacy_device = i; - - PCM_UNLOCK(d); + if ((mi->dev == -1 && d->mixer->cdev == i_dev) || mi->dev == i) + break; + } + /* Exhausted the search. */ + if (d == NULL) { bus_topo_unlock(); - return (0); + return (EINVAL); } + + /* + * Do not give up the topology lock until the device is busied, or it + * might detach between unlocking and busying. + */ + PCM_ACQUIRE(d); bus_topo_unlock(); - return (EINVAL); + m = d->mixer; + + mtx_lock(m->lock); + bzero((void *)mi, sizeof(*mi)); + mi->dev = i; + snprintf(mi->id, sizeof(mi->id), "mixer%d", i); + strlcpy(mi->name, m->name, sizeof(mi->name)); + /** + * Counter is incremented when applications change any of this + * mixer's controls. A change in value indicates that + * persistent mixer applications should update their displays. + */ + mi->modify_counter = m->modify_counter; + mi->card_number = i; + /* + * Currently, FreeBSD assumes 1:1 relationship between + * a pcm and mixer devices, so this is hardcoded to 0. + */ + mi->port_number = 0; + + /** + * @todo Fill in @sa oss_mixerinfo::mixerhandle. + * @note From 4Front: "mixerhandle is an arbitrary + * string that identifies the mixer better than + * the device number (mixerinfo.dev). Device + * numbers may change depending on the order the + * drivers are loaded. However the handle should + * remain the same provided that the sound card + * is not moved to another PCI slot." + */ + + /** + * @note + * @sa oss_mixerinfo::magic is a reserved field. + * + * @par + * From 4Front: "magic is usually 0. However some + * devices may have dedicated setup utilities and the + * magic field may contain an unique driver specific + * value (managed by [4Front])." + */ + + mi->enabled = device_is_attached(m->dev) ? 1 : 0; + /** + * The only flag for @sa oss_mixerinfo::caps is + * currently MIXER_CAP_VIRTUAL, which I'm not sure we + * really worry about. + */ + /** + * Mixer extensions currently aren't supported, so + * leave @sa oss_mixerinfo::nrext blank for now. + */ + + /** + * @todo Fill in @sa oss_mixerinfo::priority (requires + * touching drivers?) + * @note The priority field is for mixer applets to + * determine which mixer should be the default, with 0 + * being least preferred and 10 being most preferred. + * From 4Front: "OSS drivers like ICH use higher + * values (10) because such chips are known to be used + * only on motherboards. Drivers for high end pro + * devices use 0 because they will never be the + * default mixer. Other devices use values 1 to 9 + * depending on the estimated probability of being the + * default device. + */ + + snprintf(mi->devnode, sizeof(mi->devnode), "/dev/mixer%d", i); + mi->legacy_device = i; + mtx_unlock(m->lock); + + PCM_RELEASE(d); + + return (0); }