Skip to content

Commit db38fdb

Browse files
drm/xe/guc: Separate full CTB content from guc_info debugfs
The guc_info debugfs file is meant to be a quick view of the current software state of the GuC interface. Including the full CTB contents makes the file as a whole much less human readable and is not partiular useful in the general case. So don't pollute the info dump with the full buffers. Instead, move those into a separate debugfs entry that can be read when that information is actually required. Also, improve the human readability by adding a few extra blank lines to delimt the sections. v2: Hide the internal capture/print params from external callers that don't need to know (review feedback from Matthew Brost). Signed-off-by: John Harrison <John.C.Harrison@Intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20241024002554.1983101-3-John.C.Harrison@Intel.com
1 parent 833b2ec commit db38fdb

File tree

5 files changed

+49
-31
lines changed

5 files changed

+49
-31
lines changed

drivers/gpu/drm/xe/xe_devcoredump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ static void devcoredump_snapshot(struct xe_devcoredump *coredump,
267267
fw_ref = xe_force_wake_get(gt_to_fw(q->gt), XE_FORCEWAKE_ALL);
268268

269269
ss->guc.log = xe_guc_log_snapshot_capture(&guc->log, true);
270-
ss->guc.ct = xe_guc_ct_snapshot_capture(&guc->ct, true);
270+
ss->guc.ct = xe_guc_ct_snapshot_capture(&guc->ct);
271271
ss->ge = xe_guc_exec_queue_snapshot_capture(q);
272272
ss->job = xe_sched_job_snapshot_capture(job);
273273
ss->vm = xe_vm_snapshot_capture(q->vm);

drivers/gpu/drm/xe/xe_guc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,10 @@ void xe_guc_print_info(struct xe_guc *guc, struct drm_printer *p)
11861186

11871187
xe_force_wake_put(gt_to_fw(gt), fw_ref);
11881188

1189-
xe_guc_ct_print(&guc->ct, p);
1189+
drm_puts(p, "\n");
1190+
xe_guc_ct_print(&guc->ct, p, false);
1191+
1192+
drm_puts(p, "\n");
11901193
xe_guc_submit_print(guc, p);
11911194
}
11921195

drivers/gpu/drm/xe/xe_guc_ct.c

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,15 +1607,16 @@ static void g2h_worker_func(struct work_struct *w)
16071607
receive_g2h(ct);
16081608
}
16091609

1610-
struct xe_guc_ct_snapshot *xe_guc_ct_snapshot_alloc(struct xe_guc_ct *ct, bool atomic)
1610+
static struct xe_guc_ct_snapshot *guc_ct_snapshot_alloc(struct xe_guc_ct *ct, bool atomic,
1611+
bool want_ctb)
16111612
{
16121613
struct xe_guc_ct_snapshot *snapshot;
16131614

16141615
snapshot = kzalloc(sizeof(*snapshot), atomic ? GFP_ATOMIC : GFP_KERNEL);
16151616
if (!snapshot)
16161617
return NULL;
16171618

1618-
if (ct->bo) {
1619+
if (ct->bo && want_ctb) {
16191620
snapshot->ctb_size = ct->bo->size;
16201621
snapshot->ctb = kmalloc(snapshot->ctb_size, atomic ? GFP_ATOMIC : GFP_KERNEL);
16211622
}
@@ -1645,25 +1646,13 @@ static void guc_ctb_snapshot_print(struct guc_ctb_snapshot *snapshot,
16451646
drm_printf(p, "\tstatus (memory): 0x%x\n", snapshot->desc.status);
16461647
}
16471648

1648-
/**
1649-
* xe_guc_ct_snapshot_capture - Take a quick snapshot of the CT state.
1650-
* @ct: GuC CT object.
1651-
* @atomic: Boolean to indicate if this is called from atomic context like
1652-
* reset or CTB handler or from some regular path like debugfs.
1653-
*
1654-
* This can be printed out in a later stage like during dev_coredump
1655-
* analysis.
1656-
*
1657-
* Returns: a GuC CT snapshot object that must be freed by the caller
1658-
* by using `xe_guc_ct_snapshot_free`.
1659-
*/
1660-
struct xe_guc_ct_snapshot *xe_guc_ct_snapshot_capture(struct xe_guc_ct *ct,
1661-
bool atomic)
1649+
static struct xe_guc_ct_snapshot *guc_ct_snapshot_capture(struct xe_guc_ct *ct, bool atomic,
1650+
bool want_ctb)
16621651
{
16631652
struct xe_device *xe = ct_to_xe(ct);
16641653
struct xe_guc_ct_snapshot *snapshot;
16651654

1666-
snapshot = xe_guc_ct_snapshot_alloc(ct, atomic);
1655+
snapshot = guc_ct_snapshot_alloc(ct, atomic, want_ctb);
16671656
if (!snapshot) {
16681657
xe_gt_err(ct_to_gt(ct), "Skipping CTB snapshot entirely.\n");
16691658
return NULL;
@@ -1682,6 +1671,21 @@ struct xe_guc_ct_snapshot *xe_guc_ct_snapshot_capture(struct xe_guc_ct *ct,
16821671
return snapshot;
16831672
}
16841673

1674+
/**
1675+
* xe_guc_ct_snapshot_capture - Take a quick snapshot of the CT state.
1676+
* @ct: GuC CT object.
1677+
*
1678+
* This can be printed out in a later stage like during dev_coredump
1679+
* analysis. This is safe to be called during atomic context.
1680+
*
1681+
* Returns: a GuC CT snapshot object that must be freed by the caller
1682+
* by using `xe_guc_ct_snapshot_free`.
1683+
*/
1684+
struct xe_guc_ct_snapshot *xe_guc_ct_snapshot_capture(struct xe_guc_ct *ct)
1685+
{
1686+
return guc_ct_snapshot_capture(ct, true, true);
1687+
}
1688+
16851689
/**
16861690
* xe_guc_ct_snapshot_print - Print out a given GuC CT snapshot.
16871691
* @snapshot: GuC CT snapshot object.
@@ -1704,12 +1708,8 @@ void xe_guc_ct_snapshot_print(struct xe_guc_ct_snapshot *snapshot,
17041708
drm_printf(p, "\tg2h outstanding: %d\n",
17051709
snapshot->g2h_outstanding);
17061710

1707-
if (snapshot->ctb) {
1711+
if (snapshot->ctb)
17081712
xe_print_blob_ascii85(p, "CTB data", snapshot->ctb, 0, snapshot->ctb_size);
1709-
} else {
1710-
drm_printf(p, "CTB snapshot missing!\n");
1711-
return;
1712-
}
17131713
} else {
17141714
drm_puts(p, "CT disabled\n");
17151715
}
@@ -1735,14 +1735,16 @@ void xe_guc_ct_snapshot_free(struct xe_guc_ct_snapshot *snapshot)
17351735
* xe_guc_ct_print - GuC CT Print.
17361736
* @ct: GuC CT.
17371737
* @p: drm_printer where it will be printed out.
1738+
* @want_ctb: Should the full CTB content be dumped (vs just the headers)
17381739
*
1739-
* This function quickly capture a snapshot and immediately print it out.
1740+
* This function will quickly capture a snapshot of the CT state
1741+
* and immediately print it out.
17401742
*/
1741-
void xe_guc_ct_print(struct xe_guc_ct *ct, struct drm_printer *p)
1743+
void xe_guc_ct_print(struct xe_guc_ct *ct, struct drm_printer *p, bool want_ctb)
17421744
{
17431745
struct xe_guc_ct_snapshot *snapshot;
17441746

1745-
snapshot = xe_guc_ct_snapshot_capture(ct, false);
1747+
snapshot = guc_ct_snapshot_capture(ct, false, want_ctb);
17461748
xe_guc_ct_snapshot_print(snapshot, p);
17471749
xe_guc_ct_snapshot_free(snapshot);
17481750
}
@@ -1776,7 +1778,7 @@ static void ct_dead_capture(struct xe_guc_ct *ct, struct guc_ctb *ctb, u32 reaso
17761778
return;
17771779

17781780
snapshot_log = xe_guc_log_snapshot_capture(&guc->log, true);
1779-
snapshot_ct = xe_guc_ct_snapshot_capture((ct), true);
1781+
snapshot_ct = xe_guc_ct_snapshot_capture((ct));
17801782

17811783
spin_lock_irqsave(&ct->dead.lock, flags);
17821784

drivers/gpu/drm/xe/xe_guc_ct.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ void xe_guc_ct_disable(struct xe_guc_ct *ct);
1717
void xe_guc_ct_stop(struct xe_guc_ct *ct);
1818
void xe_guc_ct_fast_path(struct xe_guc_ct *ct);
1919

20-
struct xe_guc_ct_snapshot *xe_guc_ct_snapshot_alloc(struct xe_guc_ct *ct, bool atomic);
21-
struct xe_guc_ct_snapshot *xe_guc_ct_snapshot_capture(struct xe_guc_ct *ct, bool atomic);
20+
struct xe_guc_ct_snapshot *xe_guc_ct_snapshot_capture(struct xe_guc_ct *ct);
2221
void xe_guc_ct_snapshot_print(struct xe_guc_ct_snapshot *snapshot, struct drm_printer *p);
2322
void xe_guc_ct_snapshot_free(struct xe_guc_ct_snapshot *snapshot);
24-
void xe_guc_ct_print(struct xe_guc_ct *ct, struct drm_printer *p);
23+
void xe_guc_ct_print(struct xe_guc_ct *ct, struct drm_printer *p, bool want_ctb);
2524

2625
static inline bool xe_guc_ct_enabled(struct xe_guc_ct *ct)
2726
{

drivers/gpu/drm/xe/xe_guc_debugfs.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,23 @@ static int guc_log(struct seq_file *m, void *data)
4747
return 0;
4848
}
4949

50+
static int guc_ctb(struct seq_file *m, void *data)
51+
{
52+
struct xe_guc *guc = node_to_guc(m->private);
53+
struct xe_device *xe = guc_to_xe(guc);
54+
struct drm_printer p = drm_seq_file_printer(m);
55+
56+
xe_pm_runtime_get(xe);
57+
xe_guc_ct_print(&guc->ct, &p, true);
58+
xe_pm_runtime_put(xe);
59+
60+
return 0;
61+
}
62+
5063
static const struct drm_info_list debugfs_list[] = {
5164
{"guc_info", guc_info, 0},
5265
{"guc_log", guc_log, 0},
66+
{"guc_ctb", guc_ctb, 0},
5367
};
5468

5569
void xe_guc_debugfs_register(struct xe_guc *guc, struct dentry *parent)

0 commit comments

Comments
 (0)