From 54a1b52e3737aeb0201a72bbb80d0658be4addd1 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: (cherry picked from commit 7fe3529715c3bbc71560e84ed8e6a54c8d13f9b0) --- .pick_status.json | 2 +- src/freedreno/vulkan/tu_device.cc | 8 +++++++- src/freedreno/vulkan/tu_device.h | 2 ++ src/freedreno/vulkan/tu_knl_drm.cc | 4 ++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index ef5765c5369..e294fe5c1ea 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -7164,7 +7164,7 @@ "description": "tu: Fix issues with 16k (or larger) page sizes", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "63904240f21b192a5fb1e79046a2c351fbd98ace", "notes": null diff --git a/src/freedreno/vulkan/tu_device.cc b/src/freedreno/vulkan/tu_device.cc index 84c6c7dc967..c2db2c7ad8f 100644 --- a/src/freedreno/vulkan/tu_device.cc +++ b/src/freedreno/vulkan/tu_device.cc @@ -42,6 +42,8 @@ #include "tu_tracepoints.h" #include "tu_wsi.h" +uint64_t os_page_size = 4096; + static int tu_device_get_cache_uuid(struct tu_physical_device *device, void *uuid) { @@ -1005,6 +1007,10 @@ tu_get_properties(struct tu_physical_device *pdevice, vk_shaderModuleIdentifierAlgorithmUUID, sizeof(props->shaderModuleIdentifierAlgorithmUUID)); + /* [Eric] backport note: this call is present on main but not in 24.1, and + * is required in this commit to initialise os_page_size correctly */ + os_get_page_size(&os_page_size); + /* VK_EXT_multi_draw */ props->maxMultiDrawCount = 2048; @@ -2212,7 +2218,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 22d8d6fdd19..10de69500b9 100644 --- a/src/freedreno/vulkan/tu_device.h +++ b/src/freedreno/vulkan/tu_device.h @@ -63,6 +63,8 @@ struct tu_memory_heap { alignas(8) VkDeviceSize used; }; +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 c0970d26a0e..7546a360387 100644 --- a/src/freedreno/vulkan/tu_knl_drm.cc +++ b/src/freedreno/vulkan/tu_knl_drm.cc @@ -130,11 +130,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)