Skip to content

Commit a59a403

Browse files
drm/xe/guc: Copy GuC log prior to dumping
Add an extra stage to the GuC log print to copy the log buffer into regular host memory first, rather than printing the live GPU buffer object directly. Doing so helps prevent inconsistencies due to the log being updated as it is being dumped. It also allows the use of the ASCII85 helper function for printing the log in a more compact form than a straight hex dump. v2: Use %zx instead of %lx for size_t prints. v3: Replace hexdump code with ascii85 call (review feedback from Matthew B). Move chunking code into next patch as that reduces the deltas of both. v4: Add a prefix to the ASCII85 output to aid tool parsing. Signed-off-by: John Harrison <John.C.Harrison@Intel.com> Reviewed-by: Julia Filipchuk <julia.filipchuk@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20241003004611.2323493-6-John.C.Harrison@Intel.com
1 parent ec1455c commit a59a403

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

drivers/gpu/drm/xe/xe_guc_log.c

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
#include <linux/fault-inject.h>
99

1010
#include <drm/drm_managed.h>
11+
#include <linux/vmalloc.h>
1112

1213
#include "xe_bo.h"
14+
#include "xe_devcoredump.h"
1315
#include "xe_gt.h"
16+
#include "xe_gt_printk.h"
1417
#include "xe_map.h"
1518
#include "xe_module.h"
1619

@@ -51,32 +54,35 @@ static size_t guc_log_size(void)
5154
CAPTURE_BUFFER_SIZE;
5255
}
5356

57+
/**
58+
* xe_guc_log_print - dump a copy of the GuC log to some useful location
59+
* @log: GuC log structure
60+
* @p: the printer object to output to
61+
*/
5462
void xe_guc_log_print(struct xe_guc_log *log, struct drm_printer *p)
5563
{
5664
struct xe_device *xe = log_to_xe(log);
5765
size_t size;
58-
int i, j;
66+
void *copy;
5967

60-
xe_assert(xe, log->bo);
68+
if (!log->bo) {
69+
drm_puts(p, "GuC log buffer not allocated");
70+
return;
71+
}
6172

6273
size = log->bo->size;
6374

64-
#define DW_PER_READ 128
65-
xe_assert(xe, !(size % (DW_PER_READ * sizeof(u32))));
66-
for (i = 0; i < size / sizeof(u32); i += DW_PER_READ) {
67-
u32 read[DW_PER_READ];
68-
69-
xe_map_memcpy_from(xe, read, &log->bo->vmap, i * sizeof(u32),
70-
DW_PER_READ * sizeof(u32));
71-
#define DW_PER_PRINT 4
72-
for (j = 0; j < DW_PER_READ / DW_PER_PRINT; ++j) {
73-
u32 *print = read + j * DW_PER_PRINT;
74-
75-
drm_printf(p, "0x%08x 0x%08x 0x%08x 0x%08x\n",
76-
*(print + 0), *(print + 1),
77-
*(print + 2), *(print + 3));
78-
}
75+
copy = vmalloc(size);
76+
if (!copy) {
77+
drm_printf(p, "Failed to allocate %zu", size);
78+
return;
7979
}
80+
81+
xe_map_memcpy_from(xe, copy, &log->bo->vmap, 0, size);
82+
83+
xe_print_blob_ascii85(p, "Log data", copy, 0, size);
84+
85+
vfree(copy);
8086
}
8187

8288
int xe_guc_log_init(struct xe_guc_log *log)

0 commit comments

Comments
 (0)