From 6f9a5f48113b043ed597e3d815ca8d9040429e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Wed, 21 Feb 2024 06:09:47 -0800 Subject: [PATCH] iris/xe: Add VMs to error dump MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To ask Xe KMD to dump BO/VMA content to error state it is necessary to set DRM_XE_VM_BIND_FLAG_DUMPABLE during VM bind, so places that were setting 'bo.real.capture = true' after the VM bind were useless for Xe KMD. To fix that BO_ALLOC_CAPTURE was added, alloc_fresh_bo() will set 'bo.real.capture = true' automaticacly for new bos before vm bind. alloc_bo_from_cache() also required to check if capture states matches between asked bo and bo in cache. Only slabs might be left out of error dump if DEBUG_CAPTURE_ALL is not set but that was already happening for i915. Reviewed-by: Lionel Landwerlin Signed-off-by: José Roberto de Souza Part-of: --- src/gallium/drivers/iris/iris_batch.c | 4 ++-- src/gallium/drivers/iris/iris_bufmgr.c | 19 +++++++++++-------- src/gallium/drivers/iris/iris_bufmgr.h | 6 +++++- src/gallium/drivers/iris/iris_screen.c | 3 +-- .../drivers/iris/xe/iris_kmd_backend.c | 5 +++++ 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c index b24b028f2fa..5831d1f358f 100644 --- a/src/gallium/drivers/iris/iris_batch.c +++ b/src/gallium/drivers/iris/iris_batch.c @@ -426,8 +426,8 @@ create_batch(struct iris_batch *batch) /* TODO: We probably could suballocate batches... */ batch->bo = iris_bo_alloc(bufmgr, "command buffer", BATCH_SZ + BATCH_RESERVED, 8, - IRIS_MEMZONE_OTHER, BO_ALLOC_NO_SUBALLOC); - iris_get_backing_bo(batch->bo)->real.capture = true; + IRIS_MEMZONE_OTHER, + BO_ALLOC_NO_SUBALLOC | BO_ALLOC_CAPTURE); batch->map = iris_bo_map(NULL, batch->bo, MAP_READ | MAP_WRITE); batch->map_next = batch->map; diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index 8359195597d..d0895078420 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -1008,6 +1008,9 @@ alloc_bo_from_cache(struct iris_bufmgr *bufmgr, if (match_zone && memzone != iris_memzone_for_address(cur->address)) continue; + if (cur->real.capture != !!(flags & BO_ALLOC_CAPTURE)) + continue; + /* If the last BO in the cache is busy, there are no idle BOs. Bail, * either falling back to a non-matching memzone, or if that fails, * allocating a fresh buffer. @@ -1126,6 +1129,7 @@ alloc_fresh_bo(struct iris_bufmgr *bufmgr, uint64_t bo_size, unsigned flags) bo->size = bo_size; bo->idle = true; bo->zeroed = true; + bo->real.capture = (flags & BO_ALLOC_CAPTURE) != 0; return bo; } @@ -1174,6 +1178,12 @@ iris_bo_alloc(struct iris_bufmgr *bufmgr, if (memzone != IRIS_MEMZONE_OTHER || (flags & BO_ALLOC_COHERENT)) flags |= BO_ALLOC_NO_SUBALLOC; + /* By default, capture all driver-internal buffers like shader kernels, + * surface states, dynamic states, border colors, and so on. + */ + if (memzone < IRIS_MEMZONE_OTHER || INTEL_DEBUG(DEBUG_CAPTURE_ALL)) + flags |= BO_ALLOC_CAPTURE; + bo = alloc_bo_from_slabs(bufmgr, name, size, alignment, flags); if (bo) @@ -1227,12 +1237,6 @@ iris_bo_alloc(struct iris_bufmgr *bufmgr, bo->index = -1; bo->real.prime_fd = -1; - /* By default, capture all driver-internal buffers like shader kernels, - * surface states, dynamic states, border colors, and so on. - */ - if (memzone < IRIS_MEMZONE_OTHER || INTEL_DEBUG(DEBUG_CAPTURE_ALL)) - bo->real.capture = true; - assert(bo->real.map == NULL || bo->real.mmap_mode == mmap_mode); bo->real.mmap_mode = mmap_mode; @@ -2162,7 +2166,7 @@ intel_aux_map_buffer_alloc(void *driver_ctx, uint32_t size) unsigned int page_size = getpagesize(); size = MAX2(ALIGN(size, page_size), page_size); - struct iris_bo *bo = alloc_fresh_bo(bufmgr, size, 0); + struct iris_bo *bo = alloc_fresh_bo(bufmgr, size, BO_ALLOC_CAPTURE); if (!bo) { free(buf); return NULL; @@ -2182,7 +2186,6 @@ intel_aux_map_buffer_alloc(void *driver_ctx, uint32_t size) bo->name = "aux-map"; p_atomic_set(&bo->refcount, 1); bo->index = -1; - bo->real.capture = true; bo->real.mmap_mode = heap_to_mmap_mode(bufmgr, bo->real.heap); bo->real.prime_fd = -1; diff --git a/src/gallium/drivers/iris/iris_bufmgr.h b/src/gallium/drivers/iris/iris_bufmgr.h index d79f3fbdb88..89fe5a130b8 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.h +++ b/src/gallium/drivers/iris/iris_bufmgr.h @@ -326,7 +326,10 @@ struct iris_bo { /** Boolean of whether this buffer is protected (HW encryption) */ bool protected; - /** Boolean of whether this buffer needs to be captured in error dump */ + /** Boolean of whether this buffer needs to be captured in error dump. + * Xe KMD requires this to be set before vm bind while i915 needs + * this set before batch_submit(). + */ bool capture; } real; struct { @@ -345,6 +348,7 @@ struct iris_bo { #define BO_ALLOC_LMEM (1<<5) #define BO_ALLOC_PROTECTED (1<<6) #define BO_ALLOC_SHARED (1<<7) +#define BO_ALLOC_CAPTURE (1<<8) /** * Allocate a buffer object. diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c index 25163d460a6..e8ac0308002 100644 --- a/src/gallium/drivers/iris/iris_screen.c +++ b/src/gallium/drivers/iris/iris_screen.c @@ -743,7 +743,6 @@ iris_init_identifier_bo(struct iris_screen *screen) assert(iris_bo_is_real(screen->workaround_bo)); - screen->workaround_bo->real.capture = true; screen->workaround_address = (struct iris_address) { .bo = screen->workaround_bo, .offset = ALIGN( @@ -814,7 +813,7 @@ iris_screen_create(int fd, const struct pipe_screen_config *config) screen->workaround_bo = iris_bo_alloc(screen->bufmgr, "workaround", 4096, 4096, - IRIS_MEMZONE_OTHER, BO_ALLOC_NO_SUBALLOC); + IRIS_MEMZONE_OTHER, BO_ALLOC_NO_SUBALLOC | BO_ALLOC_CAPTURE); if (!screen->workaround_bo) return NULL; diff --git a/src/gallium/drivers/iris/xe/iris_kmd_backend.c b/src/gallium/drivers/iris/xe/iris_kmd_backend.c index 7ab93e256ab..4a60b5355fb 100644 --- a/src/gallium/drivers/iris/xe/iris_kmd_backend.c +++ b/src/gallium/drivers/iris/xe/iris_kmd_backend.c @@ -114,6 +114,7 @@ xe_gem_vm_bind_op(struct iris_bo *bo, uint32_t op) .flags = DRM_XE_SYNC_FLAG_SIGNAL, }; uint64_t range, obj_offset = 0; + uint32_t flags = 0; int ret, fd; fd = iris_bufmgr_get_fd(bufmgr); @@ -134,6 +135,9 @@ xe_gem_vm_bind_op(struct iris_bo *bo, uint32_t op) if (op != DRM_XE_VM_BIND_OP_UNMAP) pat_index = iris_heap_to_pat_entry(devinfo, bo->real.heap)->index; + if (bo->real.capture) + flags |= DRM_XE_VM_BIND_FLAG_DUMPABLE; + struct drm_xe_vm_bind args = { .vm_id = iris_bufmgr_get_global_vm_id(bufmgr), .num_syncs = 1, @@ -145,6 +149,7 @@ xe_gem_vm_bind_op(struct iris_bo *bo, uint32_t op) .bind.addr = intel_48b_address(bo->address), .bind.op = op, .bind.pat_index = pat_index, + .bind.flags = flags, }; xe_sync.timeline_value = intel_bind_timeline_bind_begin(bind_timeline);