From 2fa4fe2c8580e78ce0a162003da580b00727f840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Mon, 3 Jul 2023 09:38:10 -0700 Subject: [PATCH] anv: Fix some mismatches of canonical and regular addresses around anv_bo_vma_alloc_or_close() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit anv_vma_alloc() returns a canonical address, but explicit_address is a regular address. This mismatch can potentially cause issues. So here making bo->offset as always canonical address by converting it in the explicit case and fixing the only caller that was caling anv_bo_vma_alloc_or_close() with a canonical address. Signed-off-by: José Roberto de Souza Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_allocator.c | 4 ++-- src/intel/vulkan/anv_private.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c index 8fa7ad5b80e..2c46200dfdf 100644 --- a/src/intel/vulkan/anv_allocator.c +++ b/src/intel/vulkan/anv_allocator.c @@ -436,7 +436,7 @@ anv_block_pool_expand_range(struct anv_block_pool *pool, uint32_t size) pool->name, new_bo_size, pool->bo_alloc_flags, - pool->start_address + pool->size, + intel_48b_address(pool->start_address + pool->size), &new_bo); if (result != VK_SUCCESS) return result; @@ -1422,7 +1422,7 @@ anv_bo_vma_alloc_or_close(struct anv_device *device, if (alloc_flags & ANV_BO_ALLOC_FIXED_ADDRESS) { bo->has_fixed_address = true; - bo->offset = explicit_address; + bo->offset = intel_canonical_address(explicit_address); } else { bo->offset = anv_vma_alloc(device, bo->size + bo->_ccs_size, align, alloc_flags, explicit_address, diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 893c05d3d9c..7ecea5534e3 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -419,7 +419,7 @@ struct anv_bo { /* Last known offset. This value is provided by the kernel when we * execbuf and is used as the presumed offset for the next bunch of - * relocations. + * relocations, in canonical address format. */ uint64_t offset; @@ -596,7 +596,7 @@ struct anv_block_pool { uint64_t size; - /* The address where the start of the pool is pinned. The various bos that + /* The canonical address where the start of the pool is pinned. The various bos that * are created as the pool grows will have addresses in the range * [start_address, start_address + BLOCK_POOL_MEMFD_SIZE). */