From 11325f922dac299180605eeb87e29f1eb28d017a Mon Sep 17 00:00:00 2001 From: Simon Richter Date: Sat, 16 Aug 2025 22:33:43 +0900 Subject: [PATCH] anv, hasvk: Fix reported CPU page size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Memory mappings must be aligned to the smallest page size in use, which may be 16k or 64k on some systems. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13720 Signed-off-by: Simon Richter Reviewed-by: José Roberto de Souza Part-of: --- src/intel/vulkan/anv_physical_device.c | 11 ++++++++--- src/intel/vulkan_hasvk/anv_device.c | 8 ++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/intel/vulkan/anv_physical_device.c b/src/intel/vulkan/anv_physical_device.c index 9c25067e95c..7416d06da5e 100644 --- a/src/intel/vulkan/anv_physical_device.c +++ b/src/intel/vulkan/anv_physical_device.c @@ -17,6 +17,7 @@ #include "git_sha1.h" #include "util/disk_cache.h" +#include "util/os_misc.h" #include "util/mesa-sha1.h" #include "util/os_misc.h" @@ -1281,6 +1282,10 @@ get_properties(const struct anv_physical_device *pdevice, const struct intel_device_info *devinfo = &pdevice->info; + uint64_t page_size; + if (!os_get_page_size(&page_size)) + page_size = 4096; /* fallback */ + const VkDeviceSize max_heap_size = anx_get_physical_device_max_heap_size(pdevice); const uint32_t max_workgroup_size = @@ -1391,7 +1396,7 @@ get_properties(const struct anv_physical_device *pdevice, .maxViewportDimensions = { (1 << 14), (1 << 14) }, .viewportBoundsRange = { INT16_MIN, INT16_MAX }, .viewportSubPixelBits = 13, /* We take a float? */ - .minMemoryMapAlignment = 4096, /* A page */ + .minMemoryMapAlignment = page_size, /* The dataport requires texel alignment so we need to assume a worst * case of R32G32B32A32 which is 16 bytes. */ @@ -1726,7 +1731,7 @@ get_properties(const struct anv_physical_device *pdevice, /* VK_EXT_external_memory_host */ { - props->minImportedHostPointerAlignment = 4096; + props->minImportedHostPointerAlignment = page_size; } /* VK_EXT_graphics_pipeline_library */ @@ -1829,7 +1834,7 @@ get_properties(const struct anv_physical_device *pdevice, /* VK_EXT_map_memory_placed */ { - props->minPlacedMemoryMapAlignment = 4096; + props->minPlacedMemoryMapAlignment = page_size; } /* VK_EXT_mesh_shader */ diff --git a/src/intel/vulkan_hasvk/anv_device.c b/src/intel/vulkan_hasvk/anv_device.c index ddfb6c941fa..9da3c1fe7be 100644 --- a/src/intel/vulkan_hasvk/anv_device.c +++ b/src/intel/vulkan_hasvk/anv_device.c @@ -948,6 +948,10 @@ get_properties(const struct anv_physical_device *pdevice, { const struct intel_device_info *devinfo = &pdevice->info; + uint64_t page_size; + if (!os_get_page_size(&page_size)) + page_size = 4096; /* fallback */ + const uint32_t max_ssbos = pdevice->has_a64_buffer_access ? UINT16_MAX : 64; const uint32_t max_textures = 128; const uint32_t max_samplers = @@ -1063,7 +1067,7 @@ get_properties(const struct anv_physical_device *pdevice, .maxViewportDimensions = { (1 << 14), (1 << 14) }, .viewportBoundsRange = { INT16_MIN, INT16_MAX }, .viewportSubPixelBits = 13, /* We take a float? */ - .minMemoryMapAlignment = 4096, /* A page */ + .minMemoryMapAlignment = page_size, /* The dataport requires texel alignment so we need to assume a worst * case of R32G32B32A32 which is 16 bytes. */ @@ -1155,7 +1159,7 @@ get_properties(const struct anv_physical_device *pdevice, /* VK_EXT_external_memory_host */ { /* Userptr needs page aligned memory. */ - props->minImportedHostPointerAlignment = 4096; + props->minImportedHostPointerAlignment = page_size; } /* VK_EXT_line_rasterization */