From nobody Mon Nov 03 15:31:51 2025 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 4d0bD7725mz6542F; Mon, 03 Nov 2025 15:31:51 +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" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4d0bD76XWzz3Zbd; Mon, 03 Nov 2025 15:31:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762183911; 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=rrzxYuvxrJfMB6zGt0jdj3STPWtL5MR5me+BOwcHAX4=; b=dll8TBt7Wi4MBvf9m6BfYzM/njBVrrklw5hneeZXvEzVbd7Pi09r19MZAxqbJLzjEfPWjl N791afTTCaUfoG7YiFS9AvYwQR+fjhNfNRHpeQ8Cy2bux765pfShD5VAGaKoXCuXWsfY0J 0lY7Jd/UJAVlz8pKHrfwzdKA5H+9cDhGojuMkty4axp8DII8HPfLTQdKiS85Aj0/aToeFJ N3AhdrxFVPmZx9KvuUNZFBVUmzE5iwwS2aOMCM4SBHDq0PDJ0mIP6OOlLpxGzyGVPHlZd/ ibtFVGUQk94FWbd+B5mjsClTEowNyQ9m0gsDhKuudc3MVTB53hcT6ZPYhC+Jnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762183911; 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=rrzxYuvxrJfMB6zGt0jdj3STPWtL5MR5me+BOwcHAX4=; b=DjSaS6x4K/Nq+kfLLsoYVjjdXsS9GvH5VubqqSS8VB7lye6JpsNfM24Fp+Dymg5GeHngAL 8ygDIcP2Te0eBApkJBpO1Md9v7/Ls3+sStwal6BKSNSCdyKUdMvTooiriCFnb1//brpZke DBECtengrOOzEFgCaVmPxqo59CMwtGcTA7G+sQ1AIparrWf060N1H43J7opyMCo9WpzMJD tkfeOfOY0AejMCiDcd7FCNUJC1qOSbbCwVh0Gz8L2Rpyxi363Zisqg2GWayAif2omWXmIO tz2DNTOPEi13UbZvvD+Oq2IZrfMQ5fsBSUkQJ9ypxGsAQ9I05uKKbH6gR5bQjw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1762183911; a=rsa-sha256; cv=none; b=UuDShnMTj6Cqe6szn7MhbQOAcv268eLn/KB3HbyznHE7gkWHNAyjxeZKZ7hPijPbJv6DZ4 59GbE5UN+RsFnNkxWC4jYkWhi1qwdgHpsKG/DHYQHA7VhNjMcqweV0y0Vf98uLYOpSrC/w WKBRICvIPwYqOLAlNx2pYgTFF+lYAQrDs/WaYH7iWFiVX4oOUaV3KCreZLQzoH+za3hl6E nSEBh+20f1QaQ9OevmN1Jscc/aLvFkbWvoygT4Ux4Rs20kzsdeub8huJsOcAkwqKBwjWkw 2WkHbTvZFQ4tndkPUrSL7UL2mZ7c1EeaDHwZbXungTFnFgNRa9b90LxvyCFa/w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4d0bD7674Rz1xK; Mon, 03 Nov 2025 15:31:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 5A3FVptP000152; Mon, 3 Nov 2025 15:31:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5A3FVplr000149; Mon, 3 Nov 2025 15:31:51 GMT (envelope-from git) Date: Mon, 3 Nov 2025 15:31:51 GMT Message-Id: <202511031531.5A3FVplr000149@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: b9efaeb87a8f - main - tb_pci: Don't try to attach to PCI buses that aren't below a PCI-PCI brige 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: b9efaeb87a8f9cfc0cd87076a8b314785d6e04d9 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=b9efaeb87a8f9cfc0cd87076a8b314785d6e04d9 commit b9efaeb87a8f9cfc0cd87076a8b314785d6e04d9 Author: John Baldwin AuthorDate: 2025-11-03 15:24:23 +0000 Commit: John Baldwin CommitDate: 2025-11-03 15:24:23 +0000 tb_pci: Don't try to attach to PCI buses that aren't below a PCI-PCI brige This driver is a subclass of the normal PCI bus driver that is intended to be used for the logical child bus of a Thunderbolt PCI-PCI bridge device. To determine if a given PCI bus's parent is a TB bridge, it examines the PCI device IDs of the parent pcibX device. However, this only works for pcibX devices that are actual PCI-PCI bridges and panics for PCI buses that are children of host bridges such as the pci0 child of pcib0. Probably this should not be reading device IDs (as that doesn't tell you if the device driver for the PCI-PCI bridge is actually a TB driver). Instead, the TB PCI-PCI driver should be exporting a new IVAR (with a globally unique number as we do for ACPI handles) that returns the TB generation and the probe routine for this PCI bus driver should be checking for that IVAR (the way acpi_pci.c checks for the presence of an ACPI handle). This fixes a panic on boot if tb.ko is loaded at boot time (which the driver recommends for certain chipsets). Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D53202 --- sys/dev/thunderbolt/tb_pcib.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sys/dev/thunderbolt/tb_pcib.c b/sys/dev/thunderbolt/tb_pcib.c index 00738984ad1c..bc4fc1ce00ec 100644 --- a/sys/dev/thunderbolt/tb_pcib.c +++ b/sys/dev/thunderbolt/tb_pcib.c @@ -557,8 +557,20 @@ static int tb_pci_probe(device_t dev) { struct tb_pcib_ident *n; + device_t parent; + devclass_t dc; - if ((n = tb_pcib_find_ident(device_get_parent(dev))) != NULL) { + /* + * This driver is only valid if the parent device is a PCI-PCI + * bridge. To determine that, check if the grandparent is a + * PCI bus. + */ + parent = device_get_parent(dev); + dc = device_get_devclass(device_get_parent(parent)); + if (strcmp(devclass_get_name(dc), "pci") != 0) + return (ENXIO); + + if ((n = tb_pcib_find_ident(parent)) != NULL) { switch (n->flags & TB_GEN_MASK) { case TB_GEN_TB1: device_set_desc(dev, "Thunderbolt 1 Link");