drm/xe: Add batch buffer addresses to devcoredump

Those addresses are necessary to Mesa tools knows where in VM are the
batch buffers to parse and print instructions that are human readable.

Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Maarten Lankhorst <dev@lankhorst.se>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240130135648.30211-2-jose.souza@intel.com
This commit is contained in:
José Roberto de Souza 2024-01-30 05:56:48 -08:00
parent 5746eaaa80
commit be7d51c5b4
5 changed files with 56 additions and 0 deletions

View File

@ -96,6 +96,9 @@ static ssize_t xe_devcoredump_read(char *buffer, loff_t offset,
xe_guc_ct_snapshot_print(coredump->snapshot.ct, &p);
xe_guc_exec_queue_snapshot_print(coredump->snapshot.ge, &p);
drm_printf(&p, "\n**** Job ****\n");
xe_sched_job_snapshot_print(coredump->snapshot.job, &p);
drm_printf(&p, "\n**** HW Engines ****\n");
for (i = 0; i < XE_NUM_HW_ENGINES; i++)
if (coredump->snapshot.hwe[i])
@ -116,6 +119,7 @@ static void xe_devcoredump_free(void *data)
xe_guc_ct_snapshot_free(coredump->snapshot.ct);
xe_guc_exec_queue_snapshot_free(coredump->snapshot.ge);
xe_sched_job_snapshot_free(coredump->snapshot.job);
for (i = 0; i < XE_NUM_HW_ENGINES; i++)
if (coredump->snapshot.hwe[i])
xe_hw_engine_snapshot_free(coredump->snapshot.hwe[i]);
@ -155,6 +159,7 @@ static void devcoredump_snapshot(struct xe_devcoredump *coredump,
coredump->snapshot.ct = xe_guc_ct_snapshot_capture(&guc->ct, true);
coredump->snapshot.ge = xe_guc_exec_queue_snapshot_capture(job);
coredump->snapshot.job = xe_sched_job_snapshot_capture(job);
for_each_hw_engine(hwe, q->gt, id) {
if (hwe->class != q->hwe->class ||

View File

@ -31,8 +31,11 @@ struct xe_devcoredump_snapshot {
struct xe_guc_ct_snapshot *ct;
/** @ge: Guc Engine snapshot */
struct xe_guc_submit_exec_queue_snapshot *ge;
/** @hwe: HW Engine snapshot array */
struct xe_hw_engine_snapshot *hwe[XE_NUM_HW_ENGINES];
/** @job: Snapshot of job state */
struct xe_sched_job_snapshot *job;
};
/**

View File

@ -278,3 +278,41 @@ int xe_sched_job_last_fence_add_dep(struct xe_sched_job *job, struct xe_vm *vm)
return drm_sched_job_add_dependency(&job->drm, fence);
}
struct xe_sched_job_snapshot *
xe_sched_job_snapshot_capture(struct xe_sched_job *job)
{
struct xe_exec_queue *q = job->q;
struct xe_device *xe = q->gt->tile->xe;
struct xe_sched_job_snapshot *snapshot;
size_t len = sizeof(*snapshot) + (sizeof(u64) * q->width);
u16 i;
snapshot = kzalloc(len, GFP_ATOMIC);
if (!snapshot)
return NULL;
snapshot->batch_addr_len = q->width;
for (i = 0; i < q->width; i++)
snapshot->batch_addr[i] = xe_device_uncanonicalize_addr(xe, job->batch_addr[i]);
return snapshot;
}
void xe_sched_job_snapshot_free(struct xe_sched_job_snapshot *snapshot)
{
kfree(snapshot);
}
void
xe_sched_job_snapshot_print(struct xe_sched_job_snapshot *snapshot,
struct drm_printer *p)
{
u16 i;
if (!snapshot)
return;
for (i = 0; i < snapshot->batch_addr_len; i++)
drm_printf(p, "batch_addr[%u]: 0x%016llx\n", i, snapshot->batch_addr[i]);
}

View File

@ -8,6 +8,7 @@
#include "xe_sched_job_types.h"
struct drm_printer;
struct xe_vm;
#define XE_SCHED_HANG_LIMIT 1
@ -77,4 +78,8 @@ xe_sched_job_add_migrate_flush(struct xe_sched_job *job, u32 flags)
bool xe_sched_job_is_migration(struct xe_exec_queue *q);
struct xe_sched_job_snapshot *xe_sched_job_snapshot_capture(struct xe_sched_job *job);
void xe_sched_job_snapshot_free(struct xe_sched_job_snapshot *snapshot);
void xe_sched_job_snapshot_print(struct xe_sched_job_snapshot *snapshot, struct drm_printer *p);
#endif

View File

@ -43,4 +43,9 @@ struct xe_sched_job {
u64 batch_addr[];
};
struct xe_sched_job_snapshot {
u16 batch_addr_len;
u64 batch_addr[];
};
#endif