From nobody Mon May 18 18:53:30 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 4gK6QM2Pzbz6fpGm for ; Mon, 18 May 2026 18:53:31 +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 4gK6QL751kz3MKc for ; Mon, 18 May 2026 18:53:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779130411; 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=DY6JtIo4atnf+63bShKUDza7cZohrx7sPhf1z70U5C0=; b=txJ71Ll6JF20OwKA0HG2oct1rsMHjdRnjkKG0O8tesCNwE+rwXbPS4oTa03iyiVH9xP+Kp vJaNAw/PcXx8NrN1Qnl2qvZpXd+y/8Wc+ZfTCUkWrHyK3q0Bdl80A3+0kcLApyTTty7bRi gtbh6DD88RTnj+4e9M+MBFUBcxpN9X+9GL1NC+TbP/Y7cIU2y0URTi+exEvw4lRTqWFD0s 4YM/GWAGtwkXejYOChAfOSSkwy6kxzttbU3Nro7j+vTfilePVtVDL0SxWUsex6J4vXhn8O 607iBq7RVi1mF49Sna30jti+Bdoa8okXBgpZ4aa65eiavoO5ne+vPBzlG9UhDg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1779130411; a=rsa-sha256; cv=none; b=h3KCAM1FCIqW6EdMkXurL1fWLQ0rMe+Vwkj+kHlesE4/bfiOMoY/D4faPrjohfgUqVG3s2 X+uLFB3VqClCDgJazpsFpOyQLHFTAXc9HYojs6AzioTJwwV8K8Clp8TRXPGYl7xNxUHo1R P1LziUma7kI/G/keF9GO+4LbptiDyAF1jjNB9Sjf0dRlHso0HCijWNzhS8LMOsA21qa0hy zNMvzG0YbLfzLzXWTV6hq+fw913U09zAIeJ6tiClSqBBbVoJOeSxH0JCioIJuMtEp9wlWV Ti61N4pDa+2X10dWrQf5Bzj4JLn6jEAqQjorOzL+fetbtRQRhYYWySDERl3TFw== 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=1779130411; 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=DY6JtIo4atnf+63bShKUDza7cZohrx7sPhf1z70U5C0=; b=aNeGSIBiTnM55PeSyHimkoa29bqDIx39mDf6QZBXIOJ4NwTjPzXmu8MfazuHy4RMxxZnp1 zA4MUpv6TvHe3UrtaC7AJ2YXDadCP90zD2rD5shuQRAR+ktGAOuJNF8TKOu4ELWIm/ZJIL YDBnD5kjeKE/QRltmINvO+eoO1AU/5+/JpetFIxmFeW3GSx8wl6VCLRezRKrT+TUHxw0SB HT735nb/KWTvm5EZcAqpRR7pRGJxKjIthKTLzaQ96pn16qtCCDcyAn5FkyU6EsXG7LaR6m NMGFQnhMbay9oKp7SVl+U537WgY1XPl6Wn4zaOdQG+yN157Brbck4bcKJEXg0Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gK6QL6JLbzhH8 for ; Mon, 18 May 2026 18:53:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 273ee by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 18 May 2026 18:53:30 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: ffcf5e356644 - main - pci: Add is_pci_device helper function 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: ffcf5e356644252f2f6c89ba01057af45c216559 Auto-Submitted: auto-generated Date: Mon, 18 May 2026 18:53:30 +0000 Message-Id: <6a0b602a.273ee.3ae63692@gitrepo.freebsd.org> The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=ffcf5e356644252f2f6c89ba01057af45c216559 commit ffcf5e356644252f2f6c89ba01057af45c216559 Author: John Baldwin AuthorDate: 2026-05-18 18:50:39 +0000 Commit: John Baldwin CommitDate: 2026-05-18 18:50:39 +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 --- 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 fbb981891ce4..7044b6f1bb68 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1803,7 +1803,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 b5a3012accd6..adf3daea66fd 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -6993,6 +6993,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);