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
F106210003: D30986.id91718.diff
Fri, Dec 27, 5:42 AM
Unknown Object (File)
Tue, Dec 17, 1:35 AM
Unknown Object (File)
Nov 3 2024, 4:30 AM
Unknown Object (File)
Nov 3 2024, 4:30 AM
Unknown Object (File)
Nov 3 2024, 4:29 AM
Unknown Object (File)
Nov 3 2024, 4:12 AM
Unknown Object (File)
Oct 4 2024, 11:30 AM
Unknown Object (File)
Oct 2 2024, 9:38 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 Passed
Unit
No Test Coverage
Build Status
Buildable 40220
Build 37109: 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.