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)
Mon, Nov 11, 5:07 PM
Unknown Object (File)
Sun, Nov 10, 5:00 AM
Unknown Object (File)
Fri, Nov 8, 3:54 PM
Unknown Object (File)
Fri, Nov 8, 12:04 PM
Unknown Object (File)
Sun, Oct 20, 5:22 PM
Unknown Object (File)
Sep 30 2024, 7:27 PM
Unknown Object (File)
Sep 30 2024, 5:25 PM
Unknown Object (File)
Sep 30 2024, 4:14 PM
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