intel: add INTEL_DEBUG=capture-all to capture everything upon hang
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 5 Oct 2022 21:34:52 +0000 (00:34 +0300)
committerMarge Bot <emma+marge@anholt.net>
Fri, 7 Oct 2022 07:45:22 +0000 (07:45 +0000)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewd-by: Jordan Justen <jordan.l.justen@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18977>

docs/envvars.rst
src/gallium/drivers/iris/iris_bufmgr.c
src/intel/dev/intel_debug.c
src/intel/dev/intel_debug.h
src/intel/vulkan/anv_allocator.c
src/intel/vulkan/anv_batch_chain.c

index a8f0f12..ad84505 100644 (file)
@@ -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)
index 7a8e7f9..9c9aefa 100644 (file)
@@ -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:
index 41ed20f..a374ee5 100644 (file)
@@ -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 }
 };
 
index 3e6e385..14b32b5 100644 (file)
@@ -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)
 
index 785b4e0..16c3ce4 100644 (file)
@@ -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) {
index 58baa91..111a4dc 100644 (file)
@@ -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);
       }
    }