[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v3 51/56] riscv: acquire the BQL in cpu_has_work
From: |
Emilio G. Cota |
Subject: |
[Qemu-devel] [RFC v3 51/56] riscv: acquire the BQL in cpu_has_work |
Date: |
Thu, 18 Oct 2018 21:06:20 -0400 |
Soon we will call cpu_has_work without the BQL.
Cc: Michael Clark <address@hidden>
Cc: Palmer Dabbelt <address@hidden>
Cc: Sagar Karandikar <address@hidden>
Cc: Bastian Koppelmann <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
---
target/riscv/cpu.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index d630e8fd6c..b10995c807 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -18,6 +18,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/main-loop.h"
#include "qemu/log.h"
#include "cpu.h"
#include "exec/exec-all.h"
@@ -244,11 +245,14 @@ static void riscv_cpu_synchronize_from_tb(CPUState *cs,
TranslationBlock *tb)
env->pc = tb->pc;
}
-static bool riscv_cpu_has_work(CPUState *cs)
+static bool riscv_cpu_has_work_locked(CPUState *cs)
{
#ifndef CONFIG_USER_ONLY
RISCVCPU *cpu = RISCV_CPU(cs);
CPURISCVState *env = &cpu->env;
+
+ g_assert(qemu_mutex_iothread_locked());
+
/*
* Definition of the WFI instruction requires it to ignore the privilege
* mode and delegation registers, but respect individual enables
@@ -259,6 +263,21 @@ static bool riscv_cpu_has_work(CPUState *cs)
#endif
}
+static bool riscv_cpu_has_work(CPUState *cs)
+{
+ if (!qemu_mutex_iothread_locked()) {
+ bool ret;
+
+ cpu_mutex_unlock(cs);
+ qemu_mutex_lock_iothread();
+ cpu_mutex_lock(cs);
+ ret = riscv_cpu_has_work_locked(cs);
+ qemu_mutex_unlock_iothread();
+ return ret;
+ }
+ return riscv_cpu_has_work_locked(cs);
+}
+
void restore_state_to_opc(CPURISCVState *env, TranslationBlock *tb,
target_ulong *data)
{
--
2.17.1
- [Qemu-devel] [RFC v3 47/56] cpu: call .cpu_has_work with the CPU lock held, (continued)
- [Qemu-devel] [RFC v3 47/56] cpu: call .cpu_has_work with the CPU lock held, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 43/56] openrisc: convert to cpu_interrupt_request, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 37/56] mips: convert to cpu_interrupt_request, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 42/56] sparc: convert to cpu_interrupt_request, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 30/56] i386: convert to cpu_interrupt_request, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 49/56] mips: acquire the BQL in cpu_has_work, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 51/56] riscv: acquire the BQL in cpu_has_work,
Emilio G. Cota <=
- [Qemu-devel] [RFC v3 52/56] sparc: acquire the BQL in cpu_has_work, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 31/56] ppc: convert to cpu_interrupt_request, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 48/56] ppc: acquire the BQL in cpu_has_work, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 50/56] s390: acquire the BQL in cpu_has_work, Emilio G. Cota, 2018/10/18
- [Qemu-devel] [RFC v3 39/56] s390x: convert to cpu_interrupt_request, Emilio G. Cota, 2018/10/18