Commit 0eb901f7 authored by Greg V's avatar Greg V Committed by Bjoern A. Zeeb
Browse files

pci_host_generic: implement bus_translate_resource (for LinuxKPI)

In D21096 BUS_TRANSLATE_RESOURCE was introduced to allow LinuxKPI to get
physical addresses in pci_resource_start for PowerPC and implemented
in ofw_pci.
When the translation was implemented in pci_host_generic in 372c142b,
this method was not implemented; instead a local static function was
added for a similar purpose.
Rename the static function to "_common" and implement the bus function
as a wrapper around that.  With this a LinuxKPI driver using
physical addresses correctly finds the configuration registers of
the GPU.
This unbreaks amdgpu on NXP Layerscape LX2160A SoC (SolidRun HoneyComb
LX2K workstation) which has a Translation Offset in ACPI for
below-4G PCI addresses.

More info:	https://github.com/freebsd/drm-kmod/issues/84
Tested by:	dan.kotowski_a9development.com
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D30986
parent b1e2f063
......@@ -326,7 +326,7 @@ pci_host_generic_core_release_resource(device_t dev, device_t child, int type,
}
static bool
generic_pcie_translate_resource(device_t dev, int type, rman_res_t start,
generic_pcie_translate_resource_common(device_t dev, int type, rman_res_t start,
rman_res_t end, rman_res_t *new_start, rman_res_t *new_end)
{
struct generic_pcie_core_softc *sc;
......@@ -382,6 +382,16 @@ generic_pcie_translate_resource(device_t dev, int type, rman_res_t start,
return (found);
}
static int
generic_pcie_translate_resource(device_t bus, int type,
rman_res_t start, rman_res_t *newstart)
{
rman_res_t newend; /* unused */
return (!generic_pcie_translate_resource_common(
bus, type, start, 0, newstart, &newend));
}
struct resource *
pci_host_generic_core_alloc_resource(device_t dev, device_t child, int type,
int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
......@@ -406,7 +416,7 @@ pci_host_generic_core_alloc_resource(device_t dev, device_t child, int type,
type, rid, start, end, count, flags));
/* Translate the address from a PCI address to a physical address */
if (!generic_pcie_translate_resource(dev, type, start, end, &phys_start,
if (!generic_pcie_translate_resource_common(dev, type, start, end, &phys_start,
&phys_end)) {
device_printf(dev,
"Failed to translate resource %jx-%jx type %x for %s\n",
......@@ -458,7 +468,7 @@ generic_pcie_activate_resource(device_t dev, device_t child, int type,
start = rman_get_start(r);
end = rman_get_end(r);
if (!generic_pcie_translate_resource(dev, type, start, end, &start,
if (!generic_pcie_translate_resource_common(dev, type, start, end, &start,
&end))
return (EINVAL);
rman_set_start(r, start);
......@@ -529,6 +539,7 @@ static device_method_t generic_pcie_methods[] = {
DEVMETHOD(bus_activate_resource, generic_pcie_activate_resource),
DEVMETHOD(bus_deactivate_resource, generic_pcie_deactivate_resource),
DEVMETHOD(bus_release_resource, pci_host_generic_core_release_resource),
DEVMETHOD(bus_translate_resource, generic_pcie_translate_resource),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment