Module Name: src
Committed By: jmcneill
Date: Mon May 16 09:42:32 UTC 2022
Modified Files:
src/sys/arch/arm/acpi: cpu_acpi.c
src/sys/dev/tprof: tprof_armv8.c tprof_armv8.h
Log Message:
tprof: armv8: Only attach to known PMU types.
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/acpi/cpu_acpi.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/tprof/tprof_armv8.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/tprof/tprof_armv8.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/arm/acpi/cpu_acpi.c
diff -u src/sys/arch/arm/acpi/cpu_acpi.c:1.13 src/sys/arch/arm/acpi/cpu_acpi.c:1.14
--- src/sys/arch/arm/acpi/cpu_acpi.c:1.13 Thu Nov 25 09:36:20 2021
+++ src/sys/arch/arm/acpi/cpu_acpi.c Mon May 16 09:42:32 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_acpi.c,v 1.13 2021/11/25 09:36:20 skrll Exp $ */
+/* $NetBSD: cpu_acpi.c,v 1.14 2022/05/16 09:42:32 jmcneill Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
#include "opt_multiprocessor.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v 1.13 2021/11/25 09:36:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v 1.14 2022/05/16 09:42:32 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -135,7 +135,7 @@ cpu_acpi_attach(device_t parent, device_
cpu_attach(self, mpidr);
#if NTPROF > 0
- if (cpu_mpidr_aff_read() == mpidr)
+ if (cpu_mpidr_aff_read() == mpidr && armv8_pmu_detect())
config_interrupts(self, cpu_acpi_tprof_init);
#endif
}
Index: src/sys/dev/tprof/tprof_armv8.c
diff -u src/sys/dev/tprof/tprof_armv8.c:1.13 src/sys/dev/tprof/tprof_armv8.c:1.14
--- src/sys/dev/tprof/tprof_armv8.c:1.13 Fri Dec 3 10:54:19 2021
+++ src/sys/dev/tprof/tprof_armv8.c Mon May 16 09:42:32 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: tprof_armv8.c,v 1.13 2021/12/03 10:54:19 skrll Exp $ */
+/* $NetBSD: tprof_armv8.c,v 1.14 2022/05/16 09:42:32 jmcneill Exp $ */
/*-
* Copyright (c) 2018 Jared McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tprof_armv8.c,v 1.13 2021/12/03 10:54:19 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tprof_armv8.c,v 1.14 2022/05/16 09:42:32 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -220,9 +220,21 @@ armv8_pmu_init_cpu(void *arg1, void *arg
reg_pmcntenclr_el0_write(PMCNTEN_P);
}
+bool
+armv8_pmu_detect(void)
+{
+ const uint64_t dfr0 = reg_id_aa64dfr0_el1_read();
+ const u_int pmuver = __SHIFTOUT(dfr0, ID_AA64DFR0_EL1_PMUVER);
+
+ return pmuver != ID_AA64DFR0_EL1_PMUVER_NONE &&
+ pmuver != ID_AA64DFR0_EL1_PMUVER_IMPL;
+}
+
int
armv8_pmu_init(void)
{
+ KASSERT(armv8_pmu_detect());
+
uint64_t xc = xc_broadcast(0, armv8_pmu_init_cpu, NULL, NULL);
xc_wait(xc);
Index: src/sys/dev/tprof/tprof_armv8.h
diff -u src/sys/dev/tprof/tprof_armv8.h:1.1 src/sys/dev/tprof/tprof_armv8.h:1.2
--- src/sys/dev/tprof/tprof_armv8.h:1.1 Sun Jul 15 16:05:24 2018
+++ src/sys/dev/tprof/tprof_armv8.h Mon May 16 09:42:32 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: tprof_armv8.h,v 1.1 2018/07/15 16:05:24 jmcneill Exp $ */
+/* $NetBSD: tprof_armv8.h,v 1.2 2022/05/16 09:42:32 jmcneill Exp $ */
/*-
* Copyright (c) 2018 Jared McNeill <[email protected]>
@@ -29,6 +29,7 @@
#ifndef _DEV_TPROF_TPROF_ARMV8_H
#define _DEV_TPROF_TPROF_ARMV8_H
+bool armv8_pmu_detect(void);
int armv8_pmu_intr(void *);
int armv8_pmu_init(void);