From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: amir.gonnen@neuroblade.ai
Subject: [PATCH 7/7] target/nios2: Rewrite interrupt handling
Date: Sun, 27 Feb 2022 08:21:25 -1000 [thread overview]
Message-ID: <20220227182125.21809-8-richard.henderson@linaro.org> (raw)
In-Reply-To: <20220227182125.21809-1-richard.henderson@linaro.org>
Drop irq_pending boolean.
Drop helper_check_interrupts.
Move checks for irq disabled into nios2_cpu_exec_interrupt.
End the TB on writes to ienable, just like to status.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/nios2/cpu.h | 1 -
target/nios2/helper.h | 1 -
target/nios2/cpu.c | 10 ++++------
target/nios2/op_helper.c | 19 -------------------
target/nios2/translate.c | 14 +++++---------
5 files changed, 9 insertions(+), 36 deletions(-)
diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
index d2ba0c5bbd..a00e4229ce 100644
--- a/target/nios2/cpu.h
+++ b/target/nios2/cpu.h
@@ -160,7 +160,6 @@ struct CPUNios2State {
#if !defined(CONFIG_USER_ONLY)
Nios2MMU mmu;
- uint32_t irq_pending;
#endif
int error_code;
};
diff --git a/target/nios2/helper.h b/target/nios2/helper.h
index 21ef7f0791..a44ecfdf7a 100644
--- a/target/nios2/helper.h
+++ b/target/nios2/helper.h
@@ -24,5 +24,4 @@ DEF_HELPER_FLAGS_2(raise_exception, TCG_CALL_NO_WG, noreturn, env, i32)
DEF_HELPER_2(mmu_write_tlbacc, void, env, i32)
DEF_HELPER_2(mmu_write_tlbmisc, void, env, i32)
DEF_HELPER_2(mmu_write_pteaddr, void, env, i32)
-DEF_HELPER_1(check_interrupts, void, env)
#endif
diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c
index 4cade61e93..6975ae4bdb 100644
--- a/target/nios2/cpu.c
+++ b/target/nios2/cpu.c
@@ -73,12 +73,9 @@ static void nios2_cpu_set_irq(void *opaque, int irq, int level)
env->regs[CR_IPENDING] = deposit32(env->regs[CR_IPENDING], irq, 1, !!level);
- env->irq_pending = env->regs[CR_IPENDING] & env->regs[CR_IENABLE];
-
- if (env->irq_pending && (env->regs[CR_STATUS] & CR_STATUS_PIE)) {
- env->irq_pending = 0;
+ if (env->regs[CR_IPENDING]) {
cpu_interrupt(cs, CPU_INTERRUPT_HARD);
- } else if (!env->irq_pending) {
+ } else {
cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD);
}
}
@@ -134,7 +131,8 @@ static bool nios2_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
CPUNios2State *env = &cpu->env;
if ((interrupt_request & CPU_INTERRUPT_HARD) &&
- (env->regs[CR_STATUS] & CR_STATUS_PIE)) {
+ (env->regs[CR_STATUS] & CR_STATUS_PIE) &&
+ (env->regs[CR_IPENDING] & env->regs[CR_IENABLE])) {
cs->exception_index = EXCP_IRQ;
nios2_cpu_do_interrupt(cs);
return true;
diff --git a/target/nios2/op_helper.c b/target/nios2/op_helper.c
index d729379e4d..caa885f7b4 100644
--- a/target/nios2/op_helper.c
+++ b/target/nios2/op_helper.c
@@ -21,28 +21,9 @@
#include "qemu/osdep.h"
#include "cpu.h"
#include "exec/helper-proto.h"
-#include "exec/cpu_ldst.h"
#include "exec/exec-all.h"
#include "qemu/main-loop.h"
-#if !defined(CONFIG_USER_ONLY)
-static void nios2_check_interrupts(CPUNios2State *env)
-{
- if (env->irq_pending &&
- (env->regs[CR_STATUS] & CR_STATUS_PIE)) {
- env->irq_pending = 0;
- cpu_interrupt(env_cpu(env), CPU_INTERRUPT_HARD);
- }
-}
-
-void helper_check_interrupts(CPUNios2State *env)
-{
- qemu_mutex_lock_iothread();
- nios2_check_interrupts(env);
- qemu_mutex_unlock_iothread();
-}
-#endif /* !CONFIG_USER_ONLY */
-
void helper_raise_exception(CPUNios2State *env, uint32_t index)
{
CPUState *cs = env_cpu(env);
diff --git a/target/nios2/translate.c b/target/nios2/translate.c
index b17ce25a36..ce3aacf59d 100644
--- a/target/nios2/translate.c
+++ b/target/nios2/translate.c
@@ -489,19 +489,15 @@ static void wrctl(DisasContext *dc, uint32_t code, uint32_t flags)
case CR_IPENDING:
/* ipending is read only, writes ignored. */
break;
+ case CR_STATUS:
+ case CR_IENABLE:
+ /* If interrupts were enabled using WRCTL, trigger them. */
+ dc->base.is_jmp = DISAS_UPDATE;
+ /* fall through */
default:
tcg_gen_mov_tl(cpu_R[instr.imm5 + CR_BASE], v);
break;
}
-
- /* If interrupts were enabled using WRCTL, trigger them. */
- if ((instr.imm5 + CR_BASE) == CR_STATUS) {
- if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
- gen_io_start();
- }
- gen_helper_check_interrupts(cpu_env);
- dc->base.is_jmp = DISAS_UPDATE;
- }
#endif
}
--
2.25.1
next prev parent reply other threads:[~2022-02-27 18:25 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-27 18:21 [PATCH 0/7] target/nios2: Rewrite interrupt handling Richard Henderson
2022-02-27 18:21 ` [PATCH 1/7] target/nios2: Remove mmu_read_debug Richard Henderson
2022-03-02 12:44 ` Peter Maydell
2022-02-27 18:21 ` [PATCH 2/7] target/nios2: Replace MMU_LOG with tracepoints Richard Henderson
2022-02-27 22:01 ` Philippe Mathieu-Daudé
2022-03-02 12:48 ` Peter Maydell
2022-02-27 18:21 ` [PATCH 3/7] target/nios2: Only build mmu.c for system mode Richard Henderson
2022-02-27 22:01 ` Philippe Mathieu-Daudé
2022-03-02 12:49 ` Peter Maydell
2022-02-27 18:21 ` [PATCH 4/7] target/nios2: Hoist R_ZERO check in rdctl Richard Henderson
2022-02-27 22:02 ` Philippe Mathieu-Daudé
2022-03-02 12:50 ` Peter Maydell
2022-02-27 18:21 ` [PATCH 5/7] target/nios2: Split mmu_write Richard Henderson
2022-03-02 12:57 ` Peter Maydell
2022-02-27 18:21 ` [PATCH 6/7] target/nios2: Special case ipending in rdctl and wrctl Richard Henderson
2022-02-27 22:06 ` Philippe Mathieu-Daudé
2022-03-02 13:00 ` Peter Maydell
2022-02-27 18:21 ` Richard Henderson [this message]
2022-02-27 22:05 ` [PATCH 7/7] target/nios2: Rewrite interrupt handling Philippe Mathieu-Daudé
2022-03-02 13:06 ` Peter Maydell
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=20220227182125.21809-8-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=amir.gonnen@neuroblade.ai \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).