git: bd93b5f79ab4 - main - pci_host_generic: stop address translation in bus_alloc_resource

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Mon, 26 Sep 2022 19:26:03 UTC
The branch main has been updated by kevans:

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

commit bd93b5f79ab489fb0ed6ab25d6be48242eb8c028
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2022-09-26 19:24:21 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2022-09-26 19:25:13 +0000

    pci_host_generic: stop address translation in bus_alloc_resource
    
    Translating the provided range prior to rman_reserve_resource(9) is
    decidedly wrong; the caller may be trying to do a wildcard allocation,
    for which the implementation is expected to DTRT and clamp the range to
    what's actually feasible.
    
    We don't use the resulting translation here anyways, so just remove it
    entirely -- the rman in the default implementation is derived from
    sc->ranges, so the translation should trivially succeed every time as
    long as the reservation succeeded.  If something has gone awry in a
    derived driver, we'll detect it when we translate prior to activation,
    so there's likely no diagnostic value in retaining the translation after
    reservation either.
    
    Reviewed by:    andrew
    Noticed by:     jhb
    Differential Revision:  https://reviews.freebsd.org/D36618
---
 sys/dev/pci/pci_host_generic.c | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/sys/dev/pci/pci_host_generic.c b/sys/dev/pci/pci_host_generic.c
index 31462a198541..fbc9c2e1d3c2 100644
--- a/sys/dev/pci/pci_host_generic.c
+++ b/sys/dev/pci/pci_host_generic.c
@@ -436,7 +436,6 @@ pci_host_generic_core_alloc_resource(device_t dev, device_t child, int type,
 	struct generic_pcie_core_softc *sc;
 	struct resource *res;
 	struct rman *rm;
-	rman_res_t phys_start, phys_end;
 
 	sc = device_get_softc(dev);
 
@@ -452,16 +451,6 @@ pci_host_generic_core_alloc_resource(device_t dev, device_t child, int type,
 		return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child,
 		    type, rid, start, end, count, flags));
 
-	/* Translate the address from a PCI address to a physical address */
-	if (generic_pcie_translate_resource_common(dev, type, start, end,
-	    &phys_start, &phys_end) != 0) {
-		device_printf(dev,
-		    "Failed to translate resource %jx-%jx type %x for %s\n",
-		    (uintmax_t)start, (uintmax_t)end, type,
-		    device_get_nameunit(child));
-		return (NULL);
-	}
-
 	if (bootverbose) {
 		device_printf(dev,
 		    "rman_reserve_resource: start=%#jx, end=%#jx, count=%#jx\n",