From nobody Fri Mar 6 21:32:42 2026 X-Original-To: dev-commits-src-main@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 4fSKPk1BS0z6TVct for ; Fri, 06 Mar 2026 21:32:42 +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 4fSKPk0Xwtz3kSJ for ; Fri, 06 Mar 2026 21:32:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772832762; 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=fIQEjhv9Zqnih2XakQhgusDIZQ5HzzO8e2wPZ2Nfc/k=; b=WbBTbaOItIyDT2t1wuMiqepHZkRTqcEKhCfCRAbMPcFLo55zefgSx1t07Chn0D6r6bnOWm X9vKkcduxIhdBj4GTVle8kxJpEkfrm71DUfpnZfNj636+4OW9MakaBNwApWQ/XRJLDONZ7 mY2S5UibDREzw/stcvTWG3uP+5jtK0J8Z7X0mSTQTxPz26xLEMt1+9V6C4nzezCbEk9KH+ +PshDTq8CpnTeRWCyugmQGx/w+FeSW7BZq+LvBJJtiCqXgPrqR1cF3GEU9rOMB/BU5n3EI 33Aa4AgvEtkwFohlyP3dhr98gzNSk9w0+Ua9OaE4sbG8v86EiN27SCi0jLHhUw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1772832762; a=rsa-sha256; cv=none; b=AxVcLyIivnxtBp8gsBbKxfJ66zo4DSMb8o+5zpVFZ1OdsM36GSIQophP+tcm1+n72yVj8z gpFoMMeDmi9Q9AhKpNwwRiML2vMT9D+7ip9ph9IUjY4px18HcboJWkAOPTxCopa6haT6DJ +6+bxaMC+ibQrgOkOS57RA37AWYZpKJ6M6lIRvcSbdaInHj7vH9RVaIo45x/HALhgr/38v it9W+kdopFWIUc0JQ+23F1fRM8LdJH/uuW9Z6JCm+xlZAWbFVMff85xxm05ISVdwnlvJ0O 06eSXyoIq5hiGsR3X8nqS9Vzs5f0gjgYVPQc8RiA5OZQF91W7F9iPt+kG8TpEA== 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=1772832762; 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=fIQEjhv9Zqnih2XakQhgusDIZQ5HzzO8e2wPZ2Nfc/k=; b=SfFPgkneUyao+l56CZFfrivIeBB6cqH8S1iliWtUF2yXNEO4inifohx4cFLptPtHEEgVuM tEWCIht5eqIZjY36Vz5lWWwBSsYOYEptyw6uZhdfdkGzN3vUCFN7awPNZ+LeW69LcM9wMG bQoazlYQ867gABj73Oz2BxSOaq/iFeAYm3bmOrI9FsRk13hHE4wANwc0QHIxDX95OY/IAa 82Gy0FiRyfs1oiMrCRXjJ7kCXMepsHLBiBsAdG3j7laqdzSBvDlK0PEuCwtzvDqynV+esx 87x9b6yIy8xnV8bEdon5Cqi827ABeY+FoYoGjXQN7CjU9pnY2sMN7nPnv+UwUA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fSKPk06Q2zfv9 for ; Fri, 06 Mar 2026 21:32:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3a4dd by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 06 Mar 2026 21:32:42 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: ca25b1b26379 - main - devinfo: Support PCI DBSF and ACPI handles for -p List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: ca25b1b26379e27bf2bab7742a7b383ca0bfc7d2 Auto-Submitted: auto-generated Date: Fri, 06 Mar 2026 21:32:42 +0000 Message-Id: <69ab47fa.3a4dd.2fdf82d0@gitrepo.freebsd.org> The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=ca25b1b26379e27bf2bab7742a7b383ca0bfc7d2 commit ca25b1b26379e27bf2bab7742a7b383ca0bfc7d2 Author: John Baldwin AuthorDate: 2026-03-06 20:36:05 +0000 Commit: John Baldwin CommitDate: 2026-03-06 20:36:05 +0000 devinfo: Support PCI DBSF and ACPI handles for -p When matching on a name of a device, match on ACPI handles and PCI selectors in addition to device names. This can be useful for matching on devices without an attached driver. For example: devinfo -p pci0:0:31:0 Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D55673 --- usr.sbin/devinfo/devinfo.8 | 22 +++++++++++++++++- usr.sbin/devinfo/devinfo.c | 58 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/usr.sbin/devinfo/devinfo.8 b/usr.sbin/devinfo/devinfo.8 index 8bf4f9d10e17..b8acdcf524ee 100644 --- a/usr.sbin/devinfo/devinfo.8 +++ b/usr.sbin/devinfo/devinfo.8 @@ -26,7 +26,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd August 28, 2025 +.Dd March 6, 2026 .Dt DEVINFO 8 .Os .Sh NAME @@ -53,6 +53,26 @@ The following options are accepted: Display the path of .Ar dev back to the root of the device tree. +.Ar dev +can either be a device name, +the absolute path of an ACPI handle +.Po must begin with a +.Dq \e +.Pc , +or a PCI selector +.Po +either +.Sy pci Ns Fa domain Ns : Ns Fa bus Ns : Ns Fa slot Ns : Ns Fa function +or +.Sy pci Ns Fa bus Ns : Ns Fa slot Ns : Ns Fa function +.Pc . +.Pp +If +.Fl v +is specified, +each device is output on a separate line including the device name and +additional verbose information; +otherwise, a space-separated list of device names is output. .It Fl r Causes hardware resource information .Pq such as IRQ, I/O ports, I/O memory addresses diff --git a/usr.sbin/devinfo/devinfo.c b/usr.sbin/devinfo/devinfo.c index 43d88481d903..bea082ba6285 100644 --- a/usr.sbin/devinfo/devinfo.c +++ b/usr.sbin/devinfo/devinfo.c @@ -275,13 +275,69 @@ print_device_path_entry(struct devinfo_dev *dev) printf("\n"); } +/* + * This assumes the string to be compared in *cp is either space or + * nul terminated. + */ +static bool +match_value(const char *cp, const char *name) +{ + const char *end; + size_t len; + + end = strchr(cp, ' '); + if (end == NULL) + return (strcmp(cp, name) == 0); + + if (end == cp) + return (false); + + /* NB: strncmp(3) would return zero if name matches a prefix. */ + len = end - cp; + return (strlen(name) == len && memcmp(name, cp, len) == 0); +} + +static bool +device_matches_name(struct devinfo_dev *dev, const char *name) +{ + const char *cp, *val; + + if (strcmp(dev->dd_name, name) == 0) + return (true); + + if (*dev->dd_location) { + /* Permit matches on the ACPI handle stored in location. */ + if (name[0] == '\\' && (cp = strstr(dev->dd_location, + "handle=\\")) != NULL) { + if (match_value(cp + strlen("handle="), name)) + return (true); + } + + /* Permit matches on the PCI dbsf stored in location. */ + if (strncmp(name, "pci", strlen("pci")) == 0 && + (cp = strstr(dev->dd_location, "dbsf=pci")) != NULL) { + cp += strlen("dbsf=pci"); + val = name + strlen("pci"); + if (match_value(cp, val)) + return (true); + + /* Also match on pci:: for domain 0. */ + if (strncmp(cp, "0:", strlen("0:")) == 0 && + match_value(cp + strlen("0:"), val)) + return (true); + } + } + + return (false); +} + static int print_device_path(struct devinfo_dev *dev, void *xname) { const char *name = xname; int rv; - if (strcmp(dev->dd_name, name) == 0) { + if (device_matches_name(dev, name)) { print_device_path_entry(dev); return (1); }