The branch main has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=0eb901f760078c9d0402fa4df522c099f0e96cb0

commit 0eb901f760078c9d0402fa4df522c099f0e96cb0
Author:     Greg V <[email protected]>
AuthorDate: 2021-09-20 20:05:49 +0000
Commit:     Bjoern A. Zeeb <[email protected]>
CommitDate: 2021-09-27 17:19:05 +0000

    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 372c142b4fc,
    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
---
 sys/dev/pci/pci_host_generic.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c
index 22b3ccdc17b1..03e8baa1b5cf 100644
--- a/sys/dev/pci/pci_host_generic.c
+++ b/sys/dev/pci/pci_host_generic.c
@@ -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),
 
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to