[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 19/21] target/sparc: add BQL to do_interrupt and cpu_exec_inte
From: |
Robert Foley |
Subject: |
[PATCH v1 19/21] target/sparc: add BQL to do_interrupt and cpu_exec_interrupt |
Date: |
Wed, 5 Aug 2020 14:13:01 -0400 |
This is part of a series of changes to remove the implied BQL
from the common code of cpu_handle_interrupt and
cpu_handle_exception. As part of removing the implied BQL
from the common code, we are pushing the BQL holding
down into the per-arch implementation functions of
do_interrupt and cpu_exec_interrupt.
The purpose of this set of changes is to set the groundwork
so that an arch could move towards removing
the BQL from the cpu_handle_interrupt/exception paths.
This approach was suggested by Paolo Bonzini.
For reference, here are two key posts in the discussion, explaining
the reasoning/benefits of this approach.
https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html
https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html
Signed-off-by: Robert Foley <robert.foley@linaro.org>
---
target/sparc/cpu.c | 3 +++
target/sparc/int32_helper.c | 13 ++++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index 20c7c0c434..13b5a038e8 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -79,6 +79,7 @@ static void sparc_cpu_reset(DeviceState *dev)
static bool sparc_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
{
+ qemu_mutex_lock_iothread();
if (interrupt_request & CPU_INTERRUPT_HARD) {
SPARCCPU *cpu = SPARC_CPU(cs);
CPUSPARCState *env = &cpu->env;
@@ -90,10 +91,12 @@ static bool sparc_cpu_exec_interrupt(CPUState *cs, int
interrupt_request)
if (type != TT_EXTINT || cpu_pil_allowed(env, pil)) {
cs->exception_index = env->interrupt_index;
sparc_cpu_do_interrupt(cs);
+ qemu_mutex_unlock_iothread();
return true;
}
}
}
+ qemu_mutex_unlock_iothread();
return false;
}
diff --git a/target/sparc/int32_helper.c b/target/sparc/int32_helper.c
index 9a71e1abd8..3940e945ed 100644
--- a/target/sparc/int32_helper.c
+++ b/target/sparc/int32_helper.c
@@ -69,7 +69,12 @@ void sparc_cpu_do_interrupt(CPUState *cs)
{
SPARCCPU *cpu = SPARC_CPU(cs);
CPUSPARCState *env = &cpu->env;
- int cwp, intno = cs->exception_index;
+ int cwp, intno;
+ bool bql = !qemu_mutex_iothread_locked();
+ if (bql) {
+ qemu_mutex_lock_iothread();
+ }
+ intno = cs->exception_index;
/* Compute PSR before exposing state. */
if (env->cc_op != CC_OP_FLAGS) {
@@ -115,6 +120,9 @@ void sparc_cpu_do_interrupt(CPUState *cs)
"Error state",
cs->exception_index, excp_name_str(cs->exception_index));
}
+ if (bql) {
+ qemu_mutex_unlock_iothread();
+ }
return;
}
#endif
@@ -136,6 +144,9 @@ void sparc_cpu_do_interrupt(CPUState *cs)
env->qemu_irq_ack(env, env->irq_manager, intno);
}
#endif
+ if (bql) {
+ qemu_mutex_unlock_iothread();
+ }
}
#if !defined(CONFIG_USER_ONLY)
--
2.17.1
- [PATCH v1 12/21] target/nios2: add BQL to do_interrupt and cpu_exec_interrupt, (continued)
- [PATCH v1 12/21] target/nios2: add BQL to do_interrupt and cpu_exec_interrupt, Robert Foley, 2020/08/05
- [PATCH v1 13/21] target/openrisc: add BQL to do_interrupt and cpu_exec_interrupt, Robert Foley, 2020/08/05
- [PATCH v1 14/21] target/ppc: add BQL to do_interrupt and cpu_exec_interrupt, Robert Foley, 2020/08/05
- [PATCH v1 15/21] target/riscv: add BQL to do_interrupt and cpu_exec_interrupt, Robert Foley, 2020/08/05
- [PATCH v1 16/21] target/rx: add BQL to do_interrupt and cpu_exec_interrupt, Robert Foley, 2020/08/05
- [PATCH v1 17/21] target/s390x: add BQL to do_interrupt and cpu_exec_interrupt, Robert Foley, 2020/08/05
- [PATCH v1 18/21] target/sh4: add BQL to do_interrupt and cpu_exec_interrupt, Robert Foley, 2020/08/05
- [PATCH v1 19/21] target/sparc: add BQL to do_interrupt and cpu_exec_interrupt,
Robert Foley <=
- [PATCH v1 20/21] target/unicore32: add BQL to do_interrupt and cpu_exec_interrupt, Robert Foley, 2020/08/05
- [PATCH v1 21/21] target/xtensa: add BQL to do_interrupt and cpu_exec_interrupt, Robert Foley, 2020/08/05