diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2023-03-02 11:16:13 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2023-03-07 12:38:40 +0100 |
commit | 2482aeea4195ad84cf3d4e5b15b28ec5b420ed5a (patch) | |
tree | b3226141339787c9698ba562f3e3b7eaef397f06 /hw | |
parent | 6c5df4b48f0c52a61342ecb307a43f4c2a3565c4 (diff) | |
download | qemu-2482aeea4195ad84cf3d4e5b15b28ec5b420ed5a.zip qemu-2482aeea4195ad84cf3d4e5b15b28ec5b420ed5a.tar.gz qemu-2482aeea4195ad84cf3d4e5b15b28ec5b420ed5a.tar.bz2 |
edu: add smp_mb__after_rmw()
Ensure ordering between clearing the COMPUTING flag and checking
IRQFACT, and between setting the IRQFACT flag and checking
COMPUTING. This ensures that no wakeups are lost.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/misc/edu.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/hw/misc/edu.c b/hw/misc/edu.c index e935c41..a1f8bc7 100644 --- a/hw/misc/edu.c +++ b/hw/misc/edu.c @@ -267,6 +267,8 @@ static void edu_mmio_write(void *opaque, hwaddr addr, uint64_t val, case 0x20: if (val & EDU_STATUS_IRQFACT) { qatomic_or(&edu->status, EDU_STATUS_IRQFACT); + /* Order check of the COMPUTING flag after setting IRQFACT. */ + smp_mb__after_rmw(); } else { qatomic_and(&edu->status, ~EDU_STATUS_IRQFACT); } @@ -349,6 +351,9 @@ static void *edu_fact_thread(void *opaque) qemu_mutex_unlock(&edu->thr_mutex); qatomic_and(&edu->status, ~EDU_STATUS_COMPUTING); + /* Clear COMPUTING flag before checking IRQFACT. */ + smp_mb__after_rmw(); + if (qatomic_read(&edu->status) & EDU_STATUS_IRQFACT) { qemu_mutex_lock_iothread(); edu_raise_irq(edu, FACT_IRQ); |