Page MenuHomeFreeBSD

pci: bcm2838: cleanup on attach failure to fix devmatch panic
AcceptedPublic

Authored by kevans on Sat, May 9, 2:59 AM.
Tags
None
Referenced Files
F157657144: D56897.id.diff
Sat, May 23, 7:06 PM
Unknown Object (File)
Fri, May 22, 12:58 AM
Unknown Object (File)
Fri, May 22, 12:41 AM
Unknown Object (File)
Wed, May 20, 12:56 PM
Unknown Object (File)
Mon, May 18, 2:05 AM
Unknown Object (File)
Sun, May 17, 7:57 PM
Unknown Object (File)
Fri, May 15, 8:17 AM
Unknown Object (File)
Thu, May 14, 11:46 PM

Details

Reviewers
jhb
br
andrew
imp
Group Reviewers
arm64
Summary

Specifically on the RPi CM4, we currently don't set the controller up
right and it never moves into the ready state (we don't observe the link
active bit). Failure to cleanup here actually results in a panic not
long after, due to a use-after-free in the rman bits. Further down in
pci_host_generic, we have some rman stashed in the softc that are
initialized and placed onto the rman tailq, then the softc is later
freed without an rman_fini() to pull them off of the tailq properly.

Note that PCI-E on this board still isn't functional after this patch,
but it does at least allow the board to boot out of the box without
having to disable devmatch.

Shout-out to Vince <git@darkain.com> for the extensive debugging and
analysis to arrive at this conclusion.

Diff Detail

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

Event Timeline

kevans requested review of this revision.Sat, May 9, 2:59 AM

An update for the commit message.

Yes, PCIe is working!

My initial testing was with a specific Broadcom PCIe NIC. The CM4 for whatever reason doesn't like this NIC. I have two of them, both fail on this board. They were tested directly in the board itself, and through a PCIe switch between them and the board. However, further testing, virtually everything is working. This includes the mentioned PCIe switch, XHCI/USB3 card, multiple Intel NICs, Emulex NICs, Realtek NICs, and Intel Optane NVMe.

Our initial assumption of "PCIe doesnt work even with this patch" was wrong because I was only testing with what appears to be a single incompatible card.

Otherwise, with this patch, the CM4 now properly boots up without boot-looping anymore if no PCIe device is available!

This revision is now accepted and ready to land.Mon, May 11, 3:41 PM

An update for the commit message.

Yes, PCIe is working!

My initial testing was with a specific Broadcom PCIe NIC. The CM4 for whatever reason doesn't like this NIC. I have two of them, both fail on this board. They were tested directly in the board itself, and through a PCIe switch between them and the board. However, further testing, virtually everything is working. This includes the mentioned PCIe switch, XHCI/USB3 card, multiple Intel NICs, Emulex NICs, Realtek NICs, and Intel Optane NVMe.

Our initial assumption of "PCIe doesnt work even with this patch" was wrong because I was only testing with what appears to be a single incompatible card.

Otherwise, with this patch, the CM4 now properly boots up without boot-looping anymore if no PCIe device is available!

How about replacing that pargagraph with:

Note that PCIe on this board won't come up at boot without something                                            
plugged in, so it currently can't be booted with an empty slot with the                                         
intent to hotplug a supported card.  Some issues with controller startup                                        
have been observed with Broadcom NICs in the wild, but no problems have                                         
been observed with other NICs and a variety of different PCIe cards.