Date: Wed, 28 Feb 2018 15:25:47 +0000 (UTC) From: Andrew Turner <andrew@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330114 - head/sys/arm64/arm64 Message-ID: <201802281525.w1SFPloF077137@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802281525.w1SFPloF077137>