drm/xe: Add ring start to LRC snapshot
authorMatthew Brost <matthew.brost@intel.com>
Thu, 14 Nov 2024 02:25:18 +0000 (18:25 -0800)
committerMatthew Brost <matthew.brost@intel.com>
Thu, 14 Nov 2024 14:38:42 +0000 (06:38 -0800)
Add LRC ring start register to LRC snapshot to verify no LRC register
corruption upon hang. This could be possible if the indirect ring state
was mapped to user space or via an internal KMD memory corruption.

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241114022522.1951351-4-matthew.brost@intel.com
drivers/gpu/drm/xe/xe_lrc.c
drivers/gpu/drm/xe/xe_lrc.h

index cc77e51..22e58c6 100644 (file)
@@ -1061,6 +1061,14 @@ u32 xe_lrc_ring_tail(struct xe_lrc *lrc)
                return xe_lrc_read_ctx_reg(lrc, CTX_RING_TAIL) & TAIL_ADDR;
 }
 
+static u32 xe_lrc_ring_start(struct xe_lrc *lrc)
+{
+       if (xe_lrc_has_indirect_ring_state(lrc))
+               return xe_lrc_read_indirect_ctx_reg(lrc, INDIRECT_CTX_RING_START);
+       else
+               return xe_lrc_read_ctx_reg(lrc, CTX_RING_START);
+}
+
 void xe_lrc_set_ring_head(struct xe_lrc *lrc, u32 head)
 {
        if (xe_lrc_has_indirect_ring_state(lrc))
@@ -1641,6 +1649,7 @@ struct xe_lrc_snapshot *xe_lrc_snapshot_capture(struct xe_lrc *lrc)
        snapshot->head = xe_lrc_ring_head(lrc);
        snapshot->tail.internal = lrc->ring.tail;
        snapshot->tail.memory = xe_lrc_ring_tail(lrc);
+       snapshot->start = xe_lrc_ring_start(lrc);
        snapshot->start_seqno = xe_lrc_start_seqno(lrc);
        snapshot->seqno = xe_lrc_seqno(lrc);
        snapshot->lrc_bo = xe_bo_get(lrc->bo);
@@ -1701,6 +1710,7 @@ void xe_lrc_snapshot_print(struct xe_lrc_snapshot *snapshot, struct drm_printer
        drm_printf(p, "\tLRC Head: (memory) %u\n", snapshot->head);
        drm_printf(p, "\tLRC Tail: (internal) %u, (memory) %u\n",
                   snapshot->tail.internal, snapshot->tail.memory);
+       drm_printf(p, "\tRing start: (memory) 0x%08x\n", snapshot->start);
        drm_printf(p, "\tStart seqno: (memory) %d\n", snapshot->start_seqno);
        drm_printf(p, "\tSeqno: (memory) %d\n", snapshot->seqno);
        drm_printf(p, "\tTimestamp: 0x%08x\n", snapshot->ctx_timestamp);
index 37ca321..b459dca 100644 (file)
@@ -28,6 +28,7 @@ struct xe_lrc_snapshot {
        u32 ring_addr;
        u32 indirect_context_desc;
        u32 head;
+       u32 start;
        struct {
                u32 internal;
                u32 memory;