Skip to content

Commit

Permalink
drm/xe: Add batch buffer addresses to devcoredump
Browse files Browse the repository at this point in the history
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
  • Loading branch information
José Roberto de Souza committed Jan 30, 2024
1 parent 5746eaa commit be7d51c
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/gpu/drm/xe/xe_devcoredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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]);
Expand Down Expand Up @@ -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 ||
Expand Down
3 changes: 3 additions & 0 deletions drivers/gpu/drm/xe/xe_devcoredump_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/**
Expand Down
38 changes: 38 additions & 0 deletions drivers/gpu/drm/xe/xe_sched_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
5 changes: 5 additions & 0 deletions drivers/gpu/drm/xe/xe_sched_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "xe_sched_job_types.h"

struct drm_printer;
struct xe_vm;

#define XE_SCHED_HANG_LIMIT 1
Expand Down Expand Up @@ -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
5 changes: 5 additions & 0 deletions drivers/gpu/drm/xe/xe_sched_job_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,9 @@ struct xe_sched_job {
u64 batch_addr[];
};

struct xe_sched_job_snapshot {
u16 batch_addr_len;
u64 batch_addr[];
};

#endif

0 comments on commit be7d51c

Please sign in to comment.