Page MenuHomeFreeBSD

pci_host_generic: Tolerate range resource allocation failures
ClosedPublic

Authored by jhb on Apr 9 2024, 3:44 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, May 25, 3:08 PM
Unknown Object (File)
Sat, May 25, 3:08 PM
Unknown Object (File)
Thu, May 23, 11:23 PM
Unknown Object (File)
Thu, May 23, 9:40 PM
Unknown Object (File)
May 2 2024, 4:20 AM
Unknown Object (File)
Apr 11 2024, 5:16 PM
Unknown Object (File)
Apr 11 2024, 3:14 PM
Unknown Object (File)
Apr 10 2024, 12:03 AM
Subscribers

Details

Summary

QEMU for armv7 includes a PCI memory range whose CPU address is
greater than 4GB. This falls outside the range of armv7's global
mem_rman used by the nexus driver. As a result, pcib0 fails to
attach blocking all PCI devices.

Instead, change the driver to be a bit more tolerant. If allocating a
resource for a range fails, don't fail attaching the entire driver,
but do skip adding the associated PCI range to the relevant rman in
the pcib driver. This will prevent child devices from using BARs that
allocate from this range. In the case of QEMU on armv7 devices can
still allocate from an earlier PCI memory range that is within the
32-bit address space (and in fact none of the firmware-assigned memory
BARs use addresses from the upper range).

While here, reorder the operations on I/O ranges a bit: 1) print the
range under bootverbose first (rather than last) so that the range is
printed before any relevant errors for the range, 2) move
rman_manage_region last after the parent resource has been set and
allocated.

Reported by: markj, Jenkins
Fixes: d79b6b8ec267 pci_host_generic: Don't rewrite resource start address for translation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Apr 9 2024, 3:44 PM

Thank you!

sys/dev/pci/pci_host_generic.c
225

Fix style while you're here?

This revision is now accepted and ready to land.Apr 9 2024, 3:47 PM
sys/dev/pci/pci_host_generic.c
225

Yeah, and I might update the error message to match the style I used for bus_alloc_resource instead while I'm at it