From owner-dev-commits-src-all@freebsd.org Mon Sep 27 17:24:05 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D564C66C4D4; Mon, 27 Sep 2021 17:24:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HJ8d15Rzdz4RGf; Mon, 27 Sep 2021 17:24:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9BAC91529F; Mon, 27 Sep 2021 17:24:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 18RHO5Mr055521; Mon, 27 Sep 2021 17:24:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18RHO5TT055520; Mon, 27 Sep 2021 17:24:05 GMT (envelope-from git) Date: Mon, 27 Sep 2021 17:24:05 GMT Message-Id: <202109271724.18RHO5TT055520@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 0eb901f76007 - main - pci_host_generic: implement bus_translate_resource (for LinuxKPI) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0eb901f760078c9d0402fa4df522c099f0e96cb0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Sep 2021 17:24:05 -0000 The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=0eb901f760078c9d0402fa4df522c099f0e96cb0 commit 0eb901f760078c9d0402fa4df522c099f0e96cb0 Author: Greg V AuthorDate: 2021-09-20 20:05:49 +0000 Commit: Bjoern A. Zeeb 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),