Page MenuHomeFreeBSD

pci_host_generic: implement bus_translate_resource (for LinuxKPI)
AcceptedPublic

Authored by greg_unrelenting.technology on Jul 1 2021, 5:53 PM.

Details

Summary

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 https://github.com/freebsd/drm-kmod/issues/84 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

Repository
rS FreeBSD src repository - subversion
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 40259
Build 37148: arc lint + arc unit

Event Timeline

hselasky added inline comments.
sys/dev/pci/pci_host_generic.c
327

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.