From 1964899c28ffcb2f1db180195ee1677280ecc231 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Thu, 6 Oct 2022 00:34:52 +0300 Subject: [PATCH] intel: add INTEL_DEBUG=capture-all to capture everything upon hang Signed-off-by: Lionel Landwerlin Reviewd-by: Jordan Justen Part-of: --- docs/envvars.rst | 3 +++ src/gallium/drivers/iris/iris_bufmgr.c | 9 ++++++++- src/intel/dev/intel_debug.c | 1 + src/intel/dev/intel_debug.h | 1 + src/intel/vulkan/anv_allocator.c | 4 +++- src/intel/vulkan/anv_batch_chain.c | 5 +++-- 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/docs/envvars.rst b/docs/envvars.rst index a8f0f12ccdf..ad84505d5c9 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -280,6 +280,9 @@ Intel driver environment variables emit messages about buffer objects ``bt`` emit messages binding tables + ``capture-all`` + flag all buffers to be captured by the kernel driver when + generating an error stage after a gpu hang ``clip`` emit messages about the clip unit (for old gens, includes the CLIP program) diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index 7a8e7f903a5..9c9aefa716a 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -1133,7 +1133,7 @@ iris_bo_alloc(struct iris_bufmgr *bufmgr, /* By default, capture all driver-internal buffers like shader kernels, * surface states, dynamic states, border colors, and so on. */ - if (memzone < IRIS_MEMZONE_OTHER) + if (memzone < IRIS_MEMZONE_OTHER || INTEL_DEBUG(DEBUG_CAPTURE_ALL)) bo->real.kflags |= EXEC_OBJECT_CAPTURE; assert(bo->real.map == NULL || bo->real.mmap_mode == mmap_mode); @@ -1205,6 +1205,9 @@ iris_bo_create_userptr(struct iris_bufmgr *bufmgr, const char *name, bo->bufmgr = bufmgr; bo->real.kflags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS | EXEC_OBJECT_PINNED; + if (INTEL_DEBUG(DEBUG_CAPTURE_ALL)) + bo->real.kflags |= EXEC_OBJECT_CAPTURE; + simple_mtx_lock(&bufmgr->lock); bo->address = vma_alloc(bufmgr, memzone, size, 1); simple_mtx_unlock(&bufmgr->lock); @@ -1285,6 +1288,8 @@ iris_bo_gem_create_from_name(struct iris_bufmgr *bufmgr, bo->real.imported = true; bo->real.mmap_mode = IRIS_MMAP_NONE; bo->real.kflags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS | EXEC_OBJECT_PINNED; + if (INTEL_DEBUG(DEBUG_CAPTURE_ALL)) + bo->real.kflags |= EXEC_OBJECT_CAPTURE; bo->address = vma_alloc(bufmgr, IRIS_MEMZONE_OTHER, bo->size, 1); if (bo->address == 0ull) { @@ -1913,6 +1918,8 @@ iris_bo_import_dmabuf(struct iris_bufmgr *bufmgr, int prime_fd) bo->real.imported = true; bo->real.mmap_mode = IRIS_MMAP_NONE; bo->real.kflags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS | EXEC_OBJECT_PINNED; + if (INTEL_DEBUG(DEBUG_CAPTURE_ALL)) + bo->real.kflags |= EXEC_OBJECT_CAPTURE; bo->gem_handle = handle; /* From the Bspec, Memory Compression - Gfx12: diff --git a/src/intel/dev/intel_debug.c b/src/intel/dev/intel_debug.c index 41ed20fa614..a374ee5d97d 100644 --- a/src/intel/dev/intel_debug.c +++ b/src/intel/dev/intel_debug.c @@ -93,6 +93,7 @@ static const struct debug_control debug_control[] = { { "task", DEBUG_TASK }, { "mesh", DEBUG_MESH }, { "stall", DEBUG_STALL }, + { "capture-all", DEBUG_CAPTURE_ALL }, { NULL, 0 } }; diff --git a/src/intel/dev/intel_debug.h b/src/intel/dev/intel_debug.h index 3e6e385a4d2..14b32b54e5f 100644 --- a/src/intel/dev/intel_debug.h +++ b/src/intel/dev/intel_debug.h @@ -88,6 +88,7 @@ extern uint64_t intel_debug; #define DEBUG_RT (1ull << 40) #define DEBUG_TASK (1ull << 41) #define DEBUG_MESH (1ull << 42) +#define DEBUG_CAPTURE_ALL (1ull << 43) #define DEBUG_ANY (~0ull) diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c index 785b4e032f0..16c3ce4726d 100644 --- a/src/intel/vulkan/anv_allocator.c +++ b/src/intel/vulkan/anv_allocator.c @@ -1366,7 +1366,9 @@ anv_bo_alloc_flags_to_bo_flags(struct anv_device *device, pdevice->supports_48bit_addresses) bo_flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS; - if ((alloc_flags & ANV_BO_ALLOC_CAPTURE) && pdevice->has_exec_capture) + if (((alloc_flags & ANV_BO_ALLOC_CAPTURE) || + INTEL_DEBUG(DEBUG_CAPTURE_ALL)) && + pdevice->has_exec_capture) bo_flags |= EXEC_OBJECT_CAPTURE; if (alloc_flags & ANV_BO_ALLOC_IMPLICIT_WRITE) { diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c index 58baa912507..111a4dc3495 100644 --- a/src/intel/vulkan/anv_batch_chain.c +++ b/src/intel/vulkan/anv_batch_chain.c @@ -1786,8 +1786,9 @@ anv_queue_exec_locked(struct anv_queue *queue, const struct anv_bo *bo = execbuf.bos[i]; fprintf(stderr, " BO: addr=0x%016"PRIx64"-0x%016"PRIx64" size=0x%010"PRIx64 - " handle=%05u name=%s\n", - bo->offset, bo->offset + bo->size - 1, bo->size, bo->gem_handle, bo->name); + " handle=%05u capture=%u name=%s\n", + bo->offset, bo->offset + bo->size - 1, bo->size, bo->gem_handle, + (bo->flags & EXEC_OBJECT_CAPTURE) != 0, bo->name); } }