Page MenuHomeFreeBSD

pci_host_generic: implement bus_translate_resource (for LinuxKPI)
ClosedPublic

Authored by val_packett.cool on Jul 1 2021, 5:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 21, 9:16 PM
Unknown Object (File)
Fri, Apr 19, 12:23 AM
Unknown Object (File)
Fri, Apr 12, 12:57 PM
Unknown Object (File)
Sun, Apr 7, 7:40 AM
Unknown Object (File)
Feb 23 2024, 5:15 AM
Unknown Object (File)
Jan 25 2024, 10:52 AM
Unknown Object (File)
Jan 15 2024, 8:28 PM
Unknown Object (File)
Jan 3 2024, 8:38 AM

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
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

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

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.