Skip to content

Commit e7fd136

Browse files
johnharr-intelgregkh
authored andcommitted
drm/xe/guc: Copy GuC log prior to dumping
[ Upstream commit a59a403 ] 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 Stable-dep-of: 5dce85f ("drm/xe: Move the coredump registration to the worker thread") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e3e6bea commit e7fd136

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
@@ -6,9 +6,12 @@
66
#include "xe_guc_log.h"
77

88
#include <drm/drm_managed.h>
9+
#include <linux/vmalloc.h>
910

1011
#include "xe_bo.h"
12+
#include "xe_devcoredump.h"
1113
#include "xe_gt.h"
14+
#include "xe_gt_printk.h"
1215
#include "xe_map.h"
1316
#include "xe_module.h"
1417

@@ -49,32 +52,35 @@ static size_t guc_log_size(void)
4952
CAPTURE_BUFFER_SIZE;
5053
}
5154

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

58-
xe_assert(xe, log->bo);
66+
if (!log->bo) {
67+
drm_puts(p, "GuC log buffer not allocated");
68+
return;
69+
}
5970

6071
size = log->bo->size;
6172

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

8086
int xe_guc_log_init(struct xe_guc_log *log)

0 commit comments

Comments
 (0)