venus: renderer to check map size only when mappable
authorYiwei Zhang <zzyiwei@chromium.org>
Wed, 1 Sep 2021 21:46:38 +0000 (21:46 +0000)
committerMarge Bot <eric+marge@anholt.net>
Wed, 1 Sep 2021 22:38:48 +0000 (22:38 +0000)
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>

src/virtio/vulkan/vn_renderer_virtgpu.c

index 5a29fb6..050a35b 100644 (file)
@@ -1173,15 +1173,20 @@ virtgpu_bo_create_from_dma_buf(struct vn_renderer *renderer,
       if (info.blob_mem != VIRTGPU_BLOB_MEM_HOST3D)
          goto fail;
 
-      if (info.size < size)
-         goto fail;
-
       /* blob_flags is not passed to the kernel and is only for internal use
        * on imports.  Set it to what works best for us.
        */
       blob_flags = virtgpu_bo_blob_flags(flags, 0);
       blob_flags |= VIRTGPU_BLOB_FLAG_USE_SHAREABLE;
-      mmap_size = size;
+
+      /* mmap_size is only used when mappable */
+      mmap_size = 0;
+      if (blob_flags & VIRTGPU_BLOB_FLAG_USE_MAPPABLE) {
+         if (info.size < size)
+            goto fail;
+
+         mmap_size = size;
+      }
    } else {
       /* must be classic resource here
        * set blob_flags to 0 to fail virtgpu_bo_map