From: Ricardo Koller <ricarkol@google.com>
To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
andrew.jones@linux.dev
Cc: maz@kernel.org, alexandru.elisei@arm.com, eric.auger@redhat.com,
oliver.upton@linux.dev, reijiw@google.com,
Ricardo Koller <ricarkol@google.com>
Subject: [kvm-unit-tests PATCH v4 2/4] arm: pmu: Add reset_pmu() for 32-bit arm
Date: Thu, 11 Aug 2022 11:52:08 -0700 [thread overview]
Message-ID: <20220811185210.234711-3-ricarkol@google.com> (raw)
In-Reply-To: <20220811185210.234711-1-ricarkol@google.com>
Add a 32-bit arm version of reset_pmu(). Add all the necessary register
definitions as well.
Signed-off-by: Ricardo Koller <ricarkol@google.com>
---
arm/pmu.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/arm/pmu.c b/arm/pmu.c
index 4c601b05..a5260178 100644
--- a/arm/pmu.c
+++ b/arm/pmu.c
@@ -93,7 +93,10 @@ static struct pmu pmu;
#define PMSELR __ACCESS_CP15(c9, 0, c12, 5)
#define PMXEVTYPER __ACCESS_CP15(c9, 0, c13, 1)
#define PMCNTENSET __ACCESS_CP15(c9, 0, c12, 1)
+#define PMCNTENCLR __ACCESS_CP15(c9, 0, c12, 2)
+#define PMOVSR __ACCESS_CP15(c9, 0, c12, 3)
#define PMCCNTR32 __ACCESS_CP15(c9, 0, c13, 0)
+#define PMINTENCLR __ACCESS_CP15(c9, 0, c14, 2)
#define PMCCNTR64 __ACCESS_CP15_64(0, c9)
static inline uint32_t get_id_dfr0(void) { return read_sysreg(ID_DFR0); }
@@ -145,6 +148,19 @@ static inline void precise_instrs_loop(int loop, uint32_t pmcr)
: "cc");
}
+static void pmu_reset(void)
+{
+ /* reset all counters, counting disabled at PMCR level*/
+ set_pmcr(pmu.pmcr_ro | PMU_PMCR_LC | PMU_PMCR_C | PMU_PMCR_P);
+ /* Disable all counters */
+ write_sysreg(ALL_SET, PMCNTENCLR);
+ /* clear overflow reg */
+ write_sysreg(ALL_SET, PMOVSR);
+ /* disable overflow interrupts on all counters */
+ write_sysreg(ALL_SET, PMINTENCLR);
+ isb();
+}
+
/* event counter tests only implemented for aarch64 */
static void test_event_introspection(void) {}
static void test_event_counter_config(void) {}
--
2.37.1.559.g78731f0fdb-goog
next prev parent reply other threads:[~2022-08-11 18:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-11 18:52 [kvm-unit-tests PATCH v4 0/4] arm: pmu: Fixes for bare metal Ricardo Koller
2022-08-11 18:52 ` [kvm-unit-tests PATCH v4 1/4] arm: pmu: Add missing isb()'s after sys register writing Ricardo Koller
2022-08-11 18:52 ` Ricardo Koller [this message]
2022-08-11 18:52 ` [kvm-unit-tests PATCH v4 3/4] arm: pmu: Reset the pmu registers before starting some tests Ricardo Koller
2022-08-11 18:52 ` [kvm-unit-tests PATCH v4 4/4] arm: pmu: Check for overflow in the low counter in chained counters tests Ricardo Koller
2022-08-12 6:33 ` [kvm-unit-tests PATCH v4 0/4] arm: pmu: Fixes for bare metal Andrew Jones
2022-08-12 17:57 ` Ricardo Koller
2022-08-13 8:13 ` Marc Zyngier
2022-10-28 11:40 ` Andrew Jones
2022-10-28 15:01 ` Marc Zyngier
2022-10-28 15:31 ` Andrew Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220811185210.234711-3-ricarkol@google.com \
--to=ricarkol@google.com \
--cc=alexandru.elisei@arm.com \
--cc=andrew.jones@linux.dev \
--cc=eric.auger@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=reijiw@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox