This change ensures that the MMIO write calls into the PVG
framework are performed asynchronously on a background dispatch
queue. Without this, we rapidly run into re-entrant MMIO issues.
This problem only seems to exist on x86-64 hosts. Conversely,
doing it async on arm64/vmapple causes other issues,
so we're
left with 2 different implementations.
Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
---
hw/display/apple-gfx.m | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/hw/display/apple-gfx.m b/hw/display/apple-gfx.m
index 806feb58fa..48463e5a1f 100644
--- a/hw/display/apple-gfx.m
+++ b/hw/display/apple-gfx.m
@@ -67,15 +67,28 @@ static uint64_t apple_gfx_read(void *opaque, hwaddr offset,
unsigned size)
return res;
}
-static void apple_gfx_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
+static void apple_gfx_write(void *opaque, hwaddr offset, uint64_t val,
+ unsigned size)
{
AppleGFXState *s = opaque;
trace_apple_gfx_write(offset, val);
+#ifdef __x86_64__
+ id<PGDevice> dev = s->pgdev;
+ dispatch_queue_t bg_queue = NULL;
+
+ bg_queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul);
+ [dev retain];
+ dispatch_async(bg_queue, ^{
+ [dev mmioWriteAtOffset:offset value:val];
+ [dev release];
+ });
+#else
bql_unlock();
[s->pgdev mmioWriteAtOffset:offset value:val];
bql_lock();
+#endif
}
static const MemoryRegionOps apple_gfx_ops = {