Commit 4d5242a0 authored by Maarten Lankhorst's avatar Maarten Lankhorst

drm/xe: Implement capture of HWSP and HWCTX

Dump the HWCTX and HWSP as part of LRC capture.

Changes since v1:
- Use same layout for HWSP and HWCTX as VM bo's, to simplify dumping.
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240227131248.92910-3-maarten.lankhorst@linux.intel.com
parent 784b3410
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include "xe_lrc.h" #include "xe_lrc.h"
#include <linux/ascii85.h>
#include "instructions/xe_mi_commands.h" #include "instructions/xe_mi_commands.h"
#include "instructions/xe_gfxpipe_commands.h" #include "instructions/xe_gfxpipe_commands.h"
#include "instructions/xe_gfx_state_commands.h" #include "instructions/xe_gfx_state_commands.h"
...@@ -33,6 +35,10 @@ ...@@ -33,6 +35,10 @@
#define ENGINE_INSTANCE_SHIFT 48 #define ENGINE_INSTANCE_SHIFT 48
struct xe_lrc_snapshot { struct xe_lrc_snapshot {
struct xe_bo *lrc_bo;
void *lrc_snapshot;
unsigned long lrc_size, lrc_offset;
u32 context_desc; u32 context_desc;
u32 head; u32 head;
struct { struct {
...@@ -1356,19 +1362,47 @@ struct xe_lrc_snapshot *xe_lrc_snapshot_capture(struct xe_lrc *lrc) ...@@ -1356,19 +1362,47 @@ struct xe_lrc_snapshot *xe_lrc_snapshot_capture(struct xe_lrc *lrc)
snapshot->tail.memory = xe_lrc_read_ctx_reg(lrc, CTX_RING_TAIL); snapshot->tail.memory = xe_lrc_read_ctx_reg(lrc, CTX_RING_TAIL);
snapshot->start_seqno = xe_lrc_start_seqno(lrc); snapshot->start_seqno = xe_lrc_start_seqno(lrc);
snapshot->seqno = xe_lrc_seqno(lrc); snapshot->seqno = xe_lrc_seqno(lrc);
snapshot->lrc_bo = xe_bo_get(lrc->bo);
snapshot->lrc_offset = xe_lrc_pphwsp_offset(lrc);
snapshot->lrc_size = lrc->bo->size - snapshot->lrc_offset;
snapshot->lrc_snapshot = NULL;
return snapshot; return snapshot;
} }
void xe_lrc_snapshot_capture_delayed(struct xe_lrc_snapshot *snapshot) void xe_lrc_snapshot_capture_delayed(struct xe_lrc_snapshot *snapshot)
{ {
struct xe_bo *bo;
struct iosys_map src;
if (!snapshot) if (!snapshot)
return; return;
/* TODO: Copy status page */ bo = snapshot->lrc_bo;
snapshot->lrc_bo = NULL;
snapshot->lrc_snapshot = kvmalloc(snapshot->lrc_size, GFP_KERNEL);
if (!snapshot->lrc_snapshot)
goto put_bo;
dma_resv_lock(bo->ttm.base.resv, NULL);
if (!ttm_bo_vmap(&bo->ttm, &src)) {
xe_map_memcpy_from(xe_bo_device(bo),
snapshot->lrc_snapshot, &src, snapshot->lrc_offset,
snapshot->lrc_size);
ttm_bo_vunmap(&bo->ttm, &src);
} else {
kvfree(snapshot->lrc_snapshot);
snapshot->lrc_snapshot = NULL;
}
dma_resv_unlock(bo->ttm.base.resv);
put_bo:
xe_bo_put(bo);
} }
void xe_lrc_snapshot_print(struct xe_lrc_snapshot *snapshot, struct drm_printer *p) void xe_lrc_snapshot_print(struct xe_lrc_snapshot *snapshot, struct drm_printer *p)
{ {
unsigned long i;
if (!snapshot) if (!snapshot)
return; return;
...@@ -1378,9 +1412,37 @@ void xe_lrc_snapshot_print(struct xe_lrc_snapshot *snapshot, struct drm_printer ...@@ -1378,9 +1412,37 @@ void xe_lrc_snapshot_print(struct xe_lrc_snapshot *snapshot, struct drm_printer
snapshot->tail.internal, snapshot->tail.memory); snapshot->tail.internal, snapshot->tail.memory);
drm_printf(p, "\tStart seqno: (memory) %d\n", snapshot->start_seqno); drm_printf(p, "\tStart seqno: (memory) %d\n", snapshot->start_seqno);
drm_printf(p, "\tSeqno: (memory) %d\n", snapshot->seqno); drm_printf(p, "\tSeqno: (memory) %d\n", snapshot->seqno);
if (!snapshot->lrc_snapshot)
return;
drm_printf(p, "\t[HWSP].length: 0x%x\n", LRC_PPHWSP_SIZE);
drm_puts(p, "\t[HWSP].data: ");
for (i = 0; i < LRC_PPHWSP_SIZE; i += sizeof(u32)) {
u32 *val = snapshot->lrc_snapshot + i;
char dumped[ASCII85_BUFSZ];
drm_puts(p, ascii85_encode(*val, dumped));
}
drm_printf(p, "\n\t[HWCTX].length: 0x%lx\n", snapshot->lrc_size - LRC_PPHWSP_SIZE);
drm_puts(p, "\t[HWCTX].data: ");
for (; i < snapshot->lrc_size; i += sizeof(u32)) {
u32 *val = snapshot->lrc_snapshot + i;
char dumped[ASCII85_BUFSZ];
drm_puts(p, ascii85_encode(*val, dumped));
}
drm_puts(p, "\n");
} }
void xe_lrc_snapshot_free(struct xe_lrc_snapshot *snapshot) void xe_lrc_snapshot_free(struct xe_lrc_snapshot *snapshot)
{ {
if (!snapshot)
return;
kvfree(snapshot->lrc_snapshot);
if (snapshot->lrc_bo)
xe_bo_put(snapshot->lrc_bo);
kfree(snapshot); kfree(snapshot);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment