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 <dmitry.baryshkov@linaro.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24861>
This commit is contained in:
Dmitry Baryshkov 2023-08-24 07:48:54 +03:00 committed by Marge Bot
parent cda1961835
commit 2fdcc00b01

View file

@ -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.