Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/aarch64/aarch64 Only touch PMC registers if Perform...



details:   https://anonhg.NetBSD.org/src/rev/a3fd40747606
branches:  trunk
changeset: 976903:a3fd40747606
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Wed Oct 07 16:03:10 2020 +0000

description:
Only touch PMC registers if Performance Monitor Extensions are present.

diffstat:

 sys/arch/aarch64/aarch64/cpu.c |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r 1e5f169b828c -r a3fd40747606 sys/arch/aarch64/aarch64/cpu.c
--- a/sys/arch/aarch64/aarch64/cpu.c    Wed Oct 07 14:07:42 2020 +0000
+++ b/sys/arch/aarch64/aarch64/cpu.c    Wed Oct 07 16:03:10 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.54 2020/07/25 22:51:57 riastradh Exp $ */
+/* $NetBSD: cpu.c,v 1.55 2020/10/07 16:03:10 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.54 2020/07/25 22:51:57 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.55 2020/10/07 16:03:10 jmcneill Exp $");
 
 #include "locators.h"
 #include "opt_arm_debug.h"
@@ -472,6 +472,13 @@
 static void
 cpu_init_counter(struct cpu_info *ci)
 {
+       const uint64_t dfr0 = reg_id_aa64dfr0_el1_read();
+       const u_int pmuver = __SHIFTOUT(dfr0, ID_AA64DFR0_EL1_PMUVER);
+       if (pmuver == ID_AA64DFR0_EL1_PMUVER_NONE) {
+               /* Performance Monitors Extension not implemented. */
+               return;
+       }
+
        reg_pmcr_el0_write(PMCR_E | PMCR_C);
        reg_pmcntenset_el0_write(PMCNTEN_C);
 



Home | Main Index | Thread Index | Old Index