[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 4/9] edu: add smp_mb__after_rmw()
From: |
Paolo Bonzini |
Subject: |
[PULL 4/9] edu: add smp_mb__after_rmw() |
Date: |
Tue, 7 Mar 2023 12:43:24 +0100 |
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>
---
hw/misc/edu.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/misc/edu.c b/hw/misc/edu.c
index e935c418d400..a1f8bc77e770 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);
--
2.39.1
- [PULL 0/9] Fix missing memory barriers on ARM, Paolo Bonzini, 2023/03/07
- [PULL 1/9] qatomic: add smp_mb__before/after_rmw(), Paolo Bonzini, 2023/03/07
- [PULL 2/9] qemu-thread-posix: cleanup, fix, document QemuEvent, Paolo Bonzini, 2023/03/07
- [PULL 3/9] qemu-thread-win32: cleanup, fix, document QemuEvent, Paolo Bonzini, 2023/03/07
- [PULL 4/9] edu: add smp_mb__after_rmw(),
Paolo Bonzini <=
- [PULL 5/9] aio-wait: switch to smp_mb__after_rmw(), Paolo Bonzini, 2023/03/07
- [PULL 6/9] qemu-coroutine-lock: add smp_mb__after_rmw(), Paolo Bonzini, 2023/03/07
- [PULL 8/9] async: update documentation of the memory barriers, Paolo Bonzini, 2023/03/07
- [PULL 7/9] physmem: add missing memory barrier, Paolo Bonzini, 2023/03/07
- [PULL 9/9] async: clarify usage of barriers in the polling case, Paolo Bonzini, 2023/03/07
- Re: [PULL 0/9] Fix missing memory barriers on ARM, Peter Maydell, 2023/03/09