venus: workaround a blob_mem mappable size check issue

For blob_mem allocated from virtgpu_virgl backend, the guest mappable
size queried can be smaller than the size returned from image memory
requirement query from the host side. Here we temporarily workaround
until we switch to use cross-domain backend in minigbm.

Cc: 21.2.3 mesa-stable

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12687>
This commit is contained in:
Yiwei Zhang
2021-09-01 21:30:36 +00:00
committed by Marge Bot
parent cbdec34db3
commit 97aa90dec2
3 changed files with 19 additions and 8 deletions
+9 -2
View File
@@ -918,6 +918,7 @@ vn_android_device_import_ahb(struct vn_device *dev,
int dup_fd = -1;
uint64_t alloc_size = 0;
uint32_t mem_type_bits = 0;
bool force_unmappable = false;
VkResult result = VK_SUCCESS;
handle = AHardwareBuffer_getNativeHandle(ahb);
@@ -960,6 +961,12 @@ vn_android_device_import_ahb(struct vn_device *dev,
}
alloc_size = mem_req.size;
/* XXX Workaround before we use cross-domain backend in minigbm. The
* blob_mem allocated from virgl backend can have a queried guest mappable
* size smaller than the size returned from image memory requirement.
*/
force_unmappable = true;
}
if (dedicated_info && dedicated_info->buffer != VK_NULL_HANDLE) {
@@ -999,8 +1006,8 @@ vn_android_device_import_ahb(struct vn_device *dev,
.allocationSize = alloc_size,
.memoryTypeIndex = alloc_info->memoryTypeIndex,
};
result =
vn_device_memory_import_dma_buf(dev, mem, &local_alloc_info, dup_fd);
result = vn_device_memory_import_dma_buf(dev, mem, &local_alloc_info,
force_unmappable, dup_fd);
if (result != VK_SUCCESS) {
close(dup_fd);
return result;
+9 -6
View File
@@ -224,20 +224,23 @@ VkResult
vn_device_memory_import_dma_buf(struct vn_device *dev,
struct vn_device_memory *mem,
const VkMemoryAllocateInfo *alloc_info,
bool force_unmappable,
int fd)
{
VkDevice device = vn_device_to_handle(dev);
VkDeviceMemory memory = vn_device_memory_to_handle(mem);
const VkPhysicalDeviceMemoryProperties *mem_props =
&dev->physical_device->memory_properties.memoryProperties;
const VkMemoryType *mem_type =
&mem_props->memoryTypes[alloc_info->memoryTypeIndex];
VkMemoryPropertyFlags mem_flags =
mem_props->memoryTypes[alloc_info->memoryTypeIndex].propertyFlags;
struct vn_renderer_bo *bo;
VkResult result = VK_SUCCESS;
result = vn_renderer_bo_create_from_dma_buf(dev->renderer,
alloc_info->allocationSize, fd,
mem_type->propertyFlags, &bo);
if (force_unmappable)
mem_flags &= ~VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
result = vn_renderer_bo_create_from_dma_buf(
dev->renderer, alloc_info->allocationSize, fd, mem_flags, &bo);
if (result != VK_SUCCESS)
return result;
@@ -355,7 +358,7 @@ vn_AllocateMemory(VkDevice device,
} else if (export_ahb) {
result = vn_android_device_allocate_ahb(dev, mem, pAllocateInfo, alloc);
} else if (import_fd_info) {
result = vn_device_memory_import_dma_buf(dev, mem, pAllocateInfo,
result = vn_device_memory_import_dma_buf(dev, mem, pAllocateInfo, false,
import_fd_info->fd);
} else if (export_info) {
result = vn_device_memory_alloc(dev, mem, pAllocateInfo, true,
+1
View File
@@ -47,6 +47,7 @@ VkResult
vn_device_memory_import_dma_buf(struct vn_device *dev,
struct vn_device_memory *mem,
const VkMemoryAllocateInfo *alloc_info,
bool force_unmappable,
int fd);
VkResult