git: b9efaeb87a8f - main - tb_pci: Don't try to attach to PCI buses that aren't below a PCI-PCI brige
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 03 Nov 2025 15:31:51 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=b9efaeb87a8f9cfc0cd87076a8b314785d6e04d9
commit b9efaeb87a8f9cfc0cd87076a8b314785d6e04d9
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-11-03 15:24:23 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
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");