From a1fda29bd1d8577caf0f7bb6e058b53241c7ff0f Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Tue, 27 Jun 2023 16:54:04 +0300 Subject: [PATCH] anv: look into batch bo reloc list looking for BOs to decode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On DG2 I ran into a case where the surface state was not being decoded with INTEL_DEBUG=bat. This is because the surface states are not part of a state pool there anymore. Instead BO are allocate manually and placed in vma heap. Signed-off-by: Lionel Landwerlin Fixes: 96c33fb027 ("anv: enable direct descriptors on platforms with extended bindless offset") Reviewed-by: José Roberto de Souza Part-of: --- src/intel/vulkan/anv_device.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index c33bc635f32..9a4969f6d9c 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -2881,19 +2881,38 @@ decode_get_bo(void *v_batch, bool ppgtt, uint64_t address) if (!device->cmd_buffer_being_decoded) return (struct intel_batch_decode_bo) { }; - struct anv_batch_bo **bo; - - u_vector_foreach(bo, &device->cmd_buffer_being_decoded->seen_bbos) { + struct anv_batch_bo **bbo; + u_vector_foreach(bbo, &device->cmd_buffer_being_decoded->seen_bbos) { /* The decoder zeroes out the top 16 bits, so we need to as well */ - uint64_t bo_address = (*bo)->bo->offset & (~0ull >> 16); + uint64_t bo_address = (*bbo)->bo->offset & (~0ull >> 16); - if (address >= bo_address && address < bo_address + (*bo)->bo->size) { + if (address >= bo_address && address < bo_address + (*bbo)->bo->size) { return (struct intel_batch_decode_bo) { .addr = bo_address, - .size = (*bo)->bo->size, - .map = (*bo)->bo->map, + .size = (*bbo)->bo->size, + .map = (*bbo)->bo->map, }; } + + uint32_t dep_words = (*bbo)->relocs.dep_words; + BITSET_WORD *deps = (*bbo)->relocs.deps; + for (uint32_t w = 0; w < dep_words; w++) { + BITSET_WORD mask = deps[w]; + while (mask) { + int i = u_bit_scan(&mask); + uint32_t gem_handle = w * BITSET_WORDBITS + i; + struct anv_bo *bo = anv_device_lookup_bo(device, gem_handle); + assert(bo->refcount > 0); + bo_address = bo->offset & (~0ull >> 16); + if (address >= bo_address && address < bo_address + bo->size) { + return (struct intel_batch_decode_bo) { + .addr = bo_address, + .size = bo->size, + .map = bo->map, + }; + } + } + } } return (struct intel_batch_decode_bo) { };