From nobody Wed Jun 10 04:01:09 2026 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 4gZsX63Drlz6gv4s for ; Wed, 10 Jun 2026 04:01:10 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gZsX620BBz3w87 for ; Wed, 10 Jun 2026 04:01:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781064070; 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=ssbL/A1jMOVS7Z+GuzWsMpIIutIy4hfrRhY16LIyuJo=; b=RC0Hh0160P4ri4x82nvhGD+1kUqCW6Q79N9txMDTmvZp7j47p594P0Ze0MHJiTee1N/4xc GIodMHiTI9tVX3dRwf/2M0H5ujxjVMf2jRE821lPYPDqw01I9XDLZY+SkdSnasSmugtiDN ynm3fcQoGvDEmKdGJ/Py9lnOJCdKwcB0dkzECCakb0trvjkQWXu1cbYSpGd37mxhLFlYWb U7NaUtHfG4LnF61FEVtQZeG46ka2K6odzW/0KLHSxyw3bCISi6uydZKZHOf+xyoa4RQgDX adR2dc/64127vqbWd5nH9KChUofrV0gfoxHhkyJwO77bzCinqU7EOSSjX3aUEg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781064070; a=rsa-sha256; cv=none; b=L46Vh/TDt1IAXcwcgcDuqEUyUL9YhzqBZ2EQW6ZCPTsL+vzqKDI7aq7PUlecoztVJ6DXx9 RxZRRTHrQeuMYT+lnv3/vlYL9zMKyPYOYw6K8toJrQIQC63u2zFT3M6NrQ+9AfWtyMI3tf NIJohgOTKjwOj9QFRTRAZ7F1TIn5zwpDi+XgsIR10oeZdkx03+5ah2AYXCbBgtKyDUrvNi fZv7QRg1PJsAc1jHeZEkaG1GKe3kzSa+56O92rVrBWjeDmfmy5geyJgobUu5q8afXfn7sI BD4QdRcmnf68bthzcrVVZT4GLR+ZDT2uuk3jXc2PuXvKGspYwd+W7Y2dPYNXkA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781064070; 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=ssbL/A1jMOVS7Z+GuzWsMpIIutIy4hfrRhY16LIyuJo=; b=hIxDe8WO5KM1V2mN3/LuczXX2s38I8TNuGQBKOJ1OTrln2xx/yACqLlFd67u+aFUv56b5p A1qrN0ERAD/vimcAAOs5rRLeU5kxzynuBS53FDtxWCO5Ec4U53KGIMBjFr+qtAEvNLXLek Hgk/grswUjk9xO+1Th/X6imuMOvQcfZEialY2qSf2I7wJ2ETALskvOWSzYKY8eJase88st RXw9l1W09vikSX7nx0zpPLly8GrdjqpJrMDhp+3rWUD38T+FTH2vQT8qvrD+akI93le4Lj qK3QcpN9pdOS4d0BF5ot8Ps/42whq73QWGlMfkNUAeoKS2//o8rIcXofZnUVQQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gZsX56Bl5z14PL for ; Wed, 10 Jun 2026 04:01:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2645e by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 10 Jun 2026 04:01:09 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 1f7337264f7d - stable/14 - pci: pci_host_generic: provide cleanup methods outside of detach 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 1f7337264f7d03578f8f16dc84b1707639cc7116 Auto-Submitted: auto-generated Date: Wed, 10 Jun 2026 04:01:09 +0000 Message-Id: <6a28e185.2645e.63ef8b71@gitrepo.freebsd.org> The branch stable/14 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=1f7337264f7d03578f8f16dc84b1707639cc7116 commit 1f7337264f7d03578f8f16dc84b1707639cc7116 Author: Kyle Evans AuthorDate: 2026-05-09 02:46:24 +0000 Commit: Kyle Evans CommitDate: 2026-06-10 04:00:48 +0000 pci: pci_host_generic: provide cleanup methods outside of detach If device_attach() fails, we're expected to actually cleanup after ourselves because device_detach() will not be called. Factor out the cleanup bits that don't rely on attach having actually succeeded so that we can cleanup properly in bcm2838_pci. Reviewed by: andrew, imp (cherry picked from commit 31a94ec32b53ebf6227bc868ce4f7aa07650680d) --- sys/dev/pci/pci_host_generic.c | 15 +++++++++++---- sys/dev/pci/pci_host_generic.h | 1 + sys/dev/pci/pci_host_generic_fdt.c | 19 +++++++++++++++++++ sys/dev/pci/pci_host_generic_fdt.h | 1 + 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c index 0fa663c12a56..600aa7bed7f9 100644 --- a/sys/dev/pci/pci_host_generic.c +++ b/sys/dev/pci/pci_host_generic.c @@ -250,15 +250,22 @@ err_resource: int pci_host_generic_core_detach(device_t dev) { - struct generic_pcie_core_softc *sc; - int error, rid, tuple; - - sc = device_get_softc(dev); + int error; error = bus_generic_detach(dev); if (error != 0) return (error); + return (pci_host_generic_core_free(dev)); +} + +int +pci_host_generic_core_free(device_t dev) +{ + struct generic_pcie_core_softc *sc; + int rid, tuple; + + sc = device_get_softc(dev); for (tuple = 0; tuple < MAX_RANGES_TUPLES; tuple++) { rid = sc->ranges[tuple].rid; if (sc->ranges[tuple].size == 0) { diff --git a/sys/dev/pci/pci_host_generic.h b/sys/dev/pci/pci_host_generic.h index 2d15f06890db..ad2b55c29a7f 100644 --- a/sys/dev/pci/pci_host_generic.h +++ b/sys/dev/pci/pci_host_generic.h @@ -94,6 +94,7 @@ DECLARE_CLASS(generic_pcie_core_driver); int pci_host_generic_core_attach(device_t); int pci_host_generic_core_detach(device_t); +int pci_host_generic_core_free(device_t); struct resource *pci_host_generic_core_alloc_resource(device_t, device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); int pci_host_generic_core_release_resource(device_t, device_t, int, int, diff --git a/sys/dev/pci/pci_host_generic_fdt.c b/sys/dev/pci/pci_host_generic_fdt.c index 05e77f46032f..b0ae82a67292 100644 --- a/sys/dev/pci/pci_host_generic_fdt.c +++ b/sys/dev/pci/pci_host_generic_fdt.c @@ -104,6 +104,25 @@ generic_pcie_fdt_probe(device_t dev) return (ENXIO); } +void +pci_host_generic_destroy_fdt(device_t dev) +{ + struct generic_pcie_fdt_softc *sc; + struct pci_ofw_devinfo *di; + + sc = device_get_softc(dev); + while (!STAILQ_EMPTY(&sc->pci_ofw_devlist)) { + di = STAILQ_FIRST(&sc->pci_ofw_devlist); + STAILQ_REMOVE_HEAD(&sc->pci_ofw_devlist, pci_ofw_link); + + ofw_bus_gen_destroy_devinfo(&di->di_dinfo); + free(di, M_DEVBUF); + } + + ofw_bus_destroy_iinfo(&sc->pci_iinfo); + (void)pci_host_generic_core_free(dev); +} + int pci_host_generic_setup_fdt(device_t dev) { diff --git a/sys/dev/pci/pci_host_generic_fdt.h b/sys/dev/pci/pci_host_generic_fdt.h index cc6e575f6056..790f781b23f0 100644 --- a/sys/dev/pci/pci_host_generic_fdt.h +++ b/sys/dev/pci/pci_host_generic_fdt.h @@ -46,6 +46,7 @@ DECLARE_CLASS(generic_pcie_fdt_driver); struct resource *pci_host_generic_alloc_resource(device_t, device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); int pci_host_generic_setup_fdt(device_t); +void pci_host_generic_destroy_fdt(device_t); int pci_host_generic_fdt_attach(device_t); int generic_pcie_get_id(device_t, device_t, enum pci_id_type, uintptr_t *);