From nobody Fri Dec 10 00:05:14 2021 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 C007618C90B9; Fri, 10 Dec 2021 00:05:16 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J9B4C0qVnz4VNs; Fri, 10 Dec 2021 00:05:15 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 28C1F10B8F; Fri, 10 Dec 2021 00:05:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BA05E6u060516; Fri, 10 Dec 2021 00:05:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BA05EhN060515; Fri, 10 Dec 2021 00:05:14 GMT (envelope-from git) Date: Fri, 10 Dec 2021 00:05:14 GMT Message-Id: <202112100005.1BA05EhN060515@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 96e500a3f9f0 - main - hda: Push giant / newbus topo lock down a layer 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 96e500a3f9f0e317875b5d5c2097df804106bc3f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639094715; 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=p6yk6mQjvzYnocBfS/9KEX6KN1wTroZRWlqOXpBRyWY=; b=f7ztIr7cgHIs9lJiLrekY9zgM2YU6JPMbZLgsMxqiCDN2ulmLJ2Oxt5weVe+4scXwRoVLT 5GuUL3b00S2yM+Zo0h3S37D2YT/EkYyxQ1zaJnTiU0FL00pzW1vJh4qjevzRP4h1VqZpPA NLAHB06pQRos62DbvbO1l0p7XoSKLXSOdJ8nJNLcA/HjuHNKP0j221EchrxOUQoDFIB+Me en+QyQd9mGteH5+ds9a/ACtTPv/NC9/2T39ZFVrtCQDIwrVz8iZRRVFcnvX8sqWCgm3bIB WdO4XCFGPB6fDZx10oIK74D3j8OEe8KTb5EZE2lL+CxiZNG3CC4TSb605gpTlw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639094715; a=rsa-sha256; cv=none; b=tjKlqvmwqYlVSdlyVWr1jkdbYvWUNz3RsrJwnGWjPiTWIWsKrt2GD1wX1Y3+pQi+bTw5tY Vg+z4ETq3s54slpeh1zbSX4bWjD9HtAibeGG4KdnDY0sSI00cYr3EIX7R5957QBlD+NoZT 12LnHLjjJn0X9LAu65pXB8ADrdijeI+J63CNWwT6cclC7+2gtxU2FhxSZOfVKy26yHp+CN D/OGvJFf7nz/w6XgizchWDvhqgyo6xnpapXuYphL4zbmCOSJVNqRNmIyPNBZ1MWlqBMThZ giEF/kUclOWyP8v96eb6WBK6FTVxn4YG0s4wT4Pu2HLhOHq2IQMk//o6kDPgDA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=96e500a3f9f0e317875b5d5c2097df804106bc3f commit 96e500a3f9f0e317875b5d5c2097df804106bc3f Author: Warner Losh AuthorDate: 2021-12-09 23:52:55 +0000 Commit: Warner Losh CommitDate: 2021-12-10 00:04:58 +0000 hda: Push giant / newbus topo lock down a layer Rather than picking up Giant at the start of these sysctl handlers, push acquiring Giant down a layer to protect walking the children and also to add/delete children for the reconfigure. Sponsored by: Netflix Reviewed by: mav, jhb Differential Revision: https://reviews.freebsd.org/D33057 --- sys/dev/sound/pci/hda/hdaa.c | 13 +++++++++++-- sys/dev/sound/pci/hda/hdac.c | 14 +++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/sys/dev/sound/pci/hda/hdaa.c b/sys/dev/sound/pci/hda/hdaa.c index 82c309996d75..ddc22c3bc139 100644 --- a/sys/dev/sound/pci/hda/hdaa.c +++ b/sys/dev/sound/pci/hda/hdaa.c @@ -6463,16 +6463,25 @@ hdaa_sysctl_reconfig(SYSCTL_HANDLER_ARGS) HDA_BOOTHVERBOSE( device_printf(dev, "Reconfiguration...\n"); ); - if ((error = device_delete_children(dev)) != 0) + + bus_topo_lock(); + + if ((error = device_delete_children(dev)) != 0) { + bus_topo_unlock(); return (error); + } hdaa_lock(devinfo); hdaa_unconfigure(dev); hdaa_configure(dev); hdaa_unlock(devinfo); bus_generic_attach(dev); + bus_topo_unlock(); HDA_BOOTHVERBOSE( device_printf(dev, "Reconfiguration done\n"); ); + + bus_topo_unlock(); + return (0); } @@ -6669,7 +6678,7 @@ hdaa_attach(device_t dev) devinfo, 0, hdaa_sysctl_gpo_config, "A", "GPO configuration"); SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, - "reconfig", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + "reconfig", CTLTYPE_INT | CTLFLAG_RW, dev, 0, hdaa_sysctl_reconfig, "I", "Reprocess configuration"); SYSCTL_ADD_INT(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, diff --git a/sys/dev/sound/pci/hda/hdac.c b/sys/dev/sound/pci/hda/hdac.c index 5d3f1d85a2ad..058eb63e268d 100644 --- a/sys/dev/sound/pci/hda/hdac.c +++ b/sys/dev/sound/pci/hda/hdac.c @@ -1387,12 +1387,20 @@ sysctl_hdac_pindump(SYSCTL_HANDLER_ARGS) return (0); } - if ((err = device_get_children(dev, &devlist, &devcount)) != 0) + bus_topo_lock(); + + if ((err = device_get_children(dev, &devlist, &devcount)) != 0) { + bus_topo_unlock(); return (err); + } + hdac_lock(sc); for (i = 0; i < devcount; i++) HDAC_PINDUMP(devlist[i]); hdac_unlock(sc); + + bus_topo_unlock(); + free(devlist, M_TEMP); return (0); } @@ -1607,11 +1615,11 @@ hdac_attach2(void *arg) SYSCTL_ADD_PROC(device_get_sysctl_ctx(sc->dev), SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO, - "pindump", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc->dev, + "pindump", CTLTYPE_INT | CTLFLAG_RW, sc->dev, sizeof(sc->dev), sysctl_hdac_pindump, "I", "Dump pin states/data"); SYSCTL_ADD_PROC(device_get_sysctl_ctx(sc->dev), SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO, - "polling", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc->dev, + "polling", CTLTYPE_INT | CTLFLAG_RW, sc->dev, sizeof(sc->dev), sysctl_hdac_polling, "I", "Enable polling mode"); }