From aa392e1ec21bf4e8605d85a46d1d804ad4184fc0 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Thu, 14 Nov 2024 21:44:29 -0500 Subject: [PATCH] tu: Align BO size to page size The kernel was rounding the size up for us, but it doesn't like a non-aligned map size, so just sanitize the size here. tu_cs was relying on the size not being rounded to keep the maximum size 2^20-1 or less, so fix that by using the initial unrounded size. Part-of: --- src/freedreno/vulkan/tu_cs.cc | 2 +- src/freedreno/vulkan/tu_knl.cc | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/freedreno/vulkan/tu_cs.cc b/src/freedreno/vulkan/tu_cs.cc index 7e700e2c6de..aa0861c9859 100644 --- a/src/freedreno/vulkan/tu_cs.cc +++ b/src/freedreno/vulkan/tu_cs.cc @@ -176,7 +176,7 @@ tu_cs_add_bo(struct tu_cs *cs, uint32_t size) bos->bos[bos->bo_count++] = new_bo; cs->start = cs->cur = cs->reserved_end = (uint32_t *) new_bo->map; - cs->end = cs->start + new_bo->size / sizeof(uint32_t); + cs->end = cs->start + size; return VK_SUCCESS; } diff --git a/src/freedreno/vulkan/tu_knl.cc b/src/freedreno/vulkan/tu_knl.cc index 96b90aa0892..1b16dec1144 100644 --- a/src/freedreno/vulkan/tu_knl.cc +++ b/src/freedreno/vulkan/tu_knl.cc @@ -40,6 +40,8 @@ tu_bo_init_new_explicit_iova(struct tu_device *dev, MESA_TRACE_FUNC(); struct tu_instance *instance = dev->physical_device->instance; + size = align64(size, os_page_size); + VkResult result = dev->instance->knl->bo_init(dev, base, out_bo, size, client_iova, mem_property, flags, name); @@ -65,6 +67,7 @@ tu_bo_init_dmabuf(struct tu_device *dev, uint64_t size, int fd) { + size = align64(size, os_page_size); VkResult result = dev->instance->knl->bo_init_dmabuf(dev, bo, size, fd); if (result != VK_SUCCESS) return result;