Merge "Looking for minImportedHostPointerAlignment on memory import operation" into main
diff --git a/guest/platform/kumquat/VirtGpuKumquat.h b/guest/platform/kumquat/VirtGpuKumquat.h
index d940ffd..d22f210 100644
--- a/guest/platform/kumquat/VirtGpuKumquat.h
+++ b/guest/platform/kumquat/VirtGpuKumquat.h
@@ -17,7 +17,13 @@
 #pragma once
 
 #include "VirtGpu.h"
+
+// Blueprint and Meson builds place things differently
+#if defined(ANDROID)
+#include "virtgpu_kumquat_ffi.h"
+#else
 #include "virtgpu_kumquat/virtgpu_kumquat_ffi.h"
+#endif
 
 class VirtGpuKumquatResource : public std::enable_shared_from_this<VirtGpuKumquatResource>,
                                public VirtGpuResource {
diff --git a/guest/platform/kumquat/VirtGpuKumquatBlob.cpp b/guest/platform/kumquat/VirtGpuKumquatBlob.cpp
index cd0e3e0..991d53d 100644
--- a/guest/platform/kumquat/VirtGpuKumquatBlob.cpp
+++ b/guest/platform/kumquat/VirtGpuKumquatBlob.cpp
@@ -23,7 +23,6 @@
 #include <cstring>
 
 #include "VirtGpuKumquat.h"
-#include "virtgpu_kumquat/virtgpu_kumquat_ffi.h"
 
 VirtGpuKumquatResource::VirtGpuKumquatResource(struct virtgpu_kumquat* virtGpu, uint32_t blobHandle,
                                                uint32_t resourceHandle, uint64_t size)
@@ -53,7 +52,8 @@
 
     ret = virtgpu_kumquat_resource_map(mVirtGpu, &map);
     if (ret < 0) {
-        ALOGE("Mapping failed with %s", strerror(errno));
+        ALOGE("Mapping failed with %s for resource %u blob %u", strerror(errno), mResourceHandle,
+              mBlobHandle);
         return nullptr;
     }
 
diff --git a/guest/platform/kumquat/VirtGpuKumquatDevice.cpp b/guest/platform/kumquat/VirtGpuKumquatDevice.cpp
index 6101cc1..774c9dc 100644
--- a/guest/platform/kumquat/VirtGpuKumquatDevice.cpp
+++ b/guest/platform/kumquat/VirtGpuKumquatDevice.cpp
@@ -26,15 +26,13 @@
 
 #include "VirtGpuKumquat.h"
 #include "virtgpu_gfxstream_protocol.h"
-#include "virtgpu_kumquat/virtgpu_kumquat_ffi.h"
 
 #define PARAM(x) \
     (struct VirtGpuParam) { x, #x, 0 }
 
 static inline uint32_t align_up(uint32_t n, uint32_t a) { return ((n + a - 1) / a) * a; }
 
-VirtGpuKumquatDevice::VirtGpuKumquatDevice(enum VirtGpuCapset capset, int fd)
-    : VirtGpuDevice(capset) {
+VirtGpuKumquatDevice::VirtGpuKumquatDevice(enum VirtGpuCapset capset, int) : VirtGpuDevice(capset) {
     struct VirtGpuParam params[] = {
         PARAM(VIRTGPU_KUMQUAT_PARAM_3D_FEATURES),
         PARAM(VIRTGPU_KUMQUAT_PARAM_CAPSET_QUERY_FIX),
@@ -60,7 +58,7 @@
     processName = getprogname();
 #endif
 
-    ret = virtgpu_kumquat_init(&mVirtGpu);
+    ret = virtgpu_kumquat_init(&mVirtGpu, nullptr);
     if (ret) {
         ALOGV("Failed to init virtgpu kumquat");
         return;
diff --git a/guest/platform/kumquat/VirtGpuKumquatSync.cpp b/guest/platform/kumquat/VirtGpuKumquatSync.cpp
index d152bff..47884fc 100644
--- a/guest/platform/kumquat/VirtGpuKumquatSync.cpp
+++ b/guest/platform/kumquat/VirtGpuKumquatSync.cpp
@@ -23,9 +23,24 @@
 VirtGpuKumquatSyncHelper::VirtGpuKumquatSyncHelper() {}
 
 int VirtGpuKumquatSyncHelper::wait(int syncFd, int timeoutMilliseconds) {
-    (void)syncFd;
     (void)timeoutMilliseconds;
-    return -1;
+    // So far, syncfds are EventFd in the Kumquat layer. This may change
+    uint64_t count = 1;
+    ssize_t bytes_read = read(syncFd, &count, sizeof(count));
+
+    if (bytes_read < 0) {
+        return bytes_read;
+    }
+
+    // A successful read decrements the eventfd's counter to zero.  In
+    // case the eventfd is waited on again, or a dup is waited on, we
+    // have to write to the eventfd for the next read.
+    ssize_t bytes_written = write(syncFd, &count, sizeof(count));
+    if (bytes_written < 0) {
+        return bytes_written;
+    }
+
+    return 0;
 }
 
 int VirtGpuKumquatSyncHelper::dup(int syncFd) { return ::dup(syncFd); }