Mesa (master): venus: set bo->size to 0 for classic resource

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Apr 27 00:25:54 UTC 2021


Module: Mesa
Branch: master
Commit: 282e2c949663505115bc2b862b70e0ad43a59222
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=282e2c949663505115bc2b862b70e0ad43a59222

Author: Yiwei Zhang <zzyiwei at chromium.org>
Date:   Tue Apr 27 00:03:21 2021 +0000

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 <zzyiwei at chromium.org>
Reviewed-by: Chia-I Wu <olvaffe at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10259>

---

 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;
 



More information about the mesa-commit mailing list