From nobody Tue Nov 05 21:45:33 2024 X-Original-To: dev-commits-src-branches@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 4Xjhhs2v4bz5bdsj; Tue, 05 Nov 2024 21:45: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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xjhhs24T3z4fT2; Tue, 5 Nov 2024 21:45:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730843133; 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=yX+ZOnfbpD0wEZuHH6Z/EWFRNdsghsTg+gRSWAS4eWw=; b=HDCU5R3iNXbVB0SwxjmFFPte6CYCPCbXLPfT1U0Y70300KJUrt4cGXrNlkg+lyE88gktZv xFEJqzTM3jSOIjnX+K3EERlQPkbkLidDbzN7z9h2s4rkPEbmcjoY4fZhM2nO2uZ0ntA6Vr 7KrlL8c2eaa7hKMWVwcYIIfGo62Ghf+CTe+x9UAS4H13p+OovAeTDw6enlbxggjK7CeinB iNitYngw0xxNsHkZPJa/O/4uUrATpmhi39DS8sZww8QGX9y2wxNG0oF+gFK6nKtLvGbjpA OYXMiw9+uk9Lut/LgsRapqcByk11/M9EVdZfymnN5j3pAH1Ij/HTkITb3RQc/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730843133; 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=yX+ZOnfbpD0wEZuHH6Z/EWFRNdsghsTg+gRSWAS4eWw=; b=ETMxui80tn9cB1Jz4niFnMeaUR3/aANrnw1uzapvjcteKqGNuap+ndZrp7UEtXaN/ESNoA NN2FG5p4j827egorTQ2qRUDkDAVvxTw1AqKlfchA7aXe0k56H549XziwAjNwYU7AMSYEDT FE1jX05udhy4qKsGND3ckz9mfbV64tmba52dgDimCUasS3lMEbT/8YmL9SO4SIYRS0leyH pDwpciDneJPSbwxoX1ms4A9qntJmVnZ5I90Y2eUH9L77feAsGADYyDHTgna8ymcTtnkAZA o4Rbxn5/jUfjjbaEVKg+oYbCk2Tpt5JXKlUmCxeZaO1lcA9dIuejXJtE8QXOdw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730843133; a=rsa-sha256; cv=none; b=ePwF/yBlj6NvJZcp1KofM2ARf7xGNJr1Hpkb4MwS+8kkXMilgUnNLtq/b8kzqsX3DdPHzo cqbSpt6KCev9hK7IciWGQpeW7yJckErqqZsmRsiK3zDsxelslrvr75oBvTNwRw/Btodo8R NgG2ijlaGTcvAYZ4zlSAOhU+x8nOJgyd7glzOXS32zJgw/mCIbfY1Ra/Ojo+Gihqce6uOt mMMIU3TeIGvlY6Bkxfd4KqC6gNCbDr5ucQPikIhv8N7JeGjPi8n+aPXQ0j+xplTfg6ouZj dt1XrSItG18zRQLKVwR+90+OW/lwSl04tOi2qSAb99cWTnkU+nwnZJ2UU35mbw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Xjhhs1ghczZf0; Tue, 5 Nov 2024 21:45:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4A5LjXdJ095453; Tue, 5 Nov 2024 21:45:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A5LjX3K095450; Tue, 5 Nov 2024 21:45:33 GMT (envelope-from git) Date: Tue, 5 Nov 2024 21:45:33 GMT Message-Id: <202411052145.4A5LjX3K095450@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: 00c066cd575d - stable/14 - sound: Move sysctl and /dev/dspX creation to pcm_setstatus() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 00c066cd575dedf34a1aa76ed29489604f4a9c9d Auto-Submitted: auto-generated The branch stable/14 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=00c066cd575dedf34a1aa76ed29489604f4a9c9d commit 00c066cd575dedf34a1aa76ed29489604f4a9c9d Author: Christos Margiolis AuthorDate: 2024-11-03 19:02:31 +0000 Commit: Christos Margiolis CommitDate: 2024-11-05 21:44:41 +0000 sound: Move sysctl and /dev/dspX creation to pcm_setstatus() Create the sysctl and /dev/dsp* nodes in pcm_setstatus(), which is responsible for finalizing the device initialization, instead of doing this in the middle of the initialization. For the sysctl creation specifically, move them into pcm_sysinit(), since this is where we create the rest of the sysctl nodes anyway. A side effect of this change is, that we avoid the possibility of racing in between pcm_register() and pcm_setstatus() by accessing /dev/dspX or the sysctls within that window. Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: dev_submerge.ch, markj Differential Revision: https://reviews.freebsd.org/D47322 (cherry picked from commit 66f3eb14e955d3917f817ff346d33d839679c2cf) --- sys/dev/sound/pcm/sound.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index 948cbd0b8fb9..5ca38ca622c9 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -316,7 +316,7 @@ pcm_setstatus(device_t dev, char *str) else if (snd_unit_auto == 1) snd_unit = pcm_best_unit(snd_unit); - return (0); + return (dsp_make_dev(dev)); } uint32_t @@ -433,6 +433,15 @@ pcm_sysinit(device_t dev) mode = pcm_mode_init(d); + sysctl_ctx_init(&d->play_sysctl_ctx); + d->play_sysctl_tree = SYSCTL_ADD_NODE(&d->play_sysctl_ctx, + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "play", + CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "playback channels node"); + sysctl_ctx_init(&d->rec_sysctl_ctx); + d->rec_sysctl_tree = SYSCTL_ADD_NODE(&d->rec_sysctl_ctx, + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "rec", + CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "recording channels node"); + /* XXX: a user should be able to set this with a control tool, the sysadmin then needs min+max sysctls for this */ SYSCTL_ADD_UINT(device_get_sysctl_ctx(dev), @@ -497,21 +506,12 @@ pcm_register(device_t dev, void *devinfo, int numplay, int numrec) if ((numplay == 0 || numrec == 0) && numplay != numrec) d->flags |= SD_F_SIMPLEX; - sysctl_ctx_init(&d->play_sysctl_ctx); - d->play_sysctl_tree = SYSCTL_ADD_NODE(&d->play_sysctl_ctx, - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "play", - CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "playback channels node"); - sysctl_ctx_init(&d->rec_sysctl_ctx); - d->rec_sysctl_tree = SYSCTL_ADD_NODE(&d->rec_sysctl_ctx, - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "rec", - CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "recording channels node"); - if (numplay > 0 || numrec > 0) d->flags |= SD_F_AUTOVCHAN; sndstat_register(dev, d->status); - return (dsp_make_dev(dev)); + return (0); } int