From nobody Tue Jun 23 16:28:24 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 4gl9VK0ybcz6hhbS for ; Tue, 23 Jun 2026 16:28:25 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gl9VJ5Tcyz3MrN for ; Tue, 23 Jun 2026 16:28:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782232104; 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=qfSYQpF45Y0aplB1N6Mftq6nf6JKHLNVDR6cUJlhz5w=; b=jVCJJRCbiU/zF3xa+tGK7yA/0Tdicj3iR9HOWy5TTD4swwh1UCXF6pd5LYKIM6jEhc/8X2 +jKTPORSGrzVRGHlJrS+lzlYXJoNzP78VgmsvlGM0m9d6c6Q1Oz5oL2+gBYyizUuyqf2aw /SAUb9ODL0Q7SKQSkgKc4EKKJI85BS82hoG4Fbku/e5+nKpNSoqGxLkzqZjUtqxLzoRaUE +ktg8aL4TqBD9mJTTtUS0iPvRjFJcvCLDURVdVYudVUt6qP+uPD34YYUpqBQo23HucgrwQ 980V9NOnxdStGeHL1gEmyvigluI+W6bZQCoN+iQ5lj08FZPbDPPq+2kOV74P/g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782232104; a=rsa-sha256; cv=none; b=Nzikqzq+z81LVR5o3eYbuF1dppUye6guZ+EQz4IlxsBqKXJtrCk0gevvYe7sDsXuh2s87m aq/0VLOeXTRterPjeLlGIM0x1u5Khr2utmurLeRcVyFGiU0uZz67z5PZtlcnovJ9e+RmBH 6fUi3JlqTVM44AR4J07h+wMEk4dMAgxkwkHyqkrVF3AOLSZ78bK3feIvSWcGdxR0h0ZxXU UQgGBx6kS0aARCi1PJlyfMhBXoXWYAB6kUghIwOU/FmXFIaDlCZjlDDOt/Q2QhLo0M3f0U +XhyzDoaT9a7147bgN9FfqsZRbaN1YKLrykkASzQ8KMbWMQtPDQhqDLmwflmkQ== 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=1782232104; 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=qfSYQpF45Y0aplB1N6Mftq6nf6JKHLNVDR6cUJlhz5w=; b=DKAFE31T+D5MfMXHNbPyDpjI8AreGiA+LA0BzYZAGpPLZgaqs/T2PBJUlu2AcL4si4a17c tosPtkA8+Q8rRy3g+T3I+YhAg/lbrz2CdLxwacek/JPIZh6mAVgmOM1wDBMR3PAEsQK/0k GG5zFOLOiIKz4HcEk2Srvt4Ut8EppQSSOBKpX6T/FGYWMJ/RzBU37sHYhuDeH9jk/bKpCv KbKHjg7CZfVX1PzPEPNGptN2IQbiKTlAPbRw572nA218+XXSnVtQF/UWeE0mfgtK98DF1M NQzK91/otpepw3YYjczNW5s8O6E7rAqn8I6HlyRf6FQS+VMmEBehB/Hq2lw1fw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gl9VJ4QldzhHx for ; Tue, 23 Jun 2026 16:28:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 27819 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 23 Jun 2026 16:28:24 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: e375116a4903 - stable/15 - pci: Add is_pci_device helper function 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: e375116a49035df765c1197f980d79066f757ef0 Auto-Submitted: auto-generated Date: Tue, 23 Jun 2026 16:28:24 +0000 Message-Id: <6a3ab428.27819.5fd40007@gitrepo.freebsd.org> The branch stable/15 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e375116a49035df765c1197f980d79066f757ef0 commit e375116a49035df765c1197f980d79066f757ef0 Author: John Baldwin AuthorDate: 2026-05-18 18:50:39 +0000 Commit: John Baldwin CommitDate: 2026-06-23 16:08:55 +0000 pci: Add is_pci_device helper function This returns true if a given device is a PCI device (child of a PCI bus). Reviewed by: bz, kib Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D56996 (cherry picked from commit ffcf5e356644252f2f6c89ba01057af45c216559) --- share/man/man9/Makefile | 3 ++- share/man/man9/pci.9 | 11 ++++++++++- sys/dev/pci/pci.c | 11 +++++++++++ sys/dev/pci/pcivar.h | 1 + 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 0bdb66f32c65..7131fbcfd798 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1796,7 +1796,8 @@ MLINKS+=osd.9 osd_call.9 \ osd.9 osd_set_reserved.9 MLINKS+=panic.9 vpanic.9 \ panic.9 KERNEL_PANICKED.9 -MLINKS+=pci.9 pci_alloc_msi.9 \ +MLINKS+=pci.9 is_pci_device.9 \ + pci.9 pci_alloc_msi.9 \ pci.9 pci_alloc_msix.9 \ pci.9 pci_clear_pme.9 \ pci.9 pci_disable_busmaster.9 \ diff --git a/share/man/man9/pci.9 b/share/man/man9/pci.9 index 871f69f887a6..4d69d3a4240f 100644 --- a/share/man/man9/pci.9 +++ b/share/man/man9/pci.9 @@ -23,11 +23,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd March 27, 2025 +.Dd May 18, 2026 .Dt PCI 9 .Os .Sh NAME .Nm pci , +.Nm is_pci_device , .Nm pci_alloc_msi , .Nm pci_alloc_msix , .Nm pci_clear_pme , @@ -80,6 +81,8 @@ .In sys/bus.h .In dev/pci/pcireg.h .In dev/pci/pcivar.h +.Ft bool +.Fn is_pci_device "device_t dev" .Ft int .Fn pci_alloc_msi "device_t dev" "int *count" .Ft int @@ -202,6 +205,12 @@ device information, device configuration, and message signaled interrupts. +.Pp +The +.Fn is_pci_device +function can be used to determine if +.Fa dev +is a PCI device. .Ss Raw Configuration Access The .Fn pci_read_config diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 9e4b64f03171..83bce77f3b05 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -6994,6 +6994,17 @@ pci_print_faulted_dev(void) } } +bool +is_pci_device(device_t dev) +{ + devclass_t pci_class; + + if (device_get_parent(dev) == NULL) + return (false); + pci_class = devclass_find("pci"); + return (device_get_devclass(device_get_parent(dev)) == pci_class); +} + #ifdef DDB DB_SHOW_COMMAND_FLAGS(pcierr, pci_print_faulted_dev_db, DB_CMD_MEMSAFE) { diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index 696e1c688c68..bcd4d2d35b54 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -676,6 +676,7 @@ pci_child_added(device_t dev) return (PCI_CHILD_ADDED(device_get_parent(dev), dev)); } +bool is_pci_device(device_t dev); device_t pci_find_bsf(uint8_t, uint8_t, uint8_t); device_t pci_find_dbsf(uint32_t, uint8_t, uint8_t, uint8_t); device_t pci_find_device(uint16_t, uint16_t);