From 7fe3529715c3bbc71560e84ed8e6a54c8d13f9b0 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Tue, 30 Jul 2024 13:13:33 -0700 Subject: [PATCH] tu: Fix issues with 16k (or larger) page sizes The iova allocations need to be CPU page aligned. (The GPU itself always supports 4k mappings regardless of the smallest CPU page size, but GEM buffer allocations must be an integer number of CPU pages.) Signed-off-by: Rob Clark Fixes: 63904240f21b ("tu: Re-enable bufferDeviceAddressCaptureReplay") Part-of: --- src/freedreno/vulkan/tu_device.cc | 5 +++-- src/freedreno/vulkan/tu_device.h | 2 ++ src/freedreno/vulkan/tu_knl_drm.cc | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/freedreno/vulkan/tu_device.cc b/src/freedreno/vulkan/tu_device.cc index b6877295d46..65125cda36a 100644 --- a/src/freedreno/vulkan/tu_device.cc +++ b/src/freedreno/vulkan/tu_device.cc @@ -48,6 +48,8 @@ #include #endif +uint64_t os_page_size = 4096; + static int tu_device_get_cache_uuid(struct tu_physical_device *device, void *uuid) { @@ -1063,7 +1065,6 @@ tu_get_properties(struct tu_physical_device *pdevice, sizeof(props->shaderModuleIdentifierAlgorithmUUID)); /* VK_EXT_map_memory_placed */ - uint64_t os_page_size = 4096; os_get_page_size(&os_page_size); props->minPlacedMemoryMapAlignment = os_page_size, @@ -2265,7 +2266,7 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice, if (physical_device->has_set_iova) { mtx_init(&device->vma_mutex, mtx_plain); util_vma_heap_init(&device->vma, physical_device->va_start, - ROUND_DOWN_TO(physical_device->va_size, 4096)); + ROUND_DOWN_TO(physical_device->va_size, os_page_size)); } if (TU_DEBUG(BOS)) diff --git a/src/freedreno/vulkan/tu_device.h b/src/freedreno/vulkan/tu_device.h index e6096063714..fed89ab37b0 100644 --- a/src/freedreno/vulkan/tu_device.h +++ b/src/freedreno/vulkan/tu_device.h @@ -70,6 +70,8 @@ enum tu_kgsl_dma_type TU_KGSL_DMA_TYPE_DMAHEAP, }; +extern uint64_t os_page_size; + struct tu_physical_device { struct vk_physical_device vk; diff --git a/src/freedreno/vulkan/tu_knl_drm.cc b/src/freedreno/vulkan/tu_knl_drm.cc index c3eabed2ffc..9dfb0dab3e8 100644 --- a/src/freedreno/vulkan/tu_knl_drm.cc +++ b/src/freedreno/vulkan/tu_knl_drm.cc @@ -34,11 +34,11 @@ tu_allocate_userspace_iova(struct tu_device *dev, * them from the other end of the address space. */ dev->vma.alloc_high = true; - *iova = util_vma_heap_alloc(&dev->vma, size, 0x1000); + *iova = util_vma_heap_alloc(&dev->vma, size, os_page_size); } } else { dev->vma.alloc_high = false; - *iova = util_vma_heap_alloc(&dev->vma, size, 0x1000); + *iova = util_vma_heap_alloc(&dev->vma, size, os_page_size); } if (!*iova)