venus: handle device probing properly.

Currently if you try to probe the virtio ICD on a non-virtio system
it will fail in CreateInstance which causes the loader to spit on the
screen.

However instance creation shouldn't fail, the driver should just
not enumerate any devices in this case. It's a bit tricky to ensure
this, but return instance and then handle instance destruction
and fail device enumeration.

Cc: mesa-stable
Reviewed-by: Ryan Neph
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32266>
(cherry picked from commit 25b8f4f714)
This commit is contained in:
Dave Airlie
2024-11-21 08:39:20 +10:00
committed by Dylan Baker
parent 5770bac174
commit c2701a90c6
3 changed files with 18 additions and 8 deletions

View File

@@ -304,7 +304,7 @@
"description": "venus: handle device probing properly.",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View File

@@ -276,6 +276,7 @@ vn_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
return vn_error(NULL, result);
}
VkInstance instance_handle = vn_instance_to_handle(instance);
/* ring_idx = 0 reserved for CPU timeline */
instance->ring_idx_used_mask = 0x1;
@@ -294,6 +295,10 @@ vn_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
}
result = vn_instance_init_renderer(instance);
if (result == VK_ERROR_INITIALIZATION_FAILED) {
*pInstance = instance_handle;
return VK_SUCCESS;
}
if (result != VK_SUCCESS)
goto out_mtx_destroy;
@@ -333,7 +338,6 @@ vn_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
local_create_info.pApplicationInfo = &local_app_info;
}
VkInstance instance_handle = vn_instance_to_handle(instance);
result = vn_call_vkCreateInstance(instance->ring.ring, pCreateInfo, NULL,
&instance_handle);
if (result != VK_SUCCESS)
@@ -407,16 +411,18 @@ vn_DestroyInstance(VkInstance _instance,
mtx_destroy(&instance->physical_device.mutex);
mtx_destroy(&instance->ring_idx_mutex);
vn_call_vkDestroyInstance(instance->ring.ring, _instance, NULL);
if (instance->renderer) {
vn_call_vkDestroyInstance(instance->ring.ring, _instance, NULL);
vn_instance_fini_ring(instance);
vn_instance_fini_ring(instance);
vn_renderer_shmem_pool_fini(instance->renderer,
&instance->reply_shmem_pool);
vn_renderer_shmem_pool_fini(instance->renderer,
&instance->reply_shmem_pool);
vn_renderer_shmem_pool_fini(instance->renderer, &instance->cs_shmem_pool);
vn_renderer_shmem_pool_fini(instance->renderer, &instance->cs_shmem_pool);
vn_renderer_destroy(instance->renderer, alloc);
vn_renderer_destroy(instance->renderer, alloc);
}
driDestroyOptionCache(&instance->dri_options);
driDestroyOptionInfo(&instance->available_dri_options);

View File

@@ -1500,6 +1500,10 @@ enumerate_physical_devices(struct vn_instance *instance,
struct vn_physical_device *physical_devs = NULL;
VkResult result;
if (!instance->renderer) {
*out_count = 0;
return VK_SUCCESS;
}
uint32_t count = 0;
result = vn_call_vkEnumeratePhysicalDevices(
ring, vn_instance_to_handle(instance), &count, NULL);