Page MenuHomeFreeBSD

pci_host_generic: implement bus_translate_resource (for LinuxKPI)

Authored by on Jul 1 2021, 5:53 PM.
Referenced Files
Unknown Object (File)
Sat, Nov 25, 5:00 PM
Unknown Object (File)
Oct 16 2023, 9:57 AM
Unknown Object (File)
Oct 13 2023, 3:37 AM
Unknown Object (File)
Sep 16 2023, 5:25 AM
Unknown Object (File)
Sep 6 2023, 4:08 AM
Unknown Object (File)
Sep 6 2023, 4:01 AM
Unknown Object (File)
Aug 15 2023, 9:37 PM
Unknown Object (File)
Aug 5 2023, 5:54 AM



This fixes e.g. amdgpu operation on the NXP Layerscape LX2160A SoC (powering the SolidRun HoneyComb LX2K workstation) which has a Translation Offset in ACPI for below-4G PCI addresses.

See for our long debugging session :)

tl;dr due to how Linux drivers are written, LinuxKPI requires raw physical memory addresses.
In D21096 / rS350570, a BUS_TRANSLATE_RESOURCE method was introduced to allow LinuxKPI to get physical addresses in pci_resource_start, this was done for PowerPC and implemented in ofw_pci.
When translation was implemented in pci_host_generic in r10:372c142b4fc almost a year later, this method was not implemented — instead a local static function was added for a similar purpose.
And that's why GPUs were mysteriously broken on the LX2K, instead of talking to the GPU's configuration register area, the driver was talking to something else and receiving all zeros.

BIKESHEDDING TIME: Obviously this first version of the patch is not beautiful. Having a second wrapper function that throws out the end is… meh :/

Would it be fine to just convert to the start-only API, and recalculate end in callers based on start and the size? (And if not, any suggestions on naming these, any other changes?)

Test Plan

Diff Detail

rG FreeBSD src repository
Lint Not Applicable
Tests Not Applicable

Event Timeline

hselasky added inline comments.

use the word _common instead of _end .

This revision is now accepted and ready to land.Jul 4 2021, 9:48 AM

I'll have a look to do this the next two days as I have further changes in that area pending.