| From cbdec34db3129552a6507d87d4bf0b4866774148 Mon Sep 17 00:00:00 2001 |
| From: Yiwei Zhang <zzyiwei@chromium.org> |
| Date: Wed, 1 Sep 2021 21:46:38 +0000 |
| Subject: [PATCH 1/2] venus: renderer to check map size only when mappable |
| |
| 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 | 13 +++++++++---- |
| 1 file changed, 9 insertions(+), 4 deletions(-) |
| |
| diff --git a/src/virtio/vulkan/vn_renderer_virtgpu.c b/src/virtio/vulkan/vn_renderer_virtgpu.c |
| index 5a29fb6c129..050a35bfec3 100644 |
| --- a/src/virtio/vulkan/vn_renderer_virtgpu.c |
| +++ b/src/virtio/vulkan/vn_renderer_virtgpu.c |
| @@ -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 |
| -- |
| 2.33.0.153.gba50c8fa24-goog |
| |