svn commit: r330114 - head/sys/arm64/arm64
Andrew Turner
andrew at FreeBSD.org
Wed Feb 28 15:25:48 UTC 2018
Author: andrew
Date: Wed Feb 28 15:25:47 2018
New Revision: 330114
URL: https://svnweb.freebsd.org/changeset/base/330114
Log:
Count the number of GIC redistributors in the ACPI tables. The GICv3 driver
needs this to allocate memory, and connect the CPUs to the interrupt
controller.
Sponsored by: DARPA, AFRL
Sponsored by: Cavium (Hardware)
Modified:
head/sys/arm64/arm64/gic_v3_acpi.c
Modified: head/sys/arm64/arm64/gic_v3_acpi.c
==============================================================================
--- head/sys/arm64/arm64/gic_v3_acpi.c Wed Feb 28 15:18:31 2018 (r330113)
+++ head/sys/arm64/arm64/gic_v3_acpi.c Wed Feb 28 15:25:47 2018 (r330114)
@@ -206,7 +206,42 @@ gic_v3_acpi_probe(device_t dev)
return (BUS_PROBE_NOWILDCARD);
}
+static void
+madt_count_redistrib(ACPI_SUBTABLE_HEADER *entry, void *arg)
+{
+ struct gic_v3_softc *sc = arg;
+
+ if (entry->Type == ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR)
+ sc->gic_redists.nregions++;
+}
+
static int
+gic_v3_acpi_count_regions(device_t dev)
+{
+ struct gic_v3_softc *sc;
+ ACPI_TABLE_MADT *madt;
+ vm_paddr_t physaddr;
+
+ sc = device_get_softc(dev);
+
+ physaddr = acpi_find_table(ACPI_SIG_MADT);
+ if (physaddr == 0)
+ return (ENXIO);
+
+ madt = acpi_map_table(physaddr, ACPI_SIG_MADT);
+ if (madt == NULL) {
+ device_printf(dev, "Unable to map the MADT\n");
+ return (ENXIO);
+ }
+
+ acpi_walk_subtables(madt + 1, (char *)madt + madt->Header.Length,
+ madt_count_redistrib, sc);
+ acpi_unmap_table(madt);
+
+ return (sc->gic_redists.nregions > 0 ? 0 : ENXIO);
+}
+
+static int
gic_v3_acpi_attach(device_t dev)
{
struct gic_v3_softc *sc;
@@ -216,8 +251,9 @@ gic_v3_acpi_attach(device_t dev)
sc->dev = dev;
sc->gic_bus = GIC_BUS_ACPI;
- /* TODO: Count these correctly */
- sc->gic_redists.nregions = 1;
+ err = gic_v3_acpi_count_regions(dev);
+ if (err != 0)
+ goto error;
err = gic_v3_attach(dev);
if (err != 0)
More information about the svn-src-head
mailing list