[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 14/19] target/ppc/pmu_book3s_helper.c: add generic timeout helper
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH 14/19] target/ppc/pmu_book3s_helper.c: add generic timeout helpers |
Date: |
Mon, 9 Aug 2021 10:10:52 -0300 |
Before adding counter negative condition support for the other 5
counters, create generic helpers that retrieves the elapsed timeout to
counter negative based on the event being sampled.
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
target/ppc/pmu_book3s_helper.c | 41 +++++++++++++++++++++++++++++-----
1 file changed, 35 insertions(+), 6 deletions(-)
diff --git a/target/ppc/pmu_book3s_helper.c b/target/ppc/pmu_book3s_helper.c
index e7af273cb6..7126e9b3d5 100644
--- a/target/ppc/pmu_book3s_helper.c
+++ b/target/ppc/pmu_book3s_helper.c
@@ -111,23 +111,52 @@ static void update_PMCs(CPUPPCState *env, uint64_t
icount_delta)
update_PMC_PM_CYC(env, SPR_POWER_PMC6, icount_delta);
}
+static int64_t get_INST_CMPL_timeout(CPUPPCState *env, int sprn)
+{
+ int64_t remaining_insns;
+
+ if (env->spr[sprn] == 0) {
+ return icount_to_ns(COUNTER_NEGATIVE_VAL);
+ }
+
+ if (env->spr[sprn] >= COUNTER_NEGATIVE_VAL) {
+ return 0;
+ }
+
+ remaining_insns = COUNTER_NEGATIVE_VAL - env->spr[sprn];
+ return icount_to_ns(remaining_insns);
+}
+
+static int64_t get_CYC_timeout(CPUPPCState *env, int sprn)
+{
+ int64_t remaining_cyc;
+
+ if (env->spr[sprn] == 0) {
+ return icount_to_ns(COUNTER_NEGATIVE_VAL);
+ }
+
+ if (env->spr[sprn] >= COUNTER_NEGATIVE_VAL) {
+ return 0;
+ }
+
+ remaining_cyc = COUNTER_NEGATIVE_VAL - env->spr[sprn];
+ return muldiv64(remaining_cyc, NANOSECONDS_PER_SECOND, PPC_CPU_FREQ);
+}
+
static void set_PMU_excp_timer(CPUPPCState *env)
{
- uint64_t timeout, now, remaining_val;
+ uint64_t timeout, now;
if (!(env->spr[SPR_POWER_MMCR0] & MMCR0_PMC1CE)) {
return;
}
- remaining_val = COUNTER_NEGATIVE_VAL - env->spr[SPR_POWER_PMC1];
-
switch (get_PMC_event(env, SPR_POWER_PMC1)) {
case 0x2:
- timeout = icount_to_ns(remaining_val);
+ timeout = get_INST_CMPL_timeout(env, SPR_POWER_PMC1);
break;
case 0x1e:
- timeout = muldiv64(remaining_val, NANOSECONDS_PER_SECOND,
- PPC_CPU_FREQ);
+ timeout = get_CYC_timeout(env, SPR_POWER_PMC1);
break;
default:
return;
--
2.31.1
- Re: [PATCH 12/19] target/ppc/pmu_book3s_helper.c: enable PMC1 counter negative EBB, (continued)
[PATCH 13/19] target/ppc/translate: PMU: handle setting of PMCs while running, Daniel Henrique Barboza, 2021/08/09
[PATCH 15/19] target/ppc/pmu_book3s_helper: enable counter negative for all PMCs, Daniel Henrique Barboza, 2021/08/09
[PATCH 14/19] target/ppc/pmu_book3s_helper.c: add generic timeout helpers,
Daniel Henrique Barboza <=
[PATCH 16/19] target/ppc/pmu_book3s_helper: adding 0xFA event, Daniel Henrique Barboza, 2021/08/09
[PATCH 17/19] target/ppc/pmu_book3s_helper.c: add PMC14/PMC56 counter freeze bits, Daniel Henrique Barboza, 2021/08/09
[PATCH 18/19] target/ppc/pmu_book3s_helper.c: add PM_CMPLU_STALL mock events, Daniel Henrique Barboza, 2021/08/09
[PATCH 19/19] docs/specs: add PPC64 TCG PMU-EBB documentation, Daniel Henrique Barboza, 2021/08/09