venus: fix dmabuf import mmap_size check
Do not set mmap_size to info.size. We do not track the size of the BO
anymore.
This fixes
dEQP-VK.api.external.memory.dma_buf.suballocated.device_only.fd_properties
where the test allocates a 1KB VkDeviceMemory, export and call
vkGetMemoryFdPropertiesKHR. It can happen that bo->mmap_size is less
than the aligned info.size.
FWIW, the test fails because it violates a VU:
VUID-vkGetMemoryFdPropertiesKHR-fd-00673
fd must be an external memory handle created outside of the Vulkan API
Fixes: 88f481dd74
("venus: make sure gem_handle and vn_renderer_bo are 1:1")
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10592>
This commit is contained in:
parent
a9a75edc24
commit
40fbfd8b5b
|
@ -1164,29 +1164,29 @@ virtgpu_bo_create_from_dmabuf(struct vn_renderer *renderer,
|
|||
goto fail;
|
||||
|
||||
uint32_t blob_flags;
|
||||
size_t mmap_size;
|
||||
if (info.blob_mem) {
|
||||
/* must be VIRTGPU_BLOB_MEM_HOST3D */
|
||||
if (info.blob_mem != VIRTGPU_BLOB_MEM_HOST3D)
|
||||
goto fail;
|
||||
|
||||
if (!size)
|
||||
size = info.size;
|
||||
else if (info.size < size)
|
||||
if (info.size < size)
|
||||
goto fail;
|
||||
|
||||
blob_flags = virtgpu_bo_blob_flags(flags, external_handles);
|
||||
mmap_size = size;
|
||||
} else {
|
||||
/* must be classic resource here
|
||||
* set blob_flags to 0 to fail virtgpu_bo_map
|
||||
* set size to 0 since mapping is not allowed
|
||||
* set mmap_size to 0 since mapping is not allowed
|
||||
*/
|
||||
blob_flags = 0;
|
||||
size = 0;
|
||||
mmap_size = 0;
|
||||
}
|
||||
|
||||
struct virtgpu_bo *bo = util_sparse_array_get(&gpu->bo_array, gem_handle);
|
||||
if (bo->gem_handle == gem_handle) {
|
||||
if (bo->base.mmap_size < size)
|
||||
if (bo->base.mmap_size < mmap_size)
|
||||
goto fail;
|
||||
if (blob_flags & ~bo->blob_flags)
|
||||
goto fail;
|
||||
|
@ -1200,7 +1200,7 @@ virtgpu_bo_create_from_dmabuf(struct vn_renderer *renderer,
|
|||
.base = {
|
||||
.refcount = 1,
|
||||
.res_id = info.res_handle,
|
||||
.mmap_size = size,
|
||||
.mmap_size = mmap_size,
|
||||
},
|
||||
.gem_handle = gem_handle,
|
||||
.blob_flags = blob_flags,
|
||||
|
|
Loading…
Reference in New Issue