From owner-svn-src-head@freebsd.org Wed Feb 28 15:25:47 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DDA64F2E366; Wed, 28 Feb 2018 15:25:47 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 89AA57D251; Wed, 28 Feb 2018 15:25:47 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7DA681B42F; Wed, 28 Feb 2018 15:25:47 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1SFPlwl077138; Wed, 28 Feb 2018 15:25:47 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1SFPloF077137; Wed, 28 Feb 2018 15:25:47 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201802281525.w1SFPloF077137@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Wed, 28 Feb 2018 15:25:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330114 - head/sys/arm64/arm64 X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: head/sys/arm64/arm64 X-SVN-Commit-Revision: 330114 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Feb 2018 15:25:48 -0000 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)