[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v9 62/74] cpu: call .cpu_has_work with the CPU lock held
From: |
Robert Foley |
Subject: |
[PATCH v9 62/74] cpu: call .cpu_has_work with the CPU lock held |
Date: |
Thu, 21 May 2020 12:39:59 -0400 |
From: "Emilio G. Cota" <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Reviewed-by: Alex Bennée <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
Signed-off-by: Robert Foley <address@hidden>
---
include/hw/core/cpu.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 6ed806db60..7bf7700630 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -80,7 +80,8 @@ struct TranslationBlock;
* instantiatable CPU type.
* @parse_features: Callback to parse command line arguments.
* @reset_dump_flags: #CPUDumpFlags to use for reset logging.
- * @has_work: Callback for checking if there is work to do.
+ * @has_work: Callback for checking if there is work to do. Called with the
+ * CPU lock held.
* @do_interrupt: Callback for interrupt handling.
* @do_unaligned_access: Callback for unaligned access handling, if
* the target defines #TARGET_ALIGNED_ONLY.
@@ -799,9 +800,16 @@ const char *parse_cpu_option(const char *cpu_option);
static inline bool cpu_has_work(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
+ bool ret;
g_assert(cc->has_work);
- return cc->has_work(cpu);
+ if (cpu_mutex_locked(cpu)) {
+ return cc->has_work(cpu);
+ }
+ cpu_mutex_lock(cpu);
+ ret = cc->has_work(cpu);
+ cpu_mutex_unlock(cpu);
+ return ret;
}
/**
--
2.17.1
- [PATCH v9 51/74] mips: convert to cpu_interrupt_request, (continued)
- [PATCH v9 51/74] mips: convert to cpu_interrupt_request, Robert Foley, 2020/05/21
- [PATCH v9 53/74] s390x: convert to cpu_interrupt_request, Robert Foley, 2020/05/21
- [PATCH v9 52/74] nios: convert to cpu_interrupt_request, Robert Foley, 2020/05/21
- [PATCH v9 55/74] moxie: convert to cpu_interrupt_request, Robert Foley, 2020/05/21
- [PATCH v9 56/74] sparc: convert to cpu_interrupt_request, Robert Foley, 2020/05/21
- [PATCH v9 58/74] unicore32: convert to cpu_interrupt_request, Robert Foley, 2020/05/21
- [PATCH v9 57/74] openrisc: convert to cpu_interrupt_request, Robert Foley, 2020/05/21
- [PATCH v9 54/74] alpha: convert to cpu_interrupt_request, Robert Foley, 2020/05/21
- [PATCH v9 61/74] cpu: convert to interrupt_request, Robert Foley, 2020/05/21
- [PATCH v9 60/74] accel/tcg: convert to cpu_interrupt_request, Robert Foley, 2020/05/21
- [PATCH v9 62/74] cpu: call .cpu_has_work with the CPU lock held,
Robert Foley <=
- [PATCH v9 59/74] microblaze: convert to cpu_interrupt_request, Robert Foley, 2020/05/21
- [PATCH v9 63/74] cpu: introduce cpu_has_work_with_iothread_lock, Robert Foley, 2020/05/21
- [PATCH v9 64/74] ppc: convert to cpu_has_work_with_iothread_lock, Robert Foley, 2020/05/21
- [PATCH v9 65/74] mips: convert to cpu_has_work_with_iothread_lock, Robert Foley, 2020/05/21
- [PATCH v9 67/74] riscv: convert to cpu_has_work_with_iothread_lock, Robert Foley, 2020/05/21
- [PATCH v9 66/74] s390x: convert to cpu_has_work_with_iothread_lock, Robert Foley, 2020/05/21
- [PATCH v9 68/74] sparc: convert to cpu_has_work_with_iothread_lock, Robert Foley, 2020/05/21
- [PATCH v9 69/74] xtensa: convert to cpu_has_work_with_iothread_lock, Robert Foley, 2020/05/21
- [PATCH v9 70/74] cpu: rename all_cpu_threads_idle to qemu_tcg_rr_all_cpu_threads_idle, Robert Foley, 2020/05/21