From 2fdcc00b0154cb094a5fd2c9253904fc9073d96e Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Thu, 24 Aug 2023 07:48:54 +0300 Subject: [PATCH] tu: Pass real size of prime buffers to allocator The msm driver reserves the actual DMABUF size in the memory map, while TU can request smaller memory chunk to be allocated. This potentially can lead to a situation when next allocation IOVA will be in the middle of the address space which is reserved for the DMABUF. Pass the `real_size' to TU allocator instead, so that kernel and userspace have the same picture of memory allocations. Cc: mesa-stable Signed-off-by: Dmitry Baryshkov Part-of: --- src/freedreno/vulkan/tu_knl_drm_msm.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/freedreno/vulkan/tu_knl_drm_msm.cc b/src/freedreno/vulkan/tu_knl_drm_msm.cc index 2d7f838..4961110 100644 --- a/src/freedreno/vulkan/tu_knl_drm_msm.cc +++ b/src/freedreno/vulkan/tu_knl_drm_msm.cc @@ -580,6 +580,9 @@ msm_bo_init_dmabuf(struct tu_device *dev, if (real_size < 0 || (uint64_t) real_size < size) return vk_error(dev, VK_ERROR_INVALID_EXTERNAL_HANDLE); + /* iova allocation needs to consider the object's *real* size: */ + size = real_size; + /* Importing the same dmabuf several times would yield the same * gem_handle. Thus there could be a race when destroying * BO and importing the same dmabuf from different threads. -- 2.7.4