From nobody Fri Dec 06 22:29:15 2024 X-Original-To: dev-commits-src-all@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 4Y4mC006Ymz5g0yX; Fri, 06 Dec 2024 22:29: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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y4mBz6lV4z485d; Fri, 6 Dec 2024 22:29:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733524155; 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=RCEp9HMB0Qd/8oKAYfdSNx23tc/6zWtOkjfNFSU63sc=; b=QtHcy4WgnlgRFmL9VdjfPbp/f/wZGFBhOJ6AAtYNN+n2hTU4hIozP253tLXciZanWQ4K80 XmH+XAQtZ271WrfCr3mViJ07zJ4J67nxH9tg6KjdEneqyhiOOLVWgCdcRR7k71RKwnAd6Z L5Crh0rvEquDV5d/nN7Ean9InsvK+02dBCzmc6GJt6aXwbDTDWTI+ROVoyd9Hacj5ZgygK hyrXDseNdGMYFkBZkN+sWl94rTSnkSR18GwjNIyV1HX0eUrgu31EPWD8AeqC8rZgL1hAdy 2LrqrtlFxEYFRM30LU8R2OsmVs0XBqnDq5u5cwmEPLDSxXYARGkiSWcPihDCfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733524155; 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=RCEp9HMB0Qd/8oKAYfdSNx23tc/6zWtOkjfNFSU63sc=; b=fbKI4rsmi//gJ1JSRcRabP0YeCaxjRWByAJX3FwIOkzGB3RbAaesQWa8Xd98XfeDW37Lkr 66VAVNKDL+cOiSmevT8kEpnIT9QOdsp6Jic2uUUgneRPrGE3qrM0gI64xed8tjV9cuOkvu bfE8KFx67I9CRvIFTwbhM69VrkOFFAa4mkYqcSNTqJKWzZHfZGtXrQOjwc5DJP+HKqyjjB zdYM2t7fyqGV0Vlb1vFSjToHon78k2zHzKYOCzLjRlQDacsi8qQOpPQ6NUExyZMQBXASue b/adIOMfGkkxDYuMwAHhFus1wtd0EfdY8/iaY+DgaWJFPfch6AGnjYw2sr/seQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733524155; a=rsa-sha256; cv=none; b=ggUEHojzCx/mKB9VY+q9pUe1dt0hjvWqbIDxqoQBQgkXS5uKsMgav+jWxubfzJ+sWG4RCv CGuGkST6DcmBCaekQVsve+NMyTLJXHC18ltnXlFtANoYJR+FjEOXH5HU5ZVOyM8r48ok0z wR+ONOibhm/3m2Pt6vqEtH5qtqTH6Pn/lqHLmOG7BsSablt8ZE2Jeoj3RdQd9Xof9GKvXn 3MOxQI2EmnWb+G6gPZ5yFc3WKgzlxPE7/cxjokM4zvmvut69uJ8zgyizQ8TxPzwLiyChTB PS7qW5flAIRpa4+P5JnFcaegAEnA4l1etqQlmGEPXPYLXYdtpnCZwxTUKeeW/g== 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 4Y4mBz6LZdzwqT; Fri, 6 Dec 2024 22:29:15 +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 4B6MTFoT072155; Fri, 6 Dec 2024 22:29:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B6MTFvN072152; Fri, 6 Dec 2024 22:29:15 GMT (envelope-from git) Date: Fri, 6 Dec 2024 22:29:15 GMT Message-Id: <202412062229.4B6MTFvN072152@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 46297859a745 - main - new-bus: Add bus_(identify|attach|detach)_children List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 46297859a74563dde6fc5bff9f9ecded9fb61ba6 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=46297859a74563dde6fc5bff9f9ecded9fb61ba6 commit 46297859a74563dde6fc5bff9f9ecded9fb61ba6 Author: John Baldwin AuthorDate: 2024-12-06 22:25:04 +0000 Commit: John Baldwin CommitDate: 2024-12-06 22:25:42 +0000 new-bus: Add bus_(identify|attach|detach)_children These correspond to the current implementations of bus_generic_(probe|attach|detach) but with more accurate names and semantics. The intention is to deprecate bus_generic_(probe|attach) and reimplement bus_generic_detach in a future commit. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47673 --- sys/kern/subr_bus.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++----- sys/sys/bus.h | 4 ++++ sys/sys/param.h | 2 +- 3 files changed, 65 insertions(+), 6 deletions(-) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 32ddcaa9f643..945d91d951d6 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -3408,6 +3408,22 @@ bus_generic_add_child(device_t dev, u_int order, const char *name, int unit) */ int bus_generic_probe(device_t dev) +{ + bus_identify_children(dev); + return (0); +} + +/** + * @brief Ask drivers to add child devices of the given device. + * + * This function allows drivers for child devices of a bus to identify + * child devices and add them as children of the given device. NB: + * The driver for @param dev must implement the BUS_ADD_CHILD method. + * + * @param dev the parent device + */ +void +bus_identify_children(device_t dev) { devclass_t dc = dev->devclass; driverlink_t dl; @@ -3426,8 +3442,6 @@ bus_generic_probe(device_t dev) continue; DEVICE_IDENTIFY(dl->driver, dev); } - - return (0); } /** @@ -3439,14 +3453,29 @@ bus_generic_probe(device_t dev) */ int bus_generic_attach(device_t dev) +{ + bus_attach_children(dev); + return (0); +} + +/** + * @brief Probe and attach all children of the given device + * + * This function attempts to attach a device driver to each unattached + * child of the given device using device_probe_and_attach(). If an + * individual child fails to attach this function continues attaching + * other children. + * + * @param dev the parent device + */ +void +bus_attach_children(device_t dev) { device_t child; TAILQ_FOREACH(child, &dev->children, link) { device_probe_and_attach(child); } - - return (0); } /** @@ -3460,7 +3489,7 @@ int bus_delayed_attach_children(device_t dev) { /* Probe and attach the bus children when interrupts are available */ - config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev); + config_intrhook_oneshot((ich_func_t)bus_attach_children, dev); return (0); } @@ -3474,6 +3503,32 @@ bus_delayed_attach_children(device_t dev) */ int bus_generic_detach(device_t dev) +{ + int error; + + error = bus_detach_children(dev); + if (error != 0) + return (error); + + return (0); +} + +/** + * @brief Detach drivers from all children of a device + * + * This function attempts to detach a device driver from each attached + * child of the given device using device_detach(). If an individual + * child fails to detach this function stops and returns an error. + * NB: Children that were successfully detached are not re-attached if + * an error occurs. + * + * @param dev the parent device + * + * @retval 0 success + * @retval non-zero a device would not detach + */ +int +bus_detach_children(device_t dev) { device_t child; int error; diff --git a/sys/sys/bus.h b/sys/sys/bus.h index 1f5e074cfe5a..c712e37fd34d 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -591,8 +591,12 @@ void bus_delete_resource(device_t dev, int type, int rid); int bus_child_present(device_t child); int bus_child_pnpinfo(device_t child, struct sbuf *sb); int bus_child_location(device_t child, struct sbuf *sb); + +void bus_attach_children(device_t dev); +int bus_detach_children(device_t dev); void bus_enumerate_hinted_children(device_t bus); int bus_delayed_attach_children(device_t bus); +void bus_identify_children(device_t dev); static __inline struct resource * bus_alloc_resource_any(device_t dev, int type, int *rid, u_int flags) diff --git a/sys/sys/param.h b/sys/sys/param.h index 550ea1fc61f6..f675dd024ee0 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -73,7 +73,7 @@ * cannot include sys/param.h and should only be updated here. */ #undef __FreeBSD_version -#define __FreeBSD_version 1500028 +#define __FreeBSD_version 1500029 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,