Author: manu Date: Fri May 17 17:05:16 2019 New Revision: 347930 URL: https://svnweb.freebsd.org/changeset/base/347930
Log: pci: ecam: Correctly parse memory and IO region When activating a resource do not compare the resource id to the adress. Treat IO region as MEMORY region too. Submitted by: Tuan Phan <tp...@amperecomputing.com> (Original Version) Sponsored by: Ampere Computing, LLC Differential Revision: https://reviews.freebsd.org/D20214 Modified: head/sys/dev/pci/pci_host_generic.c head/sys/dev/pci/pci_host_generic_acpi.c Modified: head/sys/dev/pci/pci_host_generic.c ============================================================================== --- head/sys/dev/pci/pci_host_generic.c Fri May 17 17:04:01 2019 (r347929) +++ head/sys/dev/pci/pci_host_generic.c Fri May 17 17:05:16 2019 (r347930) @@ -359,29 +359,30 @@ generic_pcie_activate_resource(device_t dev, device_t switch (type) { case SYS_RES_IOPORT: + case SYS_RES_MEMORY: found = 0; for (i = 0; i < MAX_RANGES_TUPLES; i++) { pci_base = sc->ranges[i].pci_base; phys_base = sc->ranges[i].phys_base; size = sc->ranges[i].size; - if ((rid > pci_base) && (rid < (pci_base + size))) { + if ((rman_get_start(r) >= pci_base) && (rman_get_start(r) < (pci_base + size))) { found = 1; break; } } if (found) { - rman_set_start(r, rman_get_start(r) + phys_base); - rman_set_end(r, rman_get_end(r) + phys_base); + rman_set_start(r, rman_get_start(r) - pci_base + phys_base); + rman_set_end(r, rman_get_end(r) - pci_base + phys_base); res = BUS_ACTIVATE_RESOURCE(device_get_parent(dev), child, type, rid, r); } else { device_printf(dev, - "Failed to activate IOPORT resource\n"); + "Failed to activate %s resource\n", + type == SYS_RES_IOPORT ? "IOPORT" : "MEMORY"); res = 0; } break; - case SYS_RES_MEMORY: case SYS_RES_IRQ: res = BUS_ACTIVATE_RESOURCE(device_get_parent(dev), child, type, rid, r); Modified: head/sys/dev/pci/pci_host_generic_acpi.c ============================================================================== --- head/sys/dev/pci/pci_host_generic_acpi.c Fri May 17 17:04:01 2019 (r347929) +++ head/sys/dev/pci/pci_host_generic_acpi.c Fri May 17 17:05:16 2019 (r347930) @@ -148,8 +148,6 @@ pci_host_generic_acpi_parse_resource(ACPI_RESOURCE *re off = res->Data.Address32.Address.TranslationOffset; break; case ACPI_RESOURCE_TYPE_ADDRESS64: - if (res->Data.Address.ResourceType != ACPI_MEMORY_RANGE) - break; min = res->Data.Address64.Address.Minimum; max = res->Data.Address64.Address.Maximum; off = res->Data.Address64.Address.TranslationOffset; @@ -293,7 +291,7 @@ pci_host_generic_acpi_attach(device_t dev) continue; /* empty range element */ if (sc->base.ranges[tuple].flags & FLAG_MEM) { error = rman_manage_region(&sc->base.mem_rman, - phys_base, phys_base + size - 1); + pci_base, pci_base + size - 1); } else if (sc->base.ranges[tuple].flags & FLAG_IO) { error = rman_manage_region(&sc->base.io_rman, pci_base + PCI_IO_WINDOW_OFFSET, _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"