]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe: Add replay_offset and replay_length lines to LRC HWCTX snapshot
authorMatthew Brost <matthew.brost@intel.com>
Wed, 26 Nov 2025 18:59:51 +0000 (10:59 -0800)
committerMatthew Brost <matthew.brost@intel.com>
Mon, 1 Dec 2025 18:03:18 +0000 (10:03 -0800)
Add replay_offset and replay_length lines to LRC HWCTX snapshot with the
idea being this information can be used extract the data which needs to
be pass to exec queue extension DRM_XE_EXEC_QUEUE_SET_HANG_REPLAY_STATE
so GPU hang can be replayed via a Mesa tool.

The additional lines look like:

[HWCTX].replay_offset: 0x%x
[HWCTX].replay_length: 0x%x

Cc: José Roberto de Souza <jose.souza@intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Link: https://patch.msgid.link/20251126185952.546277-9-matthew.brost@intel.com
drivers/gpu/drm/xe/xe_lrc.c
drivers/gpu/drm/xe/xe_lrc.h
drivers/gpu/drm/xe/xe_lrc_types.h

index b5083c99dd500aa33b4df118218e3b02bee5ec2c..2deca095607c8f837655ca6c497924e2966b8e8d 100644 (file)
@@ -1402,6 +1402,9 @@ static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
 
        kref_init(&lrc->refcount);
        lrc->gt = gt;
+       lrc->replay_size = xe_gt_lrc_size(gt, hwe->class);
+       if (xe_gt_has_indirect_ring_state(gt))
+               lrc->replay_size -= LRC_INDIRECT_RING_STATE_SIZE;
        lrc->size = lrc_size;
        lrc->flags = 0;
        lrc->ring.size = ring_size;
@@ -2235,6 +2238,8 @@ struct xe_lrc_snapshot *xe_lrc_snapshot_capture(struct xe_lrc *lrc)
        snapshot->lrc_bo = xe_bo_get(lrc->bo);
        snapshot->lrc_offset = xe_lrc_pphwsp_offset(lrc);
        snapshot->lrc_size = lrc->size;
+       snapshot->replay_offset = 0;
+       snapshot->replay_size = lrc->replay_size;
        snapshot->lrc_snapshot = NULL;
        snapshot->ctx_timestamp = lower_32_bits(xe_lrc_ctx_timestamp(lrc));
        snapshot->ctx_job_timestamp = xe_lrc_ctx_job_timestamp(lrc);
@@ -2305,6 +2310,9 @@ void xe_lrc_snapshot_print(struct xe_lrc_snapshot *snapshot, struct drm_printer
        }
 
        drm_printf(p, "\n\t[HWCTX].length: 0x%lx\n", snapshot->lrc_size - LRC_PPHWSP_SIZE);
+       drm_printf(p, "\n\t[HWCTX].replay_offset: 0x%lx\n", snapshot->replay_offset);
+       drm_printf(p, "\n\t[HWCTX].replay_length: 0x%lx\n", snapshot->replay_size);
+
        drm_puts(p, "\t[HWCTX].data: ");
        for (; i < snapshot->lrc_size; i += sizeof(u32)) {
                u32 *val = snapshot->lrc_snapshot + i;
index 2fb628da5c4331c8b7e96e0de11e78af20acb3bc..c3288625d0c708265304949ceaf6a86c6971b767 100644 (file)
@@ -23,6 +23,7 @@ struct xe_lrc_snapshot {
        struct xe_bo *lrc_bo;
        void *lrc_snapshot;
        unsigned long lrc_size, lrc_offset;
+       unsigned long replay_size, replay_offset;
 
        u32 context_desc;
        u32 ring_addr;
index e9883706e0043a1fc0dad5978e712cd99ec9b344..a4373d280c397d304279b7c91303d62034ed8f3d 100644 (file)
@@ -25,6 +25,9 @@ struct xe_lrc {
        /** @size: size of the lrc and optional indirect ring state */
        u32 size;
 
+       /** @replay_size: Size LRC needed for replaying a hang */
+       u32 replay_size;
+
        /** @gt: gt which this LRC belongs to */
        struct xe_gt *gt;