[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
- [PATCH 09/19] PPC64/TCG: Implement 'rfebb' instruction, (continued)
- [PATCH 10/19] target/ppc: PMU Event-Based exception support, Daniel Henrique Barboza, 2021/08/09
- [PATCH 11/19] target/ppc/excp_helper.c: POWERPC_EXCP_EBB adjustments, Daniel Henrique Barboza, 2021/08/09
- [PATCH 14/19] target/ppc/pmu_book3s_helper.c: add generic timeout helpers,
Daniel Henrique Barboza <=
- [PATCH 12/19] target/ppc/pmu_book3s_helper.c: enable PMC1 counter negative EBB, Daniel Henrique Barboza, 2021/08/09
- Re: [PATCH 12/19] target/ppc/pmu_book3s_helper.c: enable PMC1 counter negative EBB, David Gibson, 2021/08/10
- Re: [PATCH 12/19] target/ppc/pmu_book3s_helper.c: enable PMC1 counter negative EBB, Daniel Henrique Barboza, 2021/08/10
- Re: [PATCH 12/19] target/ppc/pmu_book3s_helper.c: enable PMC1 counter negative EBB, David Gibson, 2021/08/11
- Re: [PATCH 12/19] target/ppc/pmu_book3s_helper.c: enable PMC1 counter negative EBB, Daniel Henrique Barboza, 2021/08/11
- Re: [PATCH 12/19] target/ppc/pmu_book3s_helper.c: enable PMC1 counter negative EBB, David Gibson, 2021/08/11
- Re: [PATCH 12/19] target/ppc/pmu_book3s_helper.c: enable PMC1 counter negative EBB, Richard Henderson, 2021/08/12
- Re: [PATCH 12/19] target/ppc/pmu_book3s_helper.c: enable PMC1 counter negative EBB, Richard Henderson, 2021/08/12
- Re: [PATCH 12/19] target/ppc/pmu_book3s_helper.c: enable PMC1 counter negative EBB, Daniel Henrique Barboza, 2021/08/12