Skip to content

Commit a9ab659

Browse files
lucasdemarchirodrigovivi
authored andcommitted
drm/xe: Fix and re-enable xe_print_blob_ascii85()
Commit 70fb86a ("drm/xe: Revert some changes that break a mesa debug tool") partially reverted some changes to workaround breakage caused to mesa tools. However, in doing so it also broke fetching the GuC log via debugfs since xe_print_blob_ascii85() simply bails out. The fix is to avoid the extra newlines: the devcoredump interface is line-oriented and adding random newlines in the middle breaks it. If a tool is able to parse it by looking at the data and checking for chars that are out of the ascii85 space, it can still do so. A format change that breaks the line-oriented output on devcoredump however needs better coordination with existing tools. v2: Add suffix description comment v3: Reword explanation of xe_print_blob_ascii85() calling drm_puts() in a loop Reviewed-by: José Roberto de Souza <jose.souza@intel.com> Cc: John Harrison <John.C.Harrison@Intel.com> Cc: Julia Filipchuk <julia.filipchuk@intel.com> Cc: José Roberto de Souza <jose.souza@intel.com> Cc: stable@vger.kernel.org Fixes: 70fb86a ("drm/xe: Revert some changes that break a mesa debug tool") Fixes: ec1455c ("drm/xe/devcoredump: Add ASCII85 dump helper function") Link: https://patchwork.freedesktop.org/patch/msgid/20250123202307.95103-2-jose.souza@intel.com Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> (cherry picked from commit 2c95bbf) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 042c48b commit a9ab659

File tree

4 files changed

+19
-24
lines changed

4 files changed

+19
-24
lines changed

drivers/gpu/drm/xe/xe_devcoredump.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -391,42 +391,34 @@ int xe_devcoredump_init(struct xe_device *xe)
391391
/**
392392
* xe_print_blob_ascii85 - print a BLOB to some useful location in ASCII85
393393
*
394-
* The output is split to multiple lines because some print targets, e.g. dmesg
395-
* cannot handle arbitrarily long lines. Note also that printing to dmesg in
396-
* piece-meal fashion is not possible, each separate call to drm_puts() has a
397-
* line-feed automatically added! Therefore, the entire output line must be
398-
* constructed in a local buffer first, then printed in one atomic output call.
394+
* The output is split into multiple calls to drm_puts() because some print
395+
* targets, e.g. dmesg, cannot handle arbitrarily long lines. These targets may
396+
* add newlines, as is the case with dmesg: each drm_puts() call creates a
397+
* separate line.
399398
*
400399
* There is also a scheduler yield call to prevent the 'task has been stuck for
401400
* 120s' kernel hang check feature from firing when printing to a slow target
402401
* such as dmesg over a serial port.
403402
*
404-
* TODO: Add compression prior to the ASCII85 encoding to shrink huge buffers down.
405-
*
406403
* @p: the printer object to output to
407404
* @prefix: optional prefix to add to output string
405+
* @suffix: optional suffix to add at the end. 0 disables it and is
406+
* not added to the output, which is useful when using multiple calls
407+
* to dump data to @p
408408
* @blob: the Binary Large OBject to dump out
409409
* @offset: offset in bytes to skip from the front of the BLOB, must be a multiple of sizeof(u32)
410410
* @size: the size in bytes of the BLOB, must be a multiple of sizeof(u32)
411411
*/
412-
void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix,
412+
void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix, char suffix,
413413
const void *blob, size_t offset, size_t size)
414414
{
415415
const u32 *blob32 = (const u32 *)blob;
416416
char buff[ASCII85_BUFSZ], *line_buff;
417417
size_t line_pos = 0;
418418

419-
/*
420-
* Splitting blobs across multiple lines is not compatible with the mesa
421-
* debug decoder tool. Note that even dropping the explicit '\n' below
422-
* doesn't help because the GuC log is so big some underlying implementation
423-
* still splits the lines at 512K characters. So just bail completely for
424-
* the moment.
425-
*/
426-
return;
427-
428419
#define DMESG_MAX_LINE_LEN 800
429-
#define MIN_SPACE (ASCII85_BUFSZ + 2) /* 85 + "\n\0" */
420+
/* Always leave space for the suffix char and the \0 */
421+
#define MIN_SPACE (ASCII85_BUFSZ + 2) /* 85 + "<suffix>\0" */
430422

431423
if (size & 3)
432424
drm_printf(p, "Size not word aligned: %zu", size);
@@ -458,7 +450,6 @@ void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix,
458450
line_pos += strlen(line_buff + line_pos);
459451

460452
if ((line_pos + MIN_SPACE) >= DMESG_MAX_LINE_LEN) {
461-
line_buff[line_pos++] = '\n';
462453
line_buff[line_pos++] = 0;
463454

464455
drm_puts(p, line_buff);
@@ -470,10 +461,11 @@ void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix,
470461
}
471462
}
472463

464+
if (suffix)
465+
line_buff[line_pos++] = suffix;
466+
473467
if (line_pos) {
474-
line_buff[line_pos++] = '\n';
475468
line_buff[line_pos++] = 0;
476-
477469
drm_puts(p, line_buff);
478470
}
479471

drivers/gpu/drm/xe/xe_devcoredump.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static inline int xe_devcoredump_init(struct xe_device *xe)
2929
}
3030
#endif
3131

32-
void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix,
32+
void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix, char suffix,
3333
const void *blob, size_t offset, size_t size);
3434

3535
#endif

drivers/gpu/drm/xe/xe_guc_ct.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,8 @@ void xe_guc_ct_snapshot_print(struct xe_guc_ct_snapshot *snapshot,
17241724
snapshot->g2h_outstanding);
17251725

17261726
if (snapshot->ctb)
1727-
xe_print_blob_ascii85(p, "CTB data", snapshot->ctb, 0, snapshot->ctb_size);
1727+
xe_print_blob_ascii85(p, "CTB data", '\n',
1728+
snapshot->ctb, 0, snapshot->ctb_size);
17281729
} else {
17291730
drm_puts(p, "CT disabled\n");
17301731
}

drivers/gpu/drm/xe/xe_guc_log.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,10 @@ void xe_guc_log_snapshot_print(struct xe_guc_log_snapshot *snapshot, struct drm_
211211
remain = snapshot->size;
212212
for (i = 0; i < snapshot->num_chunks; i++) {
213213
size_t size = min(GUC_LOG_CHUNK_SIZE, remain);
214+
const char *prefix = i ? NULL : "Log data";
215+
char suffix = i == snapshot->num_chunks - 1 ? '\n' : 0;
214216

215-
xe_print_blob_ascii85(p, i ? NULL : "Log data", snapshot->copy[i], 0, size);
217+
xe_print_blob_ascii85(p, prefix, suffix, snapshot->copy[i], 0, size);
216218
remain -= size;
217219
}
218220
}

0 commit comments

Comments
 (0)