svn commit: r362240 - in stable/12/sys: arm64/arm64 dev/ahci dev/pci
Emmanuel Vadot
manu at FreeBSD.org
Tue Jun 16 20:35:03 UTC 2020
Author: manu
Date: Tue Jun 16 20:35:01 2020
New Revision: 362240
URL: https://svnweb.freebsd.org/changeset/base/362240
Log:
MFC r347440, r347929-r347930, r349588
r347440:
ahci: Check if bus is cache-coherent
We do this for FDT systems but not for ACPI ones.
Check the presence of the _CCA attribute.
Sponsored by: Ampere Computing, LLC
Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D20144
r347929:
pci: ecam: Do not warn on mismatch of bus_end
We cannot know the bus end number before parsing the MCFG table
so don't set the bus_end before that. If the MCFG table doesn't
exist we will set the configuration base address based on the _CBA
value and set the bus_end to the maximal number allowed by PCI.
Sponsored by: Ampere Computing, LLC
Differential Revision: https://reviews.freebsd.org/D20213
r347930:
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 <tphan at amperecomputing.com> (Original Version)
Sponsored by: Ampere Computing, LLC
Differential Revision: https://reviews.freebsd.org/D20214
r349588:
arm64: efi: Map memory IO region as device
Reviewed by: andrew
Sponsored by: Ampere Computing, LLC
Modified:
stable/12/sys/arm64/arm64/efirt_machdep.c
stable/12/sys/dev/ahci/ahci_generic.c
stable/12/sys/dev/pci/pci_host_generic.c
stable/12/sys/dev/pci/pci_host_generic_acpi.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/arm64/arm64/efirt_machdep.c
==============================================================================
--- stable/12/sys/arm64/arm64/efirt_machdep.c Tue Jun 16 20:35:00 2020 (r362239)
+++ stable/12/sys/arm64/arm64/efirt_machdep.c Tue Jun 16 20:35:01 2020 (r362240)
@@ -208,20 +208,14 @@ efi_create_1t1_map(struct efi_md *map, int ndesc, int
mode = VM_MEMATTR_WRITE_THROUGH;
else if ((p->md_attr & EFI_MD_ATTR_WC) != 0)
mode = VM_MEMATTR_WRITE_COMBINING;
- else if ((p->md_attr & EFI_MD_ATTR_UC) != 0)
+ else
mode = VM_MEMATTR_DEVICE;
- else {
- if (bootverbose)
- printf("EFI Runtime entry %d mapping "
- "attributes unsupported\n", i);
- mode = VM_MEMATTR_UNCACHEABLE;
- }
printf("MAP %lx mode %x pages %lu\n", p->md_phys, mode, p->md_pages);
l3_attr = ATTR_DEFAULT | ATTR_IDX(mode) | ATTR_AP(ATTR_AP_RW) |
L3_PAGE;
- if (mode == VM_MEMATTR_DEVICE)
+ if (mode == VM_MEMATTR_DEVICE || p->md_attr & EFI_MD_ATTR_XP)
l3_attr |= ATTR_UXN | ATTR_PXN;
VM_OBJECT_WLOCK(obj_1t1_pt);
Modified: stable/12/sys/dev/ahci/ahci_generic.c
==============================================================================
--- stable/12/sys/dev/ahci/ahci_generic.c Tue Jun 16 20:35:00 2020 (r362239)
+++ stable/12/sys/dev/ahci/ahci_generic.c Tue Jun 16 20:35:01 2020 (r362240)
@@ -89,6 +89,7 @@ ahci_fdt_probe(device_t dev)
static int
ahci_acpi_probe(device_t dev)
{
+ struct ahci_controller *ctlr = device_get_softc(dev);
ACPI_HANDLE h;
if ((h = acpi_get_handle(dev)) == NULL)
@@ -98,6 +99,12 @@ ahci_acpi_probe(device_t dev)
pci_get_subclass(dev) == PCIS_STORAGE_SATA &&
pci_get_progif(dev) == PCIP_STORAGE_SATA_AHCI_1_0) {
device_set_desc_copy(dev, "AHCI SATA controller");
+ if (ACPI_FAILURE(acpi_GetInteger(h, "_CCA",
+ &ctlr->dma_coherent)))
+ ctlr->dma_coherent = 0;
+ if (bootverbose)
+ device_printf(dev, "Bus is%s cache-coherent\n",
+ ctlr->dma_coherent ? "" : " not");
return (BUS_PROBE_DEFAULT);
}
Modified: stable/12/sys/dev/pci/pci_host_generic.c
==============================================================================
--- stable/12/sys/dev/pci/pci_host_generic.c Tue Jun 16 20:35:00 2020 (r362239)
+++ stable/12/sys/dev/pci/pci_host_generic.c Tue Jun 16 20:35:01 2020 (r362240)
@@ -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: stable/12/sys/dev/pci/pci_host_generic_acpi.c
==============================================================================
--- stable/12/sys/dev/pci/pci_host_generic_acpi.c Tue Jun 16 20:35:00 2020 (r362239)
+++ stable/12/sys/dev/pci/pci_host_generic_acpi.c Tue Jun 16 20:35:01 2020 (r362240)
@@ -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;
@@ -207,11 +205,7 @@ pci_host_acpi_get_ecam_resource(device_t dev)
mcfg_entry++;
}
if (found) {
- if (mcfg_entry->EndBusNumber < sc->base.bus_end) {
- device_printf(dev, "bus end mismatch! expected %d found %d.\n",
- sc->base.bus_end, (int)mcfg_entry->EndBusNumber);
- sc->base.bus_end = mcfg_entry->EndBusNumber;
- }
+ sc->base.bus_end = mcfg_entry->EndBusNumber;
base = mcfg_entry->Address;
} else {
device_printf(dev, "MCFG exists, but does not have bus %d-%d\n",
@@ -220,9 +214,10 @@ pci_host_acpi_get_ecam_resource(device_t dev)
}
} else {
status = acpi_GetInteger(handle, "_CBA", &val);
- if (ACPI_SUCCESS(status))
+ if (ACPI_SUCCESS(status)) {
base = val;
- else
+ sc->base.bus_end = 255;
+ } else
return (ENXIO);
}
@@ -259,7 +254,6 @@ pci_host_generic_acpi_attach(device_t dev)
device_printf(dev, "No _BBN, using start bus 0\n");
sc->base.bus_start = 0;
}
- sc->base.bus_end = 255;
/* Get PCI Segment (domain) needed for MCFG lookup */
status = acpi_GetInteger(handle, "_SEG", &sc->base.ecam);
@@ -297,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,
More information about the svn-src-all
mailing list