From nobody Sun Nov 03 19:04:08 2024 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 4XhPCX2fJ3z5ccyL; Sun, 03 Nov 2024 19:04:08 +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 4XhPCX203Lz4rm6; Sun, 3 Nov 2024 19:04:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730660648; 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=b9ocgrV0N/CX1a+ftbzUzbiwjZ0Rke6oocqbAyGczNI=; b=J8Nki/rGtrj1nGROS6e/k/eKRqYEWTLuTokpoV/FAGhHCmcv8hMFdh6mFZTY9U8qMzUhnw UO5HPPqlLzwBFpEo3dqKc5SUVOoJgC/XwlYkNFRG/sBXw3tmdMw3Q7OS6IT5/5IlWRUJko ZdS3j2kwepJ8au0OsGDWpikvlYBJsnRX+eRpFWrPDvzz8IJbtSjQJOWN6PVvJbFE7PMQLS LcvXT0Uh8nU/fo0qaTnxQ0wuvFORaj/Kla1bFnX9RUyGpIc6O1ePkCUa5iEw5ybWo0m8lk /od2rCSNovPphXTsCJkNOn7IrZQAUyXeU+3z2jo5hoOfA49vgVxOK4HozapxwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730660648; 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=b9ocgrV0N/CX1a+ftbzUzbiwjZ0Rke6oocqbAyGczNI=; b=ZTxgkvp+42OZ8MvU0qt/D1fKKrrqoYs3KmLHwxoKil3NHTgAPT1Sogq5oj9/NTQOJ1K14g l00VRPd6K1IJNYc8/z+k/lRfg7TKmcknXLRMqe4z1sVtEB06m7tvJtYpdcYLR4eEAgmAKY xAHni37pxBmz0RI2+Vx5kOhQta+WWhktrGS5ItcwyJPsCdy8v5aYCcveenfc2zwHAYG+xC 4aoh76qs1DZc3n+Vwd1Yx4lPltDE9qpZvOi5JuGNapDQ9yjuD8aCiWQqFtFziMYnFirBP2 sZjIKanHzGRCNdMHxS9VKTv2ynGe0zukizj4a4G5pdwW1KG5tz7JbLyUZ/CafQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730660648; a=rsa-sha256; cv=none; b=dB5Bf42Tcf3sG2pgGs9XS4g3ZOo/IAlZY+EfgiabzKK1mjQC03MWtuv/SKE4/N8hpFwvy6 jnIa5t1NTYfP+/yKR8R+uBgKI9zO0Jx0Vj6lFECApI2UWoSRsIEPcPzZmH+B+ahydCAp+c pMVBbxmn1A3UlJ407UeLuQ7rIK16Eh3tdUASlB9E1GZbX4iZ4phGiVTognwlqrnJrJ/n6V wZeTIrhnXC6wS3x4w0ZFahl49Xq4nddDUbVj4At8cVc1ejALhwtVocsGxd9mdPUd7qi35B w25T6XjjG2ESltrwhPYq8Edl2WTsaWq3esBVTTjQ1X19i3HORNPg1H8Ipn+cyg== 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 4XhPCX1J23z11cQ; Sun, 3 Nov 2024 19:04:08 +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 4A3J48r4052772; Sun, 3 Nov 2024 19:04:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A3J48Kn052769; Sun, 3 Nov 2024 19:04:08 GMT (envelope-from git) Date: Sun, 3 Nov 2024 19:04:08 GMT Message-Id: <202411031904.4A3J48Kn052769@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: 66f3eb14e955 - main - sound: Move sysctl and /dev/dspX creation to pcm_setstatus() 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 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: 66f3eb14e955d3917f817ff346d33d839679c2cf Auto-Submitted: auto-generated The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=66f3eb14e955d3917f817ff346d33d839679c2cf commit 66f3eb14e955d3917f817ff346d33d839679c2cf Author: Christos Margiolis AuthorDate: 2024-11-03 19:02:31 +0000 Commit: Christos Margiolis CommitDate: 2024-11-03 19:02:31 +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 --- 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