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 <robdclark@chromium.org>
Fixes: 63904240f2 ("tu: Re-enable bufferDeviceAddressCaptureReplay")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30431>
(cherry picked from commit 7fe3529715)
This commit is contained in:
Rob Clark 2024-07-30 13:13:33 -07:00 committed by Eric Engestrom
parent f2a0f842e2
commit 54a1b52e37
4 changed files with 12 additions and 4 deletions

View file

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

View file

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

View file

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

View file

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