From nobody Mon May 18 18:53:31 2026 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 4gK6QN4ZMyz6fpXc for ; Mon, 18 May 2026 18:53:32 +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 4gK6QN0TgTz3MKg for ; Mon, 18 May 2026 18:53:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779130412; 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=9jD/Ei0QyLHnU5g2N9w2SiIsjeGqjEWOVZp96WTQNYQ=; b=YgNQ4TKHQ35B2jrI6COEL3M4L3qbvU/db4tiwwqzC4oRJ+5u8b5g1zT/br0WFlXra4Ws8m 4kzMo/bok2iO/un/r4DsQKyyAi+4MUlsP7hDEbXPz+UftkeBpaV/rjkYbvXAfsdJX468ex WR0KMIpxDXtVZXb7ZBAUxxQjryHZgWxxsIs1peLstWYqv8z5d/kUmucqMp0RJZYT7oLaIS ExVqMiPD8PgjJcgduoQ2AEfDiyOpFYvTp6wtx9JTTzoEqtXqZ6ZL8Xwa5V/aPBGzY9cxCL P5T/Wh60TceQAEJCuCFRa6Qp6oDfEmQ5ypAu6S+OVnqSHi/3UEZ6ir6lcQjEXg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1779130412; a=rsa-sha256; cv=none; b=tP7n4EefYZUdGtVZ3/4tV0zDemnrgLp/0+twpcBz1nfpXPBKUjlgDyE8tUfa3Q/zHqNcZ9 yhi9z7Bm6Iy0KBluciRZrsC1uHIHlVHYKLekW2br7m3U4AT62GjvEUXWoJQgq52seop+8o fo9X7efSiLVc8oIMD9tr5Bx/yx1fnTHl4xBq8fCPD8zEm2DAwhjlqo5ry2v3pKBsgdmVIZ N2QnWrJ0dSt7BE9b3po2AeqS7IqRpN+MsV8XxQVlIN9zsaHSmW13aqTHKfiwVTeVSq+p0R FPdwGMaIMRTwoP1rOK9lC1OwHIm0/WDU5csYxDM1K2lgGG2PsQNqJesiRH7PxQ== 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=1779130412; 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=9jD/Ei0QyLHnU5g2N9w2SiIsjeGqjEWOVZp96WTQNYQ=; b=LE8ocdH7PhUJmMi/Rn1SCm9J3SvSBGn6UTq8VbmgwSLZl6xBAhgEQn5QG+rfDW7KThHQZE pitWnFEIwUR1uYWIytwK8OuZSA/hjNbJTfefzAi4UEBWYUjOs7vu5Z5MM81gJQyr0A4kpV oHjQ3Onpjyy3P8xH2FsZF4Dv6yTrBK7Q3WoYAAUs1uYn1ik+NEJ31YsPQAuZaBMo5pK1cU Nwxx6ElpOH9j5Jxcq54VTxjr80+c9za1RJg4SH94XROo/hz1wKYaPUVMMzI4I6jim531GQ M6HB4ZK7Vo7m3+QefCmKDKa0kX6S/oFXaQ6M25KG30nfQP5y1Krdz08qlgP2LQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gK6QN057PzgVc for ; Mon, 18 May 2026 18:53:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 31b86 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 18 May 2026 18:53:31 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 6dc813301a17 - main - sys: Use is_pci_device instead of direct comparisons to devclasses 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 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6dc813301a173e2e1993c3064df162e6218c1231 Auto-Submitted: auto-generated Date: Mon, 18 May 2026 18:53:31 +0000 Message-Id: <6a0b602b.31b86.4dbaa797@gitrepo.freebsd.org> The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=6dc813301a173e2e1993c3064df162e6218c1231 commit 6dc813301a173e2e1993c3064df162e6218c1231 Author: John Baldwin AuthorDate: 2026-05-18 18:52:23 +0000 Commit: John Baldwin CommitDate: 2026-05-18 18:52:23 +0000 sys: Use is_pci_device instead of direct comparisons to devclasses Reviewed by: bz Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D56997 --- sys/arm64/cavium/thunder_pcie_pem.c | 6 +---- sys/arm64/iommu/smmu.c | 6 ++--- sys/compat/linuxkpi/common/include/linux/pci.h | 6 ++--- sys/dev/ata/ata-all.c | 3 +-- sys/dev/bge/if_bge.c | 13 +++-------- sys/dev/ichwd/ichwd.c | 5 ++-- sys/dev/iommu/busdma_iommu.c | 32 +++++++------------------- sys/dev/pci/pci.c | 10 ++------ sys/dev/pci/vga_pci.c | 6 ++--- sys/dev/vnic/thunder_bgx_fdt.c | 9 ++------ sys/x86/iommu/amd_drv.c | 3 +-- sys/x86/iommu/intel_drv.c | 13 +++-------- 12 files changed, 29 insertions(+), 83 deletions(-) diff --git a/sys/arm64/cavium/thunder_pcie_pem.c b/sys/arm64/cavium/thunder_pcie_pem.c index 04b892b91c56..092f11241e29 100644 --- a/sys/arm64/cavium/thunder_pcie_pem.c +++ b/sys/arm64/cavium/thunder_pcie_pem.c @@ -760,8 +760,6 @@ thunder_pem_attach(device_t dev) { struct resource_map_request req; struct resource_map map; - devclass_t pci_class; - device_t parent; struct thunder_pem_softc *sc; int error; int rid; @@ -773,9 +771,7 @@ thunder_pem_attach(device_t dev) sc->dev = dev; /* Allocate memory for resource */ - pci_class = devclass_find("pci"); - parent = device_get_parent(dev); - if (device_get_devclass(parent) == pci_class) + if (is_pci_device(dev)) rid = PCIR_BAR(0); else rid = RID_PEM_SPACE; diff --git a/sys/arm64/iommu/smmu.c b/sys/arm64/iommu/smmu.c index a84ef4ae347e..265f1e56f892 100644 --- a/sys/arm64/iommu/smmu.c +++ b/sys/arm64/iommu/smmu.c @@ -1825,7 +1825,6 @@ smmu_ctx_init(device_t dev, struct iommu_ctx *ioctx) struct iommu_domain *iodom; struct smmu_softc *sc; struct smmu_ctx *ctx; - devclass_t pci_class; u_int sid; int err; @@ -1836,8 +1835,7 @@ smmu_ctx_init(device_t dev, struct iommu_ctx *ioctx) domain = ctx->domain; iodom = (struct iommu_domain *)domain; - pci_class = devclass_find("pci"); - if (device_get_devclass(device_get_parent(ctx->dev)) == pci_class) { + if (is_pci_device(ctx->dev)) { err = smmu_pci_get_sid(ctx->dev, NULL, &sid); if (err) return (err); @@ -1863,7 +1861,7 @@ smmu_ctx_init(device_t dev, struct iommu_ctx *ioctx) smmu_init_ste(sc, domain->cd, ctx->sid, ctx->bypass); - if (device_get_devclass(device_get_parent(ctx->dev)) == pci_class) + if (is_pci_device((ctx->dev)) if (iommu_is_buswide_ctx(iodom->iommu, pci_get_bus(ctx->dev))) smmu_set_buswide(dev, domain, ctx); diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index a6ddc02d1947..56b9c6e05f27 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -399,8 +399,7 @@ int _lkpi_pci_enable_msi_range(struct pci_dev *pdev, int minvec, int maxvec); static inline bool dev_is_pci(struct device *dev) { - return (device_get_devclass(device_get_parent(dev->bsddev)) == - devclass_find("pci")); + return (is_pci_device(dev->bsddev)); } static inline uint16_t @@ -556,8 +555,7 @@ pci_upstream_bridge(struct pci_dev *pdev) bridge = device_get_parent(bridge); if (bridge == NULL) goto done; - if (device_get_devclass(device_get_parent(bridge)) != - devclass_find("pci")) + if (!is_pci_device(bridge)) goto done; /* diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index 2e77c0f6478e..85fe40aa4584 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -1176,8 +1176,7 @@ ataaction(struct cam_sim *sim, union ccb *ccb) cpi->protocol = PROTO_ATA; cpi->protocol_version = PROTO_VERSION_UNSPECIFIED; cpi->maxio = ch->dma.max_iosize ? ch->dma.max_iosize : DFLTPHYS; - if (device_get_devclass(device_get_parent(parent)) == - devclass_find("pci")) { + if (is_pci_device(parent)) { cpi->hba_vendor = pci_get_vendor(parent); cpi->hba_device = pci_get_device(parent); cpi->hba_subvendor = pci_get_subvendor(parent); diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index 2feb19bff677..3551f10b2ae3 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -3202,20 +3202,13 @@ bge_mbox_reorder(struct bge_softc *sc) } mbox_reorder_lists[] = { { 0x1022, 0x7450, "AMD-8131 PCI-X Bridge" }, }; - devclass_t pci, pcib; - device_t bus, dev; + device_t dev; int i; - pci = devclass_find("pci"); - pcib = devclass_find("pcib"); dev = sc->bge_dev; - bus = device_get_parent(dev); for (;;) { - dev = device_get_parent(bus); - bus = device_get_parent(dev); - if (device_get_devclass(dev) != pcib) - break; - if (device_get_devclass(bus) != pci) + dev = device_get_parent(device_get_parent(dev)); + if (!is_pci_device(dev)) break; for (i = 0; i < nitems(mbox_reorder_lists); i++) { if (pci_get_vendor(dev) == diff --git a/sys/dev/ichwd/ichwd.c b/sys/dev/ichwd/ichwd.c index 5481553cc175..b0c953e58956 100644 --- a/sys/dev/ichwd/ichwd.c +++ b/sys/dev/ichwd/ichwd.c @@ -561,13 +561,12 @@ static device_t ichwd_find_ich_lpc_bridge(device_t isa, struct ichwd_device **id_p) { struct ichwd_device *id; - device_t isab, pci; + device_t isab; uint16_t devid; /* Check whether parent ISA bridge looks familiar. */ isab = device_get_parent(isa); - pci = device_get_parent(isab); - if (pci == NULL || device_get_devclass(pci) != devclass_find("pci")) + if (!is_pci_device(isab)) return (NULL); if (pci_get_vendor(isab) != VENDORID_INTEL) return (NULL); diff --git a/sys/dev/iommu/busdma_iommu.c b/sys/dev/iommu/busdma_iommu.c index 82f73d469585..3852429c4a8a 100644 --- a/sys/dev/iommu/busdma_iommu.c +++ b/sys/dev/iommu/busdma_iommu.c @@ -117,17 +117,14 @@ iommu_bus_dma_is_dev_disabled(int domain, int bus, int slot, int func) int iommu_get_requester(device_t dev, device_t *requesterp, uint16_t *rid) { - devclass_t pci_class; device_t l, pci, pcib, pcip, pcibp, requester; int cap_offset; uint16_t pcie_flags; bool bridge_is_pcie; - pci_class = devclass_find("pci"); l = requester = dev; - pci = device_get_parent(dev); - if (pci == NULL || device_get_devclass(pci) != pci_class) { + if (!is_pci_device(dev)) { *rid = 0; /* XXXKIB: Could be ACPI HID */ *requesterp = NULL; return (ENOTTY); @@ -141,29 +138,18 @@ iommu_get_requester(device_t dev, device_t *requesterp, uint16_t *rid) * unit. */ for (;;) { - pci = device_get_parent(l); - if (pci == NULL) { + if (!is_pci_device(l)) { if (bootverbose) { printf( - "iommu_get_requester(%s): NULL parent for %s\n", + "iommu_get_requester(%s): non-pci ancestor %s\n", device_get_name(dev), device_get_name(l)); } *rid = 0; *requesterp = NULL; return (ENXIO); } - if (device_get_devclass(pci) != pci_class) { - if (bootverbose) { - printf( - "iommu_get_requester(%s): non-pci parent %s for %s\n", - device_get_name(dev), device_get_name(pci), - device_get_name(l)); - } - *rid = 0; - *requesterp = NULL; - return (ENXIO); - } + pci = device_get_parent(l); pcib = device_get_parent(pci); if (pcib == NULL) { if (bootverbose) { @@ -182,10 +168,8 @@ iommu_get_requester(device_t dev, device_t *requesterp, uint16_t *rid) * port, and the requester ID won't be translated * further. */ - pcip = device_get_parent(pcib); - if (device_get_devclass(pcip) != pci_class) + if (!is_pci_device(pcib)) break; - pcibp = device_get_parent(pcip); if (pci_find_cap(l, PCIY_EXPRESS, &cap_offset) == 0) { /* @@ -212,6 +196,8 @@ iommu_get_requester(device_t dev, device_t *requesterp, uint16_t *rid) * PCI bridge, then we know pcib is actually a * PCIe/PCI bridge. */ + pcip = device_get_parent(pcib); + pcibp = device_get_parent(pcip); if (!bridge_is_pcie && pci_find_cap(pcibp, PCIY_EXPRESS, &cap_offset) == 0) { pcie_flags = pci_read_config(pcibp, @@ -337,11 +323,9 @@ bool bus_dma_iommu_set_buswide(device_t dev) { struct iommu_unit *unit; - device_t parent; u_int busno, slot, func; - parent = device_get_parent(dev); - if (device_get_devclass(parent) != devclass_find("pci")) + if (!is_pci_device(dev)) return (false); unit = iommu_find(dev, bootverbose); if (unit == NULL) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index adf3daea66fd..034f34e2dde2 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -6535,11 +6535,9 @@ device_t pci_find_pcie_root_port(device_t dev) { struct pci_devinfo *dinfo; - devclass_t pci_class; device_t pcib, bus; - pci_class = devclass_find("pci"); - KASSERT(device_get_devclass(device_get_parent(dev)) == pci_class, + KASSERT(is_pci_device(dev), ("%s: non-pci device %s", __func__, device_get_nameunit(dev))); /* @@ -6555,11 +6553,7 @@ pci_find_pcie_root_port(device_t dev) KASSERT(pcib != NULL, ("%s: null bridge of %s", __func__, device_get_nameunit(bus))); - /* - * pcib's parent must be a PCI bus for this to be a - * PCI-PCI bridge. - */ - if (device_get_devclass(device_get_parent(pcib)) != pci_class) + if (!is_pci_device(pcib)) return (NULL); dinfo = device_get_ivars(pcib); diff --git a/sys/dev/pci/vga_pci.c b/sys/dev/pci/vga_pci.c index 39b2fcab67b4..72c93e201d96 100644 --- a/sys/dev/pci/vga_pci.c +++ b/sys/dev/pci/vga_pci.c @@ -111,8 +111,7 @@ vga_pci_is_boot_display(device_t dev) */ pcib = device_get_parent(device_get_parent(dev)); - if (device_get_devclass(device_get_parent(pcib)) == - devclass_find("pci")) { + if (is_pci_device(pcib)) { /* * The parent bridge is a PCI-to-PCI bridge: check the * value of the "VGA Enable" bit. @@ -186,8 +185,7 @@ vga_pci_map_bios(device_t dev, size_t *size) #endif pcib = device_get_parent(device_get_parent(dev)); - if (device_get_devclass(device_get_parent(pcib)) == - devclass_find("pci")) { + if (is_pci_device(pcib)) { /* * The parent bridge is a PCI-to-PCI bridge: check the * value of the "VGA Enable" bit. diff --git a/sys/dev/vnic/thunder_bgx_fdt.c b/sys/dev/vnic/thunder_bgx_fdt.c index 20a5b54f7448..d8c5459f2914 100644 --- a/sys/dev/vnic/thunder_bgx_fdt.c +++ b/sys/dev/vnic/thunder_bgx_fdt.c @@ -285,11 +285,9 @@ bgx_fdt_traverse_nodes(uint8_t unit, phandle_t start, char *name, static device_t bgx_find_root_pcib(device_t dev) { - devclass_t pci_class; device_t pcib, bus; - pci_class = devclass_find("pci"); - KASSERT(device_get_devclass(device_get_parent(dev)) == pci_class, + KASSERT(is_pci_device(dev), ("%s: non-pci device %s", __func__, device_get_nameunit(dev))); /* Walk the bridge hierarchy until we find a non-PCI device */ @@ -298,9 +296,6 @@ bgx_find_root_pcib(device_t dev) KASSERT(bus != NULL, ("%s: null parent of %s", __func__, device_get_nameunit(dev))); - if (device_get_devclass(bus) != pci_class) - return (NULL); - pcib = device_get_parent(bus); KASSERT(pcib != NULL, ("%s: null bridge of %s", __func__, device_get_nameunit(bus))); @@ -309,7 +304,7 @@ bgx_find_root_pcib(device_t dev) * If the parent of this PCIB is not PCI * then we found our root PCIB. */ - if (device_get_devclass(device_get_parent(pcib)) != pci_class) + if (!is_pci_device(pcib)) return (pcib); dev = pcib; diff --git a/sys/x86/iommu/amd_drv.c b/sys/x86/iommu/amd_drv.c index fc9770e1a32b..d45c576856eb 100644 --- a/sys/x86/iommu/amd_drv.c +++ b/sys/x86/iommu/amd_drv.c @@ -894,8 +894,7 @@ amdiommu_find_unit(device_t dev, struct amdiommu_unit **unitp, uint16_t *ridp, if (!amdiommu_enable) return (ENXIO); - if (device_get_devclass(device_get_parent(dev)) != - devclass_find("pci")) + if (!is_pci_device(dev)) return (ENXIO); bzero(&ifu, sizeof(ifu)); diff --git a/sys/x86/iommu/intel_drv.c b/sys/x86/iommu/intel_drv.c index 28db14bba95b..185ed9c1a628 100644 --- a/sys/x86/iommu/intel_drv.c +++ b/sys/x86/iommu/intel_drv.c @@ -605,16 +605,13 @@ dmar_print_path(int busno, int depth, const ACPI_DMAR_PCI_PATH *path) int dmar_dev_depth(device_t child) { - devclass_t pci_class; device_t bus, pcib; int depth; - pci_class = devclass_find("pci"); for (depth = 1; ; depth++) { bus = device_get_parent(child); pcib = device_get_parent(bus); - if (device_get_devclass(device_get_parent(pcib)) != - pci_class) + if (!is_pci_device(pcib)) return (depth); child = pcib; } @@ -623,19 +620,16 @@ dmar_dev_depth(device_t child) void dmar_dev_path(device_t child, int *busno, void *path1, int depth) { - devclass_t pci_class; device_t bus, pcib; ACPI_DMAR_PCI_PATH *path; - pci_class = devclass_find("pci"); path = path1; for (depth--; depth != -1; depth--) { path[depth].Device = pci_get_slot(child); path[depth].Function = pci_get_function(child); bus = device_get_parent(child); pcib = device_get_parent(bus); - if (device_get_devclass(device_get_parent(pcib)) != - pci_class) { + if (!is_pci_device(pcib)) { /* reached a host bridge */ *busno = pcib_get_bus(bus); return; @@ -765,8 +759,7 @@ dmar_find(device_t dev, bool verbose) /* * This function can only handle PCI(e) devices. */ - if (device_get_devclass(device_get_parent(dev)) != - devclass_find("pci")) + if (!is_pci_device(dev)) return (NULL); dev_domain = pci_get_domain(dev);