gfxstream: guest: kumquat: fixes in preparation for AOSP Kumquat testing

- API for virtgpu_kumquat_init will change with
  crrev.com/c/5747430
- Better error reporting
- Use paths prefered by AOSP
- Handle emulated sync files via eventfd

Reviewed-by: Aaron Ruby <aruby@blackberry.com>
Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27246>
This commit is contained in:
Gurchetan Singh
2024-07-29 16:18:51 -07:00
committed by Marge Bot
parent 1befa2975c
commit eb6124d6bf
4 changed files with 27 additions and 8 deletions

View File

@@ -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 {

View File

@@ -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 @@ VirtGpuResourceMappingPtr VirtGpuKumquatResource::createMapping() {
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;
}

View File

@@ -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 @@ VirtGpuKumquatDevice::VirtGpuKumquatDevice(enum VirtGpuCapset capset, int fd)
processName = getprogname();
#endif
ret = virtgpu_kumquat_init(&mVirtGpu);
ret = virtgpu_kumquat_init(&mVirtGpu, nullptr);
if (ret) {
ALOGV("Failed to init virtgpu kumquat");
return;

View File

@@ -23,9 +23,24 @@ namespace gfxstream {
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); }