From e0870cd4687db301f7caea5f24d092cb18ddf3b5 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Sun, 29 Nov 2020 16:22:33 +0000 Subject: [PATCH] Only set the PCI bus end when we are reducing it We read the bus end value from the _CRS method. On some systems we need to further limit it based on the MCFG table. Support this by setting a default value, then update it if needed in the _CRS table, and finally reduce it if it is past the end of the MCFG tabel. This will allow for both systems that use either method to encode this value. This partially reverts r347929, removing the error printf. Reviewed by: philip Tested by: philip, Andrey Fesenko MFC after: 2 weeks Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D27274 --- sys/dev/pci/pci_host_generic_acpi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/dev/pci/pci_host_generic_acpi.c b/sys/dev/pci/pci_host_generic_acpi.c index 77bebb3df58e..763a84d2fd53 100644 --- a/sys/dev/pci/pci_host_generic_acpi.c +++ b/sys/dev/pci/pci_host_generic_acpi.c @@ -201,7 +201,8 @@ pci_host_acpi_get_ecam_resource(device_t dev) mcfg_entry++; } if (found) { - sc->base.bus_end = mcfg_entry->EndBusNumber; + if (mcfg_entry->EndBusNumber < sc->base.bus_end) + 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", @@ -210,10 +211,9 @@ 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; - sc->base.bus_end = 255; - } else + else return (ENXIO); } @@ -246,6 +246,7 @@ pci_host_generic_acpi_init(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);