venus: Make sure that guest allocated blobs from hostmem are mappable

For guest-based blob allocations from hostmem (Host visible memory),
to make sure that virtio-gpu driver will send to the host the address
(offset in the region) of the allocated blob using RESOURCE_MAP_BLOB
command a flag VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT must be set.

Otherwise, if the upper layers didn't set it, host can't import memory
and guest allocation from Host visible memory region makes no sense.

Signed-off-by: Andrew D. Gazizov <andrew.gazizov@opensynergy.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26130>
This commit is contained in:
Andrew Gazizov 2023-11-09 09:33:43 +01:00 committed by Marge Bot
parent 8929889563
commit bafc27583c

View file

@ -346,9 +346,18 @@ vn_device_memory_alloc_guest_vram(struct vn_device *dev,
const struct vk_device_memory *mem_vk = &mem->base.base;
const VkMemoryType *mem_type = &dev->physical_device->memory_properties
.memoryTypes[mem_vk->memory_type_index];
VkMemoryPropertyFlags flags = mem_type->propertyFlags;
/* For external allocation handles, it's possible scenario when requested
* non-mappable memory. To make sure that virtio-gpu driver will send to
* the host the address of allocated blob using RESOURCE_MAP_BLOB command
* a flag VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT must be set.
*/
if (mem_vk->export_handle_types)
flags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
VkResult result = vn_renderer_bo_create_from_device_memory(
dev->renderer, mem_vk->size, mem->base.id, mem_type->propertyFlags,
dev->renderer, mem_vk->size, mem->base.id, flags,
mem_vk->export_handle_types, &mem->base_bo);
if (result != VK_SUCCESS) {
return result;