qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 16/26] hw/display/apple-gfx: Asynchronous MMIO writes on x86-64


From: Phil Dennis-Jordan
Subject: [PATCH 16/26] hw/display/apple-gfx: Asynchronous MMIO writes on x86-64
Date: Mon, 15 Jul 2024 23:06:55 +0200

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 = {
-- 
2.39.3 (Apple Git-146)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]