Page MenuHomeFreeBSD

tb_pci: Don't try to attach to PCI buses that aren't below a PCI-PCI brige
ClosedPublic

Authored by jhb on Sun, Oct 19, 8:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 1, 3:26 AM
Unknown Object (File)
Thu, Oct 30, 2:37 PM
Unknown Object (File)
Thu, Oct 30, 2:37 PM
Unknown Object (File)
Tue, Oct 28, 7:07 PM
Unknown Object (File)
Fri, Oct 24, 7:56 PM
Unknown Object (File)
Fri, Oct 24, 5:41 PM
Unknown Object (File)
Tue, Oct 21, 2:07 PM
Unknown Object (File)
Tue, Oct 21, 2:07 PM
Subscribers

Details

Summary

In particular, don't try to probe PCI buses that are children of host
bridges such as the pci0 child of pcib0. This fixes a panic on boot
if tb.ko is loaded at boot time (which the driver recommends for
certain chipsets).

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 67920
Build 64803: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Sun, Oct 19, 8:01 PM

So why is this driver only valid in those cases?

In D53202#1215346, @imp wrote:

So why is this driver only valid in those cases?

The panic is that it tries to do pci_get_vendor() on pcib0 (child of acpi0) and that isn't a valid IVAR and the accessor panics. In particular, note that this driver is expecting to call tb_pcib_find_ident on its parent, and tb_pcib_find_ident assumes the device it is operating on is a PCI device with a device ID, etc. That isn't true for host bridges that are children of ACPI or OFW, etc.

Also, FWIW, this just fixes a panic when the probe routine runs against pci0 on my laptop. Later when the driver tries to attach to the actual Thunderbolt slots in my laptop it panics in a different way (the attach still fails as it does post-boot, and I get a different form of a race with the interrupt handler that still results in an interrupt handler raising a GPF, presumably due to dereferencing freed memory field with 0xdeadc0de as in the other review),

Though a better answer to the question is that this bus driver is meant to take over PCI buses that are children of TB ports, and the only way to know (currently) if a given pcib device is a TB port is to check its PCI IDs. Alternatively, TB bridges could expose some sort of new IVAR that this driver could check for instead. That would be more inline with, say, the ACPI PCI bus driver which checks for the presence of a valid ACPI_HANDLE IVAR that ACPI pcib drivers provide. Maybe we could have a new TB_GEN IVAR that TB bridges would export to children. That would perhaps be cleaner solution to this.

I'd rework the comment a little, but otherwise this is a good change now that I understand why...

sys/dev/thunderbolt/tb_pcib.c
566

I'd see if I could work in something more like "This driver has to call PCI methods on it's grandparent to determine what generation of Thunderbolt this is for" or something a little more direct.

This revision is now accepted and ready to land.Wed, Oct 29, 10:04 PM