Module Name: src
Committed By: mrg
Date: Wed Jan 15 08:34:04 UTC 2020
Modified Files:
src/sys/arch/aarch64/aarch64: cpu.c cpufunc.c locore.S
src/sys/arch/aarch64/conf: files.aarch64
src/sys/arch/aarch64/include: cpu.h cpufunc.h
src/sys/arch/arm/arm32: cpu.c
src/sys/arch/arm/conf: files.arm
src/sys/arch/arm/include: cpu.h
Added Files:
src/sys/arch/arm/arm: arm_cpu_topology.c
src/sys/arch/arm/include: cpu_topology.h
Log Message:
port the arm64 cpu topology setup for big.little to arm.
rename arm64 cpu_do_topology() to arm_cpu_do_topology() and
call it from both arm cpu_attach().
replace both aarch64_set_topology() inline code in arm
cpu_attach() with new arm_cpu_do_topology(), which is called
by the arm64 locore as well (possibly not needed, which would
allow it to become static.)
not yet tested on a real big.little armv7 system. tested
on rockpro64 and pinebook pro.
To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/aarch64/aarch64/cpu.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/aarch64/aarch64/cpufunc.c
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/aarch64/aarch64/locore.S
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/aarch64/conf/files.aarch64
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/aarch64/include/cpu.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/aarch64/include/cpufunc.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/arm/arm_cpu_topology.c
cvs rdiff -u -r1.139 -r1.140 src/sys/arch/arm/arm32/cpu.c
cvs rdiff -u -r1.149 -r1.150 src/sys/arch/arm/conf/files.arm
cvs rdiff -u -r1.103 -r1.104 src/sys/arch/arm/include/cpu.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/include/cpu_topology.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/aarch64/aarch64/cpu.c
diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.33 src/sys/arch/aarch64/aarch64/cpu.c:1.34
--- src/sys/arch/aarch64/aarch64/cpu.c:1.33 Sun Jan 12 09:29:18 2020
+++ src/sys/arch/aarch64/aarch64/cpu.c Wed Jan 15 08:34:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.33 2020/01/12 09:29:18 mrg Exp $ */
+/* $NetBSD: cpu.c,v 1.34 2020/01/15 08:34:04 mrg Exp $ */
/*
* Copyright (c) 2017 Ryo Shimizu <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.33 2020/01/12 09:29:18 mrg Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.34 2020/01/15 08:34:04 mrg Exp $");
#include "locators.h"
#include "opt_arm_debug.h"
@@ -48,6 +48,7 @@ __KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.33
#include <aarch64/cpufunc.h>
#include <aarch64/machdep.h>
+#include <arm/cpu_topology.h>
#ifdef FDT
#include <arm/fdt/arm_fdtvar.h>
#endif
@@ -65,7 +66,6 @@ static void cpu_identify1(device_t self,
static void cpu_identify2(device_t self, struct cpu_info *);
static void cpu_setup_id(struct cpu_info *);
static void cpu_setup_sysctl(device_t, struct cpu_info *);
-static void cpu_do_topology(struct cpu_info *);
#ifdef MULTIPROCESSOR
uint64_t cpu_mpidr[MAXCPUS];
@@ -145,7 +145,7 @@ cpu_attach(device_t dv, cpuid_t id)
ci->ci_dev = dv;
dv->dv_private = ci;
- cpu_do_topology(ci);
+ arm_cpu_do_topology(ci);
cpu_identify(ci->ci_dev, ci);
#ifdef MULTIPROCESSOR
@@ -498,43 +498,6 @@ cpu_setup_sysctl(device_t dv, struct cpu
CTL_CREATE, CTL_EOL);
}
-static void
-cpu_do_topology(struct cpu_info *newci)
-{
- struct cpu_info *ci;
- CPU_INFO_ITERATOR cii;
- prop_dictionary_t dict;
- uint32_t capacity_dmips_mhz;
- static uint32_t best_cap = 0;
-
- dict = device_properties(newci->ci_dev);
- if (prop_dictionary_get_uint32(dict, "capacity_dmips_mhz",
- &capacity_dmips_mhz)) {
- newci->ci_capacity_dmips_mhz = capacity_dmips_mhz;
- } else {
- newci->ci_capacity_dmips_mhz = 0;
- }
-
- if (newci->ci_capacity_dmips_mhz > best_cap)
- best_cap = newci->ci_capacity_dmips_mhz;
-
- /*
- * CPU_INFO_FOREACH() doesn't work for this CPU until mi_cpu_attach()
- * is called and ncpu is bumped, so call it directly here.
- */
- aarch64_set_topology(newci, newci->ci_id.ac_mpidr,
- newci->ci_capacity_dmips_mhz < best_cap);
-
- /*
- * Using saved largest capacity, refresh previous topology info.
- * It's supposed to be OK to re-set topology.
- */
- for (CPU_INFO_FOREACH(cii, ci)) {
- aarch64_set_topology(ci, ci->ci_id.ac_mpidr,
- ci->ci_capacity_dmips_mhz < best_cap);
- }
-}
-
#ifdef MULTIPROCESSOR
void
cpu_boot_secondary_processors(void)
Index: src/sys/arch/aarch64/aarch64/cpufunc.c
diff -u src/sys/arch/aarch64/aarch64/cpufunc.c:1.14 src/sys/arch/aarch64/aarch64/cpufunc.c:1.15
--- src/sys/arch/aarch64/aarch64/cpufunc.c:1.14 Sun Jan 12 09:29:18 2020
+++ src/sys/arch/aarch64/aarch64/cpufunc.c Wed Jan 15 08:34:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpufunc.c,v 1.14 2020/01/12 09:29:18 mrg Exp $ */
+/* $NetBSD: cpufunc.c,v 1.15 2020/01/15 08:34:04 mrg Exp $ */
/*
* Copyright (c) 2017 Ryo Shimizu <[email protected]>
@@ -29,7 +29,7 @@
#include "opt_multiprocessor.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.14 2020/01/12 09:29:18 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.15 2020/01/15 08:34:04 mrg Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -89,27 +89,6 @@ extract_cacheunit(int level, bool insn,
}
void
-aarch64_set_topology(struct cpu_info * const ci, uint64_t mpidr, bool slow)
-{
-
- if (mpidr & MPIDR_MT) {
- cpu_topology_set(ci,
- __SHIFTOUT(mpidr, MPIDR_AFF2),
- __SHIFTOUT(mpidr, MPIDR_AFF1),
- __SHIFTOUT(mpidr, MPIDR_AFF0),
- 0,
- slow);
- } else {
- cpu_topology_set(ci,
- __SHIFTOUT(mpidr, MPIDR_AFF1),
- __SHIFTOUT(mpidr, MPIDR_AFF0),
- 0,
- 0,
- slow);
- }
-}
-
-void
aarch64_getcacheinfo(int unit)
{
struct cpu_info * const ci = curcpu();
Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.51 src/sys/arch/aarch64/aarch64/locore.S:1.52
--- src/sys/arch/aarch64/aarch64/locore.S:1.51 Sun Jan 12 09:29:18 2020
+++ src/sys/arch/aarch64/aarch64/locore.S Wed Jan 15 08:34:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.51 2020/01/12 09:29:18 mrg Exp $ */
+/* $NetBSD: locore.S,v 1.52 2020/01/15 08:34:04 mrg Exp $ */
/*
* Copyright (c) 2017 Ryo Shimizu <[email protected]>
@@ -38,7 +38,7 @@
#include <aarch64/hypervisor.h>
#include "assym.h"
-RCSID("$NetBSD: locore.S,v 1.51 2020/01/12 09:29:18 mrg Exp $")
+RCSID("$NetBSD: locore.S,v 1.52 2020/01/15 08:34:04 mrg Exp $")
#ifdef AARCH64_DEVICE_MEM_STRONGLY_ORDERED
#define MAIR_DEVICE_MEM MAIR_DEVICE_nGnRnE
@@ -188,7 +188,7 @@ vstart:
mrs x0, tpidr_el1 /* curcpu */
mrs x1, mpidr_el1
mov x2, #0
- bl aarch64_set_topology
+ bl arm_cpu_topology_set
mov x0, xzr
bl aarch64_getcacheinfo
Index: src/sys/arch/aarch64/conf/files.aarch64
diff -u src/sys/arch/aarch64/conf/files.aarch64:1.16 src/sys/arch/aarch64/conf/files.aarch64:1.17
--- src/sys/arch/aarch64/conf/files.aarch64:1.16 Sat Dec 28 17:19:43 2019
+++ src/sys/arch/aarch64/conf/files.aarch64 Wed Jan 15 08:34:04 2020
@@ -1,4 +1,4 @@
-# $NetBSD: files.aarch64,v 1.16 2019/12/28 17:19:43 jmcneill Exp $
+# $NetBSD: files.aarch64,v 1.17 2020/01/15 08:34:04 mrg Exp $
defflag opt_cpuoptions.h AARCH64_ALIGNMENT_CHECK
defflag opt_cpuoptions.h AARCH64_EL0_STACK_ALIGNMENT_CHECK
@@ -41,6 +41,7 @@ defparam opt_console.h CONADDR
file arch/aarch64/aarch64/fpu.c
file arch/arm/arm/arm_generic_dma.c
+file arch/arm/arm/arm_cpu_topology.c
file arch/arm/arm32/bus_dma.c
device psci
Index: src/sys/arch/aarch64/include/cpu.h
diff -u src/sys/arch/aarch64/include/cpu.h:1.18 src/sys/arch/aarch64/include/cpu.h:1.19
--- src/sys/arch/aarch64/include/cpu.h:1.18 Sun Jan 12 09:29:18 2020
+++ src/sys/arch/aarch64/include/cpu.h Wed Jan 15 08:34:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.18 2020/01/12 09:29:18 mrg Exp $ */
+/* $NetBSD: cpu.h,v 1.19 2020/01/15 08:34:04 mrg Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -104,6 +104,7 @@ struct cpu_info {
uint64_t ci_acpiid; /* ACPI Processor Unique ID */
struct aarch64_sysctl_cpu_id ci_id;
+#define arm_cpu_mpidr(ci) ((ci)->ci_id.ac_mpidr)
struct aarch64_cache_info *ci_cacheinfo;
struct aarch64_cpufuncs ci_cpufuncs;
Index: src/sys/arch/aarch64/include/cpufunc.h
diff -u src/sys/arch/aarch64/include/cpufunc.h:1.10 src/sys/arch/aarch64/include/cpufunc.h:1.11
--- src/sys/arch/aarch64/include/cpufunc.h:1.10 Sun Jan 12 09:29:18 2020
+++ src/sys/arch/aarch64/include/cpufunc.h Wed Jan 15 08:34:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpufunc.h,v 1.10 2020/01/12 09:29:18 mrg Exp $ */
+/* $NetBSD: cpufunc.h,v 1.11 2020/01/15 08:34:04 mrg Exp $ */
/*
* Copyright (c) 2017 Ryo Shimizu <[email protected]>
@@ -69,7 +69,6 @@ extern u_int aarch64_cache_prefer_mask;
extern u_int cputype; /* compat arm */
int set_cpufuncs(void);
-void aarch64_set_topology(struct cpu_info *, uint64_t, bool);
void aarch64_getcacheinfo(int);
void aarch64_printcacheinfo(device_t);
Index: src/sys/arch/arm/arm32/cpu.c
diff -u src/sys/arch/arm/arm32/cpu.c:1.139 src/sys/arch/arm/arm32/cpu.c:1.140
--- src/sys/arch/arm/arm32/cpu.c:1.139 Thu Jan 9 16:35:03 2020
+++ src/sys/arch/arm/arm32/cpu.c Wed Jan 15 08:34:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.139 2020/01/09 16:35:03 ad Exp $ */
+/* $NetBSD: cpu.c,v 1.140 2020/01/15 08:34:04 mrg Exp $ */
/*
* Copyright (c) 1995 Mark Brinicombe.
@@ -46,7 +46,7 @@
#include "opt_multiprocessor.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.139 2020/01/09 16:35:03 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.140 2020/01/15 08:34:04 mrg Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -60,6 +60,7 @@ __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.13
#include <arm/locore.h>
#include <arm/undefined.h>
+#include <arm/cpu_topology.h>
extern const char *cpu_arch;
@@ -138,21 +139,7 @@ cpu_attach(device_t dv, cpuid_t id)
ci->ci_dev = dv;
dv->dv_private = ci;
- if (id & MPIDR_MT) {
- cpu_topology_set(ci,
- __SHIFTOUT(id, MPIDR_AFF2),
- __SHIFTOUT(id, MPIDR_AFF1),
- __SHIFTOUT(id, MPIDR_AFF0),
- 0,
- false);
- } else {
- cpu_topology_set(ci,
- __SHIFTOUT(id, MPIDR_AFF1),
- __SHIFTOUT(id, MPIDR_AFF0),
- 0,
- 0,
- false);
- }
+ arm_cpu_do_topology(ci);
evcnt_attach_dynamic(&ci->ci_arm700bugcount, EVCNT_TYPE_MISC,
NULL, xname, "arm700swibug");
Index: src/sys/arch/arm/conf/files.arm
diff -u src/sys/arch/arm/conf/files.arm:1.149 src/sys/arch/arm/conf/files.arm:1.150
--- src/sys/arch/arm/conf/files.arm:1.149 Wed Nov 20 19:37:52 2019
+++ src/sys/arch/arm/conf/files.arm Wed Jan 15 08:34:04 2020
@@ -1,4 +1,4 @@
-# $NetBSD: files.arm,v 1.149 2019/11/20 19:37:52 pgoyette Exp $
+# $NetBSD: files.arm,v 1.150 2020/01/15 08:34:04 mrg Exp $
# temporary define to allow easy moving to ../arch/arm/arm32
defflag ARM32
@@ -155,6 +155,7 @@ file arch/arm/arm/bus_space_asm_generic.
file arch/arm/arm/bus_space_notimpl.S arm32
file arch/arm/arm/arm_machdep.c
+file arch/arm/arm/arm_cpu_topology.c
file arch/arm/arm/ast.c
file arch/arm/arm/bcopyinout.S
file arch/arm/arm/blockio.S
Index: src/sys/arch/arm/include/cpu.h
diff -u src/sys/arch/arm/include/cpu.h:1.103 src/sys/arch/arm/include/cpu.h:1.104
--- src/sys/arch/arm/include/cpu.h:1.103 Sun Dec 1 15:34:44 2019
+++ src/sys/arch/arm/include/cpu.h Wed Jan 15 08:34:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.103 2019/12/01 15:34:44 ad Exp $ */
+/* $NetBSD: cpu.h,v 1.104 2020/01/15 08:34:04 mrg Exp $ */
/*
* Copyright (c) 1994-1996 Mark Brinicombe.
@@ -178,6 +178,8 @@ struct cpu_info {
uint32_t ci_midr;
uint32_t ci_mpidr;
+#define arm_cpu_mpidr(ci) ((ci)->ci_mpidr)
+ uint32_t ci_capacity_dmips_mhz;
struct arm_cache_info *
ci_cacheinfo;
Added files:
Index: src/sys/arch/arm/arm/arm_cpu_topology.c
diff -u /dev/null src/sys/arch/arm/arm/arm_cpu_topology.c:1.1
--- /dev/null Wed Jan 15 08:34:05 2020
+++ src/sys/arch/arm/arm/arm_cpu_topology.c Wed Jan 15 08:34:04 2020
@@ -0,0 +1,102 @@
+/* $NetBSD: arm_cpu_topology.c,v 1.1 2020/01/15 08:34:04 mrg Exp $ */
+
+/*
+ * Copyright (c) 2020 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "opt_multiprocessor.h"
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: arm_cpu_topology.c,v 1.1 2020/01/15 08:34:04 mrg Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+
+#include <arm/cpu.h>
+#include <arm/cpu_topology.h>
+
+#include <prop/proplib.h>
+
+void
+arm_cpu_topology_set(struct cpu_info * const ci, uint64_t mpidr, bool slow)
+{
+ uint pkgid, coreid, smtid, numaid = 0;
+
+ if (mpidr & MPIDR_MT) {
+ pkgid = __SHIFTOUT(mpidr, MPIDR_AFF2);
+ coreid = __SHIFTOUT(mpidr, MPIDR_AFF1);
+ smtid = __SHIFTOUT(mpidr, MPIDR_AFF0);
+ } else {
+ pkgid = __SHIFTOUT(mpidr, MPIDR_AFF1);
+ coreid = __SHIFTOUT(mpidr, MPIDR_AFF0);
+ smtid = 0;
+ }
+ cpu_topology_set(ci, pkgid, coreid, smtid, numaid, slow);
+}
+
+void
+arm_cpu_do_topology(struct cpu_info *const newci)
+{
+#ifdef MULTIPROCESSOR
+ struct cpu_info *ci;
+ CPU_INFO_ITERATOR cii;
+#endif /* MULTIPROCESSOR */
+ prop_dictionary_t dict;
+ uint32_t capacity_dmips_mhz = 0;
+ static uint32_t best_cap = 0;
+
+ dict = device_properties(newci->ci_dev);
+ if (prop_dictionary_get_uint32(dict, "capacity_dmips_mhz",
+ &capacity_dmips_mhz))
+ newci->ci_capacity_dmips_mhz = capacity_dmips_mhz;
+
+ if (newci->ci_capacity_dmips_mhz > best_cap)
+ best_cap = newci->ci_capacity_dmips_mhz;
+
+ /*
+ * CPU_INFO_FOREACH() doesn't always work for this CPU until
+ * mi_cpu_attach() is called and ncpu is bumped, so call it
+ * directly here. This also handles the not-MP case.
+ */
+ arm_cpu_topology_set(newci, arm_cpu_mpidr(newci),
+ newci->ci_capacity_dmips_mhz < best_cap);
+
+#ifdef MULTIPROCESSOR
+ /*
+ * Using saved largest capacity, refresh previous topology info.
+ * It's supposed to be OK to re-set topology.
+ */
+ for (CPU_INFO_FOREACH(cii, ci)) {
+ if (ci == newci)
+ continue;
+ arm_cpu_topology_set(ci, arm_cpu_mpidr(ci),
+ ci->ci_capacity_dmips_mhz < best_cap);
+ }
+#endif /* MULTIPROCESSOR */
+}
Index: src/sys/arch/arm/include/cpu_topology.h
diff -u /dev/null src/sys/arch/arm/include/cpu_topology.h:1.1
--- /dev/null Wed Jan 15 08:34:05 2020
+++ src/sys/arch/arm/include/cpu_topology.h Wed Jan 15 08:34:04 2020
@@ -0,0 +1,59 @@
+/* $NetBSD: cpu_topology.h,v 1.1 2020/01/15 08:34:04 mrg Exp $ */
+
+/*
+ * Copyright (c) 2020 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARM_CPU_TOPOLOGY_H_
+#define _ARM_CPU_TOPOLOGY_H_
+
+/*
+ * ARMv7 and ARMv8 compatible CPU topology support.
+ *
+ * arm_cpu_do_topology(cpuinfo)
+ *
+ * Call arm_cpu_do_topology() in cpu_attach() after making sure that
+ * arm_cpu_mpidr() will work for this CPU, and it will split up
+ * package/core/smt IDs.
+ *
+ * The CPU frontend can set the "capacity_dmips_mhz" property for
+ * this CPU device, and arm_cpu_set_topology() will calculate the
+ * best way to call cpu_topology_set() for the known system.
+ *
+ * arm_cpu_topology_set(cpuinfo, mpidr, slow)
+ *
+ * arm_cpu_topology_set() is provided for locore and the boot CPU,
+ * and only works for the current CPU.
+ */
+
+#include <sys/param.h>
+#include <sys/cpu.h>
+
+void arm_cpu_do_topology(struct cpu_info * const);
+void arm_cpu_topology_set(struct cpu_info * const, uint64_t, bool);
+
+#endif /* _ARM_CPU_TOPOLOGY_H_ */