From nobody Fri Dec 10 00:05:12 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 CDC5818C9071; Fri, 10 Dec 2021 00:05:13 +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 4J9B491985z4Vc1; Fri, 10 Dec 2021 00:05:13 +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 EABF410724; Fri, 10 Dec 2021 00:05:12 +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 1BA05Cdv060485; Fri, 10 Dec 2021 00:05:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BA05C3p060484; Fri, 10 Dec 2021 00:05:12 GMT (envelope-from git) Date: Fri, 10 Dec 2021 00:05:12 GMT Message-Id: <202112100005.1BA05C3p060484@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: d14bc7230ba5 - main - newbus: add bus_topo_assert 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: d14bc7230ba5c26de7d793ae3947e7571dc8fb7c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639094713; 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=s3sYJYr2P2UOSm3N/n/I3YesO8PY42r/+z5HEcJuUIM=; b=MCCVdpc1B0zxLENZQsWTCRsj39mg8ojyK6sl7ATmW9bKQuRgd4tDJpp/4WV4EPn3/4SHTO 6tu+t9hK2mfxOoMxPlmn//sj3HH3vZR22yugvlwVdx+CL3HrtLXmdRvXXWk/wHNHnzFi1i YXG/MHkZN110YTRAfSl+deGypz5IfiU9fVwVMLLqUuaMgR/09t4QXB/XOIiofW3DEoMCCO EMKH2iZ6NmTwHjYJWP7szjl4+xLm3y/qQ1JKDcVw87WjCcTXIcrTs62degb5FziEXPyWbF Z0Saax4JPPOyITEsLuFqONfUAPOIW6UrxEkKB23zFYdUYaDqbZTjesK6nQZg2w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639094713; a=rsa-sha256; cv=none; b=UsYrrFQDa9FkTpYg0w8mGTsoPoGHOBV5uKYnX+uJL4Mn9O4djH/TAV93dOq7wuE1S3D1rx D/ENEnfwNrOLqLRlkq7QjQyWkYp7BmGTbAwReAVscL1HpR3CHENoEFCQFpzvTNYDGpUjJK NYi2rYe6BsYoCCdDEcAOH2sCbQjasvkHfGi3ZPkfvuZQdasfamteRWl2aR4duIyocOJI1K j4TI8v1fd9J4VcmeRdok1dAHU6ELDVE01XPWTrHju2jQs154Nq7JMrDXkcdp0BHwYuuyIR srjMTeGGSFuGs0DT/weJibTcl2k9UC5oVIcpxTfgWyK43N+90E4WU1Dj0piTlg== 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=d14bc7230ba5c26de7d793ae3947e7571dc8fb7c commit d14bc7230ba5c26de7d793ae3947e7571dc8fb7c Author: Warner Losh AuthorDate: 2021-12-09 23:52:44 +0000 Commit: Warner Losh CommitDate: 2021-12-10 00:04:57 +0000 newbus: add bus_topo_assert Add bus_topo_assert() and implmement it as GIANT_REQUIRED for the moment. This will allow us to change more easily to a newbus-specific lock int he future. Sponsored by: Netflix Reviewed by: wulf, mav, jhb Differential Revision: https://reviews.freebsd.org/D31833 --- sys/dev/acpica/acpi.c | 6 +++--- sys/dev/bhnd/bhnd.c | 4 ++-- sys/dev/bhnd/bhnd_subr.c | 3 +-- sys/dev/hid/hidbus.c | 4 ++-- sys/dev/hid/hmt.c | 4 ++-- sys/dev/mii/mii.c | 2 ++ sys/kern/subr_bus.c | 15 +++++++++++---- sys/sys/bus.h | 1 + 8 files changed, 24 insertions(+), 15 deletions(-) diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index ce396a835b4f..7066116f19a4 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -755,7 +755,7 @@ acpi_suspend(device_t dev) { int error; - GIANT_REQUIRED; + bus_topo_assert(); error = bus_generic_suspend(dev); if (error == 0) @@ -768,7 +768,7 @@ static int acpi_resume(device_t dev) { - GIANT_REQUIRED; + bus_topo_assert(); acpi_set_power_children(dev, ACPI_STATE_D0); @@ -779,7 +779,7 @@ static int acpi_shutdown(device_t dev) { - GIANT_REQUIRED; + bus_topo_assert(); /* Allow children to shutdown first. */ bus_generic_shutdown(dev); diff --git a/sys/dev/bhnd/bhnd.c b/sys/dev/bhnd/bhnd.c index 654f42864233..0413970e5665 100644 --- a/sys/dev/bhnd/bhnd.c +++ b/sys/dev/bhnd/bhnd.c @@ -374,7 +374,7 @@ bhnd_generic_alloc_pmu(device_t dev, device_t child) u_int max_latency; int error; - GIANT_REQUIRED; /* for newbus */ + bus_topo_assert(); if (device_get_parent(child) != dev) return (EINVAL); @@ -490,7 +490,7 @@ bhnd_generic_release_pmu(device_t dev, device_t child) struct bhnd_resource *r; device_t pmu_dev; - GIANT_REQUIRED; /* for newbus */ + bus_topo_assert(); sc = device_get_softc(dev); diff --git a/sys/dev/bhnd/bhnd_subr.c b/sys/dev/bhnd/bhnd_subr.c index 036c3def5817..955e1a197002 100644 --- a/sys/dev/bhnd/bhnd_subr.c +++ b/sys/dev/bhnd/bhnd_subr.c @@ -2185,8 +2185,7 @@ bhnd_bus_generic_get_nvram_var(device_t dev, device_t child, const char *name, device_t nvram; device_t parent; - /* Make sure we're holding Giant for newbus */ - GIANT_REQUIRED; + bus_topo_assert(); /* Look for a directly-attached NVRAM child */ if ((nvram = device_find_child(dev, "bhnd_nvram", -1)) != NULL) diff --git a/sys/dev/hid/hidbus.c b/sys/dev/hid/hidbus.c index 69f3d3911631..4a3a3e21bf03 100644 --- a/sys/dev/hid/hidbus.c +++ b/sys/dev/hid/hidbus.c @@ -544,7 +544,7 @@ hidbus_find_child(device_t bus, int32_t usage) device_t *children, child; int ccount, i; - GIANT_REQUIRED; + bus_topo_assert(); /* Get a list of all hidbus children */ if (device_get_children(bus, &children, &ccount) != 0) @@ -724,7 +724,7 @@ hid_set_report_descr(device_t dev, const void *data, hid_size_t len) bool is_bus; int error; - GIANT_REQUIRED; + bus_topo_assert(); is_bus = device_get_devclass(dev) == hidbus_devclass; bus = is_bus ? dev : device_get_parent(dev); diff --git a/sys/dev/hid/hmt.c b/sys/dev/hid/hmt.c index dcf360bcffba..42dadfe24256 100644 --- a/sys/dev/hid/hmt.c +++ b/sys/dev/hid/hmt.c @@ -869,7 +869,7 @@ hmt_set_input_mode(struct hmt_softc *sc, enum hconf_input_mode mode) device_t hconf; int err; - GIANT_REQUIRED; + bus_topo_assert(); /* Find touchpad's configuration TLC */ hconf = hidbus_find_child(device_get_parent(sc->dev), @@ -886,7 +886,7 @@ hmt_set_input_mode(struct hmt_softc *sc, enum hconf_input_mode mode) if (device_get_devclass(hconf) != hconf_devclass) return (ENXIO); - /* hconf_set_input_mode can drop the Giant while sleeping */ + /* hconf_set_input_mode can drop the the topo lock while sleeping */ device_busy(hconf); err = hconf_set_input_mode(hconf, mode); device_unbusy(hconf); diff --git a/sys/dev/mii/mii.c b/sys/dev/mii/mii.c index f5f791171a53..5f782b15a151 100644 --- a/sys/dev/mii/mii.c +++ b/sys/dev/mii/mii.c @@ -377,6 +377,8 @@ mii_attach(device_t dev, device_t *miibus, if_t ifp, int bmsr, first, i, nchildren, phymax, phymin, rv; uint32_t phymask; + bus_topo_assert(); + if (phyloc != MII_PHY_ANY && offloc != MII_OFFSET_ANY) { printf("%s: phyloc and offloc specified\n", __func__); return (EINVAL); diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 2544826e9028..a5d0fc773787 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -867,6 +867,13 @@ static kobj_method_t null_methods[] = { DEFINE_CLASS(null, null_methods, 0); +void +bus_topo_assert() +{ + + GIANT_REQUIRED; +} + struct mtx * bus_topo_mtx(void) { @@ -2102,7 +2109,7 @@ device_probe_child(device_t dev, device_t child) /* We should preserve the devclass (or lack of) set by the bus. */ int hasclass = (child->devclass != NULL); - GIANT_REQUIRED; + bus_topo_assert(); dc = dev->devclass; if (!dc) @@ -2920,7 +2927,7 @@ device_probe(device_t dev) { int error; - GIANT_REQUIRED; + bus_topo_assert(); if (dev->state >= DS_ALIVE) return (-1); @@ -2954,7 +2961,7 @@ device_probe_and_attach(device_t dev) { int error; - GIANT_REQUIRED; + bus_topo_assert(); error = device_probe(dev); if (error == -1) @@ -3052,7 +3059,7 @@ device_detach(device_t dev) { int error; - GIANT_REQUIRED; + bus_topo_assert(); PDEBUG(("%s", DEVICENAME(dev))); if (dev->busy > 0) diff --git a/sys/sys/bus.h b/sys/sys/bus.h index f5e31e5a6d00..9996ceeb07f3 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -745,6 +745,7 @@ void bus_set_pass(int pass); void bus_topo_lock(void); void bus_topo_unlock(void); struct mtx * bus_topo_mtx(void); +void bus_topo_assert(void); /** * Shorthands for constructing method tables.