From owner-svn-src-all@freebsd.org Sat Dec 8 19:32:24 2018 Return-Path: Delivered-To: svn-src-all@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 68C9213274F1; Sat, 8 Dec 2018 19:32:24 +0000 (UTC) (envelope-from jchandra@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 0FC4F8CD27; Sat, 8 Dec 2018 19:32:24 +0000 (UTC) (envelope-from jchandra@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 E4E6026807; Sat, 8 Dec 2018 19:32:23 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wB8JWN9Q017297; Sat, 8 Dec 2018 19:32:23 GMT (envelope-from jchandra@FreeBSD.org) Received: (from jchandra@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wB8JWNZf016911; Sat, 8 Dec 2018 19:32:23 GMT (envelope-from jchandra@FreeBSD.org) Message-Id: <201812081932.wB8JWNZf016911@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jchandra set sender to jchandra@FreeBSD.org using -f From: "Jayachandran C." Date: Sat, 8 Dec 2018 19:32:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r341743 - in head/sys: conf dev/acpica X-SVN-Group: head X-SVN-Commit-Author: jchandra X-SVN-Commit-Paths: in head/sys: conf dev/acpica X-SVN-Commit-Revision: 341743 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 0FC4F8CD27 X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.97)[-0.974,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-0.99)[-0.991,0] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Dec 2018 19:32:24 -0000 Author: jchandra Date: Sat Dec 8 19:32:23 2018 New Revision: 341743 URL: https://svnweb.freebsd.org/changeset/base/341743 Log: acpica: support parsing of arm64 affinity in acpi_pxm.c ACPI SRAT table on arm64 uses GICC entries to provide CPU locality information. These entries use an AcpiProcessorUid to identify the CPU (unlike on x86 where the entries have an APIC ID). Update acpi_pxm.c to extend the cpu_add/cpu_find/cpu_get_info functions to handle AcpiProcessorUid. Use the updated functions while parsing ACPI_SRAT_GICC_AFFINITY entry for arm64. Also update sys/conf/files.arm64 to build acpi_pxm.c when ACPI is enabled. Reviewed by: markj (previous version) Differential Revision: https://reviews.freebsd.org/D17942 Modified: head/sys/conf/files.arm64 head/sys/dev/acpica/acpi_pxm.c Modified: head/sys/conf/files.arm64 ============================================================================== --- head/sys/conf/files.arm64 Sat Dec 8 19:10:58 2018 (r341742) +++ head/sys/conf/files.arm64 Sat Dec 8 19:32:23 2018 (r341743) @@ -188,6 +188,7 @@ dev/acpica/acpi_bus_if.m optional acpi dev/acpica/acpi_if.m optional acpi dev/acpica/acpi_pci_link.c optional acpi pci dev/acpica/acpi_pcib.c optional acpi pci +dev/acpica/acpi_pxm.c optional acpi dev/ahci/ahci_generic.c optional ahci dev/axgbe/if_axgbe.c optional axgbe dev/axgbe/xgbe-desc.c optional axgbe Modified: head/sys/dev/acpica/acpi_pxm.c ============================================================================== --- head/sys/dev/acpica/acpi_pxm.c Sat Dec 8 19:10:58 2018 (r341742) +++ head/sys/dev/acpica/acpi_pxm.c Sat Dec 8 19:32:23 2018 (r341743) @@ -59,6 +59,7 @@ static struct cpu_info { int enabled:1; int has_memory:1; int domain; + int id; } *cpus; static int max_cpus; @@ -182,14 +183,33 @@ overlaps_phys_avail(vm_paddr_t start, vm_paddr_t end) } /* - * Find CPU by processor ID (APIC ID on x86). + * On x86 we can use the cpuid to index the cpus array, but on arm64 + * we have an ACPI Processor UID with a larger range. + * + * Use this variable to indicate if the cpus can be stored by index. */ +#ifdef __aarch64__ +static const int cpus_use_indexing = 0; +#else +static const int cpus_use_indexing = 1; +#endif + +/* + * Find CPU by processor ID (APIC ID on x86, Processor UID on arm64) + */ static struct cpu_info * cpu_find(int cpuid) { + int i; - if (cpuid <= last_cpu && cpus[cpuid].enabled) - return (&cpus[cpuid]); + if (cpus_use_indexing) { + if (cpuid <= last_cpu && cpus[cpuid].enabled) + return (&cpus[cpuid]); + } else { + for (i = 0; i <= last_cpu; i++) + if (cpus[i].id == cpuid) + return (&cpus[i]); + } return (NULL); } @@ -202,10 +222,14 @@ cpu_get_info(struct pcpu *pc) struct cpu_info *cpup; int id; +#ifdef __aarch64__ + id = pc->pc_acpi_id; +#else id = pc->pc_apic_id; +#endif cpup = cpu_find(id); if (cpup == NULL) - panic("SRAT: CPU with APIC ID %u is not known", id); + panic("SRAT: CPU with ID %u is not known", id); return (cpup); } @@ -217,11 +241,18 @@ cpu_add(int cpuid, int domain) { struct cpu_info *cpup; - if (cpuid >= max_cpus) - return (NULL); - last_cpu = imax(last_cpu, cpuid); - cpup = &cpus[cpuid]; + if (cpus_use_indexing) { + if (cpuid >= max_cpus) + return (NULL); + last_cpu = imax(last_cpu, cpuid); + cpup = &cpus[cpuid]; + } else { + if (last_cpu >= max_cpus - 1) + return (NULL); + cpup = &cpus[++last_cpu]; + } cpup->domain = domain; + cpup->id = cpuid; cpup->enabled = 1; return (cpup); } @@ -232,6 +263,7 @@ srat_parse_entry(ACPI_SUBTABLE_HEADER *entry, void *ar ACPI_SRAT_CPU_AFFINITY *cpu; ACPI_SRAT_X2APIC_CPU_AFFINITY *x2apic; ACPI_SRAT_MEM_AFFINITY *mem; + ACPI_SRAT_GICC_AFFINITY *gicc; static struct cpu_info *cpup; int domain, i, slot; @@ -276,6 +308,22 @@ srat_parse_entry(ACPI_SUBTABLE_HEADER *entry, void *ar if (cpup == NULL) printf("SRAT: Ignoring local APIC ID %u (too high)\n", x2apic->ApicId); + break; + case ACPI_SRAT_TYPE_GICC_AFFINITY: + gicc = (ACPI_SRAT_GICC_AFFINITY *)entry; + if (bootverbose) + printf("SRAT: Found CPU UID %u domain %d: %s\n", + gicc->AcpiProcessorUid, gicc->ProximityDomain, + (gicc->Flags & ACPI_SRAT_GICC_ENABLED) ? + "enabled" : "disabled"); + if (!(gicc->Flags & ACPI_SRAT_GICC_ENABLED)) + break; + KASSERT(cpu_find(gicc->AcpiProcessorUid) == NULL, + ("Duplicate CPU UID %u", gicc->AcpiProcessorUid)); + cpup = cpu_add(gicc->AcpiProcessorUid, gicc->ProximityDomain); + if (cpup == NULL) + printf("SRAT: Ignoring CPU UID %u (too high)\n", + gicc->AcpiProcessorUid); break; case ACPI_SRAT_TYPE_MEMORY_AFFINITY: mem = (ACPI_SRAT_MEM_AFFINITY *)entry;