venus: add error log coverage for virtgpu backend
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

Make life easier for ci debug, remote debug, and any kind of bug report
inspection. Long need to add this.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38443>
This commit is contained in:
Yiwei Zhang 2025-11-14 01:03:17 -08:00 committed by Marge Bot
parent 0afc408cb9
commit a49b7adad8

View file

@ -646,8 +646,13 @@ virtgpu_ioctl_resource_create_blob(struct virtgpu *gpu,
.blob_id = blob_id,
};
if (virtgpu_ioctl(gpu, DRM_IOCTL_VIRTGPU_RESOURCE_CREATE_BLOB, &args))
if (virtgpu_ioctl(gpu, DRM_IOCTL_VIRTGPU_RESOURCE_CREATE_BLOB, &args)) {
vn_log(gpu->instance,
"RESOURCE_CREATE_BLOB failed: type=%u, flags=%u, size=%zu, "
"id=%" PRIu64 ", err=%s",
blob_mem, blob_flags, blob_size, blob_id, strerror(errno));
return 0;
}
*res_id = args.res_handle;
return args.bo_handle;
@ -662,7 +667,14 @@ virtgpu_ioctl_resource_info(struct virtgpu *gpu,
.bo_handle = gem_handle,
};
return virtgpu_ioctl(gpu, DRM_IOCTL_VIRTGPU_RESOURCE_INFO, info);
const int ret = virtgpu_ioctl(gpu, DRM_IOCTL_VIRTGPU_RESOURCE_INFO, info);
if (ret) {
vn_log(gpu->instance, "RESOURCE_INFO failed: handle=%u, err=%s",
gem_handle, strerror(errno));
return ret;
}
return 0;
}
static void
@ -687,7 +699,14 @@ virtgpu_ioctl_prime_handle_to_fd(struct virtgpu *gpu,
};
const int ret = virtgpu_ioctl(gpu, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args);
return ret ? -1 : args.fd;
if (ret) {
vn_log(gpu->instance,
"PRIME_HANDLE_TO_FD failed: handle=%u, mappable=%d, err=%s",
gem_handle, mappable, strerror(errno));
return -1;
}
return args.fd;
}
static uint32_t
@ -698,7 +717,13 @@ virtgpu_ioctl_prime_fd_to_handle(struct virtgpu *gpu, int fd)
};
const int ret = virtgpu_ioctl(gpu, DRM_IOCTL_PRIME_FD_TO_HANDLE, &args);
return ret ? 0 : args.handle;
if (ret) {
vn_log(gpu->instance, "PRIME_FD_TO_HANDLE failed: fd=%d, err=%s", fd,
strerror(errno));
return 0;
}
return args.handle;
}
static void *
@ -708,13 +733,21 @@ virtgpu_ioctl_map(struct virtgpu *gpu, uint32_t gem_handle, size_t size)
.handle = gem_handle,
};
if (virtgpu_ioctl(gpu, DRM_IOCTL_VIRTGPU_MAP, &args))
if (virtgpu_ioctl(gpu, DRM_IOCTL_VIRTGPU_MAP, &args)) {
vn_log(gpu->instance, "MAP failed: handle=%u, err=%s", gem_handle,
strerror(errno));
return NULL;
}
void *ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, gpu->fd,
args.offset);
if (ptr == MAP_FAILED)
if (ptr == MAP_FAILED) {
vn_log(
gpu->instance,
"mmap failed: gpu_fd=%d, handle=%u, size=%zu, offset=%llu, err=%s",
gpu->fd, gem_handle, size, args.offset, strerror(errno));
return NULL;
}
return ptr;
}
@ -1179,8 +1212,13 @@ virtgpu_bo_create_from_dma_buf(struct vn_renderer *renderer,
size_t mmap_size = 0;
if (info.blob_mem) {
/* must be VIRTGPU_BLOB_MEM_HOST3D or VIRTGPU_BLOB_MEM_GUEST_VRAM */
if (info.blob_mem != gpu->bo_blob_mem)
if (info.blob_mem != gpu->bo_blob_mem) {
vn_log(gpu->instance,
"dma-buf import failed: info.blob_mem(%u) != "
"gpu->bo_blob_mem(%u)",
info.blob_mem, gpu->bo_blob_mem);
goto fail;
}
blob_flags |= virtgpu_bo_blob_flags(gpu, flags, 0);
@ -1208,10 +1246,19 @@ virtgpu_bo_create_from_dma_buf(struct vn_renderer *renderer,
* might only be memset to 0 and is not considered initialized in theory
*/
if (bo->gem_handle == gem_handle) {
if (bo->base.mmap_size < mmap_size)
if (bo->base.mmap_size < mmap_size) {
vn_log(
gpu->instance,
"dma-buf import failed: bo->base.mmap_size(%zu) < mmap_size(%zu)",
bo->base.mmap_size, mmap_size);
goto fail;
if (blob_flags & ~bo->blob_flags)
}
if (blob_flags & ~bo->blob_flags) {
vn_log(gpu->instance,
"dma-buf import failed: blob_flags(%u) & ~bo->blob_flags(%u)",
blob_flags, bo->blob_flags);
goto fail;
}
/* we can't use vn_renderer_bo_ref as the refcount may drop to 0
* temporarily before virtgpu_bo_destroy grabs the lock
@ -1278,6 +1325,10 @@ virtgpu_bo_create_from_device_memory(
assert(info.blob_mem);
if (info.size < size) {
virtgpu_ioctl_gem_close(gpu, gem_handle);
vn_log(gpu->instance,
"blob mem create failed: info.size(%u) < size(%" PRIu64 ")",
info.size, size);
return VK_ERROR_INVALID_EXTERNAL_HANDLE;
}