From bfc1782ad65668ca1ccab32c77c8bfd8bbf3523b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Tue, 14 Mar 2023 12:37:57 -0700 Subject: [PATCH] anv: Use intel_device_info memory alignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was also necessary to initialize mem_alignment in the tests otherwise vma allocation would fail with stubs. Signed-off-by: José Roberto de Souza Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_allocator.c | 10 ++-------- src/intel/vulkan/tests/block_pool_grow_first.c | 1 + src/intel/vulkan/tests/block_pool_no_free.c | 1 + src/intel/vulkan/tests/state_pool.c | 1 + src/intel/vulkan/tests/state_pool_free_list_only.c | 1 + src/intel/vulkan/tests/state_pool_no_free.c | 1 + src/intel/vulkan/tests/state_pool_padding.c | 1 + src/intel/vulkan/tests/test_common.h | 5 +++++ 8 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c index e1f0931d824..515a2c1db7a 100644 --- a/src/intel/vulkan/anv_allocator.c +++ b/src/intel/vulkan/anv_allocator.c @@ -1405,17 +1405,11 @@ anv_bo_vma_alloc_or_close(struct anv_device *device, { assert(explicit_address == intel_48b_address(explicit_address)); - uint32_t align = 4096; + uint32_t align = device->physical->info.mem_alignment; /* Gen12 CCS surface addresses need to be 64K aligned. */ if (device->info->ver >= 12 && (alloc_flags & ANV_BO_ALLOC_IMPLICIT_CCS)) - align = 64 * 1024; - - /* For XeHP, lmem and smem cannot share a single PDE, which means they - * can't live in the same 2MiB aligned region. - */ - if (device->info->verx10 >= 125) - align = 2 * 1024 * 1024; + align = MAX2(64 * 1024, align); if (alloc_flags & ANV_BO_ALLOC_FIXED_ADDRESS) { bo->has_fixed_address = true; diff --git a/src/intel/vulkan/tests/block_pool_grow_first.c b/src/intel/vulkan/tests/block_pool_grow_first.c index 50eabc8329f..5ad23039212 100644 --- a/src/intel/vulkan/tests/block_pool_grow_first.c +++ b/src/intel/vulkan/tests/block_pool_grow_first.c @@ -36,6 +36,7 @@ int main(void) const uint32_t block_size = 16 * 1024; const uint32_t initial_size = block_size / 2; + test_device_info_init(&physical_device.info); anv_device_set_physical(&device, &physical_device); device.kmd_backend = anv_kmd_backend_get(INTEL_KMD_TYPE_STUB); pthread_mutex_init(&device.mutex, NULL); diff --git a/src/intel/vulkan/tests/block_pool_no_free.c b/src/intel/vulkan/tests/block_pool_no_free.c index 1824b677d42..849e7eb377f 100644 --- a/src/intel/vulkan/tests/block_pool_no_free.c +++ b/src/intel/vulkan/tests/block_pool_no_free.c @@ -104,6 +104,7 @@ static void run_test() struct anv_device device = {}; struct anv_block_pool pool; + test_device_info_init(&physical_device.info); anv_device_set_physical(&device, &physical_device); device.kmd_backend = anv_kmd_backend_get(INTEL_KMD_TYPE_STUB); pthread_mutex_init(&device.mutex, NULL); diff --git a/src/intel/vulkan/tests/state_pool.c b/src/intel/vulkan/tests/state_pool.c index 26d0b7b67fa..8831ec1ccd0 100644 --- a/src/intel/vulkan/tests/state_pool.c +++ b/src/intel/vulkan/tests/state_pool.c @@ -39,6 +39,7 @@ int main(void) struct anv_device device = {}; struct anv_state_pool state_pool; + test_device_info_init(&physical_device.info); anv_device_set_physical(&device, &physical_device); device.kmd_backend = anv_kmd_backend_get(INTEL_KMD_TYPE_STUB); pthread_mutex_init(&device.mutex, NULL); diff --git a/src/intel/vulkan/tests/state_pool_free_list_only.c b/src/intel/vulkan/tests/state_pool_free_list_only.c index 50dc97ffb1d..3168e3afcb4 100644 --- a/src/intel/vulkan/tests/state_pool_free_list_only.c +++ b/src/intel/vulkan/tests/state_pool_free_list_only.c @@ -38,6 +38,7 @@ int main(void) struct anv_device device = {}; struct anv_state_pool state_pool; + test_device_info_init(&physical_device.info); anv_device_set_physical(&device, &physical_device); device.kmd_backend = anv_kmd_backend_get(INTEL_KMD_TYPE_STUB); pthread_mutex_init(&device.mutex, NULL); diff --git a/src/intel/vulkan/tests/state_pool_no_free.c b/src/intel/vulkan/tests/state_pool_no_free.c index bd3e20d70e5..9182ba35908 100644 --- a/src/intel/vulkan/tests/state_pool_no_free.c +++ b/src/intel/vulkan/tests/state_pool_no_free.c @@ -59,6 +59,7 @@ static void run_test() struct anv_device device = {}; struct anv_state_pool state_pool; + test_device_info_init(&physical_device.info); anv_device_set_physical(&device, &physical_device); device.kmd_backend = anv_kmd_backend_get(INTEL_KMD_TYPE_STUB); pthread_mutex_init(&device.mutex, NULL); diff --git a/src/intel/vulkan/tests/state_pool_padding.c b/src/intel/vulkan/tests/state_pool_padding.c index 8d613a2859f..845767a358e 100644 --- a/src/intel/vulkan/tests/state_pool_padding.c +++ b/src/intel/vulkan/tests/state_pool_padding.c @@ -30,6 +30,7 @@ int main(void) struct anv_device device = {}; struct anv_state_pool state_pool; + test_device_info_init(&physical_device.info); anv_device_set_physical(&device, &physical_device); device.kmd_backend = anv_kmd_backend_get(INTEL_KMD_TYPE_STUB); pthread_mutex_init(&device.mutex, NULL); diff --git a/src/intel/vulkan/tests/test_common.h b/src/intel/vulkan/tests/test_common.h index 3f883e3bdcd..ae84935f3bb 100644 --- a/src/intel/vulkan/tests/test_common.h +++ b/src/intel/vulkan/tests/test_common.h @@ -32,3 +32,8 @@ abort(); \ } \ } while (false) + +static inline void test_device_info_init(struct intel_device_info *info) +{ + info->mem_alignment = 4096; +}