From nobody Tue Mar 10 16:53:56 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 4fVg2D6wr3z6VwkH for ; Tue, 10 Mar 2026 16:53:56 +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 "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fVg2D3FWFz3lD1 for ; Tue, 10 Mar 2026 16:53:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1773161636; 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=VS7BCez3ZEJcWYbrF6VUBfCpzrP75htjis1zL+fUQRs=; b=qLvTJ9bBM4MrssOx7a32omZRCAKcn9jKhL4M1MhbPa0XUumTxOo1q5+ndvXnCXvMFA//Ha 3vsyhsrLEoEH17xgMUfPhqk4AdbAZ3tMl6NOwcgWeZyS9B4McATsCkBIbkscjCam73DcKM YLMJM2qTkdS7N1JwJUKHcdoAJeSquPsP5PS6RIKk1IapheDZzbXb7HMyT0JTv5gOonEp1F yAX4PUeyOZ78fP51u2CIRq2kGxFHhEDN3LK7TxQZjxA5P+6RINq9mrXh0He5oXuCNAIYhj ySbrAjHls7edH2d7e5qAOENs+R1gUUoLT/Z0LQf3CzITkB7hNlb/va+A6yf7Ig== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1773161636; a=rsa-sha256; cv=none; b=DgZ/ebYs9pbYYNhD5z+ZKYBDG/M5RTy367MN+4AmSyCTCHf7V/lUcEewjJC0xMO8mdpUvQ yKxQb85YLIRQE7Y9mmu3EePmW9Y+JDFNElq/St36yXBFCxkpw5gdqmS5WihSsqqwNKDua4 WKBOHHl5998XM11T1R3AcUzqAzu2YwevjinrrlY+C6E/eAEuKsz3hPn4lu+2zbZ74PaDz4 TgmsauJeWfxdV+7eXTR+5DfckrUYltJInqZ0846EN/wXSepAnPRSutSkqf7aEEXMnRixcS Tej0rAZLmR5NAzwgscI5tbiz2fKgA7SAB177GWotOQ4xUwuMS5RuUjEN/5lKHQ== 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=1773161636; 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=VS7BCez3ZEJcWYbrF6VUBfCpzrP75htjis1zL+fUQRs=; b=cIi1f6reVLW+TBOs4Cf1o3mTnj2iG80nEG0W6jWsii5xzFGyh7EOfVut8krDJwfcZxdh+Z QidmmYCjGFzVYZ/SptSjf1YbsLveBMkIsdeto3Q8OagbWLnUbEM654byVvP7xKOJRx86W2 21xL9ISDjyi1YNGq5dDql8sQz+amYfytEd5+/03BirmcNDvAkVX2x9Vo3ELKGTfUFE9xuW l9VVudUPtRwozUDlnTOqKqSSPpOPurgC78seKVQhLNo9WMXuu/Qa/M1rAT/Oa21nGijp5G TQ/x89E1b53yo5zqDHzJD/N1Lc/gt4cefsFhOkadJgv22SSsusuTXbJMCpA2dA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fVg2D2gbMz5Xr for ; Tue, 10 Mar 2026 16:53:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 440c3 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 10 Mar 2026 16:53:56 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 7e7a1b61531a - main - pci: Export bus numbers for bridge devices in struct pci_conf 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: 7e7a1b61531a29b4a0a5cdac66b96f420e6c66e4 Auto-Submitted: auto-generated Date: Tue, 10 Mar 2026 16:53:56 +0000 Message-Id: <69b04ca4.440c3.3acee0c5@gitrepo.freebsd.org> The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=7e7a1b61531a29b4a0a5cdac66b96f420e6c66e4 commit 7e7a1b61531a29b4a0a5cdac66b96f420e6c66e4 Author: John Baldwin AuthorDate: 2026-03-10 16:49:21 +0000 Commit: John Baldwin CommitDate: 2026-03-10 16:49:21 +0000 pci: Export bus numbers for bridge devices in struct pci_conf This exports bus information about bridges to userspace via the less-privileged PCIOCGETCONF ioctl. Previously if userspace wished to query this information, it had to use direct PCI config register access which requires higher privilege. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D55771 --- share/man/man4/pci.4 | 6 ++++++ sys/dev/pci/pci.c | 3 +++ sys/dev/pci/pci_user.c | 32 +++++++++++++++++++++++++++++++- sys/sys/pciio.h | 4 +++- 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/share/man/man4/pci.4 b/share/man/man4/pci.4 index f5d42efb4f37..38a427e64f4f 100644 --- a/share/man/man4/pci.4 +++ b/share/man/man4/pci.4 @@ -244,6 +244,12 @@ structure. This should always be equivalent to the offset of the .Va pc_spare member. +.It pc_secbus +Secondary PCI bus number. +.Pq Only valid for bridge devices +.It pc_subbus +Subordinate PCI bus number. +.Pq Only valid for bridge devices .It pc_spare Reserved for future use. .El diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index a46813cc155a..0dddd2dd263f 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -798,6 +798,9 @@ pci_fill_devinfo(device_t pcib, device_t bus, int d, int b, int s, int f, devlist_entry->conf.pc_progif = cfg->progif; devlist_entry->conf.pc_revid = cfg->revid; + devlist_entry->conf.pc_secbus = cfg->bridge.br_secbus; + devlist_entry->conf.pc_subbus = cfg->bridge.br_subbus; + pci_numdevs++; pci_generation++; diff --git a/sys/dev/pci/pci_user.c b/sys/dev/pci/pci_user.c index 9768030995e7..0e23363fba73 100644 --- a/sys/dev/pci/pci_user.c +++ b/sys/dev/pci/pci_user.c @@ -81,7 +81,9 @@ struct pci_conf32 { u_int32_t pd_unit; /* device unit number */ int pd_numa_domain; /* device NUMA domain */ u_int32_t pc_reported_len;/* length of PCI data reported */ - char pc_spare[64]; /* space for future fields */ + uint8_t pc_secbus; /* secondary bus number */ + uint8_t pc_subbus; /* subordinate bus number */ + char pc_spare[62]; /* space for future fields */ }; struct pci_match_conf32 { @@ -889,6 +891,8 @@ pci_conf_for_copyout(const struct pci_conf *pcp, union pci_conf_union *pcup, pcup->pc32.pd_unit = (uint32_t)pcp->pd_unit; if (cmd == PCIOCGETCONF32) { pcup->pc32.pd_numa_domain = pcp->pd_numa_domain; + pcup->pc32.pc_secbus = pcp->pc_secbus; + pcup->pc32.pc_subbus = pcp->pc_subbus; pcup->pc32.pc_reported_len = (uint32_t)offsetof(struct pci_conf32, pc_spare); } @@ -1315,6 +1319,32 @@ pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *t else dinfo->conf.pd_numa_domain = 0; + if (dinfo->cfg.dev != NULL) { + /* + * Re-read the values in case a driver + * changed them after the device was + * initially scanned. + */ + switch (dinfo->conf.pc_hdr) { + case PCIM_HDRTYPE_BRIDGE: + dinfo->conf.pc_secbus = + pci_read_config(dinfo->cfg.dev, + PCIR_SECBUS_1, 1); + dinfo->conf.pc_subbus = + pci_read_config(dinfo->cfg.dev, + PCIR_SUBBUS_1, 1); + break; + case PCIM_HDRTYPE_CARDBUS: + dinfo->conf.pc_secbus = + pci_read_config(dinfo->cfg.dev, + PCIR_SECBUS_2, 1); + dinfo->conf.pc_subbus = + pci_read_config(dinfo->cfg.dev, + PCIR_SUBBUS_2, 1); + break; + } + } + if (pattern_buf == NULL || pci_conf_match(cmd, pattern_buf, num_patterns, &dinfo->conf) == 0) { diff --git a/sys/sys/pciio.h b/sys/sys/pciio.h index 64c0b32cb8e2..58928544f171 100644 --- a/sys/sys/pciio.h +++ b/sys/sys/pciio.h @@ -79,7 +79,9 @@ struct pci_conf { u_long pd_unit; /* device unit number */ int pd_numa_domain; /* device NUMA domain */ size_t pc_reported_len;/* length of PCI data reported */ - char pc_spare[64]; /* space for future fields */ + uint8_t pc_secbus; /* secondary bus number */ + uint8_t pc_subbus; /* subordinate bus number */ + char pc_spare[62]; /* space for future fields */ }; struct pci_match_conf {