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>
This commit is contained in:
Rob Clark 2024-07-30 13:13:33 -07:00 committed by Marge Bot
parent 745ad42bb0
commit 7fe3529715
3 changed files with 7 additions and 4 deletions

View file

@ -48,6 +48,8 @@
#include <vndk/hardware_buffer.h>
#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))

View file

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

View file

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