Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/tprof tprof: armv8: Only attach to known PMU types.
details: https://anonhg.NetBSD.org/src/rev/bafe4f3876aa
branches: trunk
changeset: 366150:bafe4f3876aa
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Mon May 16 09:42:32 2022 +0000
description:
tprof: armv8: Only attach to known PMU types.
diffstat:
sys/arch/arm/acpi/cpu_acpi.c | 6 +++---
sys/dev/tprof/tprof_armv8.c | 16 ++++++++++++++--
sys/dev/tprof/tprof_armv8.h | 3 ++-
3 files changed, 19 insertions(+), 6 deletions(-)
diffs (84 lines):
diff -r 4555bdec800c -r bafe4f3876aa sys/arch/arm/acpi/cpu_acpi.c
--- a/sys/arch/arm/acpi/cpu_acpi.c Mon May 16 07:07:17 2022 +0000
+++ b/sys/arch/arm/acpi/cpu_acpi.c Mon May 16 09:42:32 2022 +0000
@@ -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_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
}
diff -r 4555bdec800c -r bafe4f3876aa sys/dev/tprof/tprof_armv8.c
--- a/sys/dev/tprof/tprof_armv8.c Mon May 16 07:07:17 2022 +0000
+++ b/sys/dev/tprof/tprof_armv8.c Mon May 16 09:42:32 2022 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
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);
diff -r 4555bdec800c -r bafe4f3876aa sys/dev/tprof/tprof_armv8.h
--- a/sys/dev/tprof/tprof_armv8.h Mon May 16 07:07:17 2022 +0000
+++ b/sys/dev/tprof/tprof_armv8.h Mon May 16 09:42:32 2022 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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);
Home |
Main Index |
Thread Index |
Old Index