venus: make cross-device optional
Cross-device is a virtio-gpu feature that enables sharing host blob dma-bufs with other virtio devices, like virtio-wl or virtio-video. This feature is mainly used by ChromeOS and not required if there is no dma-buf sharing. Venus has a hard requirement for the cross-device feature. Qemu doesn't support cross-device. Relax cross-device feature requirement by making it optional, allowing Venus to work on Qemu. Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29040>
This commit is contained in:

committed by
Marge Bot

parent
811ed62865
commit
087e9a96d1
@@ -114,6 +114,8 @@ struct virtgpu {
|
||||
mtx_t dma_buf_import_mutex;
|
||||
|
||||
struct vn_renderer_shmem_cache shmem_cache;
|
||||
|
||||
bool supports_cross_device;
|
||||
};
|
||||
|
||||
#ifdef SIMULATE_SYNCOBJ
|
||||
@@ -1120,7 +1122,8 @@ virtgpu_bo_destroy(struct vn_renderer *renderer, struct vn_renderer_bo *_bo)
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
virtgpu_bo_blob_flags(VkMemoryPropertyFlags flags,
|
||||
virtgpu_bo_blob_flags(struct virtgpu *gpu,
|
||||
VkMemoryPropertyFlags flags,
|
||||
VkExternalMemoryHandleTypeFlags external_handles)
|
||||
{
|
||||
uint32_t blob_flags = 0;
|
||||
@@ -1128,8 +1131,10 @@ virtgpu_bo_blob_flags(VkMemoryPropertyFlags flags,
|
||||
blob_flags |= VIRTGPU_BLOB_FLAG_USE_MAPPABLE;
|
||||
if (external_handles)
|
||||
blob_flags |= VIRTGPU_BLOB_FLAG_USE_SHAREABLE;
|
||||
if (external_handles & VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT)
|
||||
blob_flags |= VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE;
|
||||
if (external_handles & VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT) {
|
||||
if (gpu->supports_cross_device)
|
||||
blob_flags |= VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE;
|
||||
}
|
||||
|
||||
return blob_flags;
|
||||
}
|
||||
@@ -1168,7 +1173,7 @@ virtgpu_bo_create_from_dma_buf(struct vn_renderer *renderer,
|
||||
if (info.blob_mem != gpu->bo_blob_mem)
|
||||
goto fail;
|
||||
|
||||
blob_flags |= virtgpu_bo_blob_flags(flags, 0);
|
||||
blob_flags |= virtgpu_bo_blob_flags(gpu, flags, 0);
|
||||
|
||||
/* mmap_size is only used when mappable */
|
||||
mmap_size = 0;
|
||||
@@ -1228,7 +1233,7 @@ virtgpu_bo_create_from_device_memory(
|
||||
struct vn_renderer_bo **out_bo)
|
||||
{
|
||||
struct virtgpu *gpu = (struct virtgpu *)renderer;
|
||||
const uint32_t blob_flags = virtgpu_bo_blob_flags(flags, external_handles);
|
||||
const uint32_t blob_flags = virtgpu_bo_blob_flags(gpu, flags, external_handles);
|
||||
|
||||
uint32_t res_id;
|
||||
uint32_t gem_handle = virtgpu_ioctl_resource_create_blob(
|
||||
@@ -1483,8 +1488,7 @@ virtgpu_init_params(struct virtgpu *gpu)
|
||||
{
|
||||
const uint64_t required_params[] = {
|
||||
VIRTGPU_PARAM_3D_FEATURES, VIRTGPU_PARAM_CAPSET_QUERY_FIX,
|
||||
VIRTGPU_PARAM_RESOURCE_BLOB, VIRTGPU_PARAM_CROSS_DEVICE,
|
||||
VIRTGPU_PARAM_CONTEXT_INIT,
|
||||
VIRTGPU_PARAM_RESOURCE_BLOB, VIRTGPU_PARAM_CONTEXT_INIT,
|
||||
};
|
||||
uint64_t val;
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(required_params); i++) {
|
||||
@@ -1515,6 +1519,14 @@ virtgpu_init_params(struct virtgpu *gpu)
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
|
||||
/* Cross-device feature is optional. It enables sharing dma-bufs
|
||||
* with other virtio devices, like virtio-wl or virtio-video used
|
||||
* by ChromeOS VMs. Qemu doesn't support cross-device sharing.
|
||||
*/
|
||||
val = virtgpu_ioctl_getparam(gpu, VIRTGPU_PARAM_CROSS_DEVICE);
|
||||
if (val)
|
||||
gpu->supports_cross_device = true;
|
||||
|
||||
/* implied by CONTEXT_INIT uapi */
|
||||
gpu->max_timeline_count = 64;
|
||||
|
||||
|
Reference in New Issue
Block a user