From cdc6a0bfed71b22cfbb5ce7f6b778ee3fdedf409 Mon Sep 17 00:00:00 2001 From: Jose Maria Casanova Crespo Date: Thu, 11 Jun 2026 14:30:21 +0200 Subject: [PATCH] v3dv: allow TFU readahead padding above maxMemoryAllocationSize Our get_buffer/image_memory_requirements() pad TRANSFER_SRC resources with V3D_TFU_READAHEAD_SIZE, so allocating the reported requirements of a resource of exactly maxMemoryAllocationSize failed with VK_ERROR_OUT_OF_DEVICE_MEMORY. Accept up to one extra page over the limit: since the allocation size is page-aligned, that covers any sub-page padding. Reviewed-by: Iago Toral Quiroga Part-of: --- src/broadcom/vulkan/v3dv_device.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c index c392dafc668..2a724e5bff1 100644 --- a/src/broadcom/vulkan/v3dv_device.c +++ b/src/broadcom/vulkan/v3dv_device.c @@ -2410,7 +2410,13 @@ v3dv_AllocateMemory(VkDevice _device, assert(pAllocateInfo->sType == VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO); const VkDeviceSize alloc_size = align64(pAllocateInfo->allocationSize, 4096); - if (unlikely(alloc_size > MAX_MEMORY_ALLOCATION_SIZE)) + /* Our memory requirements pad TRANSFER_SRC resources with + * V3D_TFU_READAHEAD_SIZE (and UBO/SSBO with 4 bytes for ldunifa), so + * allocating the reported requirements of a resource of exactly + * maxMemoryAllocationSize must succeed. Accept one extra page over + * the limit, which covers any sub-page padding after alignment. + */ + if (unlikely(alloc_size > MAX_MEMORY_ALLOCATION_SIZE + 4096u)) return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY); uint64_t heap_used = p_atomic_read(&pdevice->heap_used);