From 282e2c949663505115bc2b862b70e0ad43a59222 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Tue, 27 Apr 2021 00:03:21 +0000 Subject: venus: set bo->size to 0 for classic resource bo->size is not used for classic resource since mapping is not allowed. Signed-off-by: Yiwei Zhang Reviewed-by: Chia-I Wu Part-of: --- src/virtio/vulkan/vn_renderer_virtgpu.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/virtio/vulkan/vn_renderer_virtgpu.c b/src/virtio/vulkan/vn_renderer_virtgpu.c index 8d9069c31f9..245b5e94941 100644 --- a/src/virtio/vulkan/vn_renderer_virtgpu.c +++ b/src/virtio/vulkan/vn_renderer_virtgpu.c @@ -1118,17 +1118,25 @@ virtgpu_bo_init_dmabuf(struct vn_renderer_bo *_bo, if (virtgpu_ioctl_resource_info(gpu, gem_handle, &info)) goto fail; - /* must be VIRTGPU_BLOB_MEM_HOST3D or classic */ - if (info.blob_mem && info.blob_mem != VIRTGPU_BLOB_MEM_HOST3D) - goto fail; + if (info.blob_mem) { + /* must be VIRTGPU_BLOB_MEM_HOST3D */ + if (info.blob_mem != VIRTGPU_BLOB_MEM_HOST3D) + goto fail; - if (size && info.size < size) - goto fail; + if (size && info.size < size) + goto fail; + + bo->blob_flags = virtgpu_bo_blob_flags(flags, external_handles); + bo->size = size ? size : info.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 + */ + bo->blob_flags = 0; + bo->size = 0; + } - /* set blob_flags to 0 for classic resources to fail virtgpu_bo_map */ - bo->blob_flags = - info.blob_mem ? virtgpu_bo_blob_flags(flags, external_handles) : 0; - bo->size = size ? size : info.size; bo->gem_handle = gem_handle; bo->base.res_id = info.res_handle; -- cgit v1.2.3