Skip to content

Commit bdea9e6

Browse files
lucasdemarchigregkh
authored andcommitted
drm/xe: Fix and re-enable xe_print_blob_ascii85()
commit a9ab659 upstream. 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 <[email protected]> Cc: John Harrison <[email protected]> Cc: Julia Filipchuk <[email protected]> Cc: José Roberto de Souza <[email protected]> Cc: [email protected] 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/[email protected] Signed-off-by: Lucas De Marchi <[email protected]> (cherry picked from commit 2c95bbf) Signed-off-by: Rodrigo Vivi <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c963ef1 commit bdea9e6

File tree

3 files changed

+15
-23
lines changed

3 files changed

+15
-23
lines changed

drivers/gpu/drm/xe/xe_devcoredump.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -333,42 +333,34 @@ int xe_devcoredump_init(struct xe_device *xe)
333333
/**
334334
* xe_print_blob_ascii85 - print a BLOB to some useful location in ASCII85
335335
*
336-
* The output is split to multiple lines because some print targets, e.g. dmesg
337-
* cannot handle arbitrarily long lines. Note also that printing to dmesg in
338-
* piece-meal fashion is not possible, each separate call to drm_puts() has a
339-
* line-feed automatically added! Therefore, the entire output line must be
340-
* constructed in a local buffer first, then printed in one atomic output call.
336+
* The output is split into multiple calls to drm_puts() because some print
337+
* targets, e.g. dmesg, cannot handle arbitrarily long lines. These targets may
338+
* add newlines, as is the case with dmesg: each drm_puts() call creates a
339+
* separate line.
341340
*
342341
* There is also a scheduler yield call to prevent the 'task has been stuck for
343342
* 120s' kernel hang check feature from firing when printing to a slow target
344343
* such as dmesg over a serial port.
345344
*
346-
* TODO: Add compression prior to the ASCII85 encoding to shrink huge buffers down.
347-
*
348345
* @p: the printer object to output to
349346
* @prefix: optional prefix to add to output string
347+
* @suffix: optional suffix to add at the end. 0 disables it and is
348+
* not added to the output, which is useful when using multiple calls
349+
* to dump data to @p
350350
* @blob: the Binary Large OBject to dump out
351351
* @offset: offset in bytes to skip from the front of the BLOB, must be a multiple of sizeof(u32)
352352
* @size: the size in bytes of the BLOB, must be a multiple of sizeof(u32)
353353
*/
354-
void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix,
354+
void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix, char suffix,
355355
const void *blob, size_t offset, size_t size)
356356
{
357357
const u32 *blob32 = (const u32 *)blob;
358358
char buff[ASCII85_BUFSZ], *line_buff;
359359
size_t line_pos = 0;
360360

361-
/*
362-
* Splitting blobs across multiple lines is not compatible with the mesa
363-
* debug decoder tool. Note that even dropping the explicit '\n' below
364-
* doesn't help because the GuC log is so big some underlying implementation
365-
* still splits the lines at 512K characters. So just bail completely for
366-
* the moment.
367-
*/
368-
return;
369-
370361
#define DMESG_MAX_LINE_LEN 800
371-
#define MIN_SPACE (ASCII85_BUFSZ + 2) /* 85 + "\n\0" */
362+
/* Always leave space for the suffix char and the \0 */
363+
#define MIN_SPACE (ASCII85_BUFSZ + 2) /* 85 + "<suffix>\0" */
372364

373365
if (size & 3)
374366
drm_printf(p, "Size not word aligned: %zu", size);
@@ -400,7 +392,6 @@ void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix,
400392
line_pos += strlen(line_buff + line_pos);
401393

402394
if ((line_pos + MIN_SPACE) >= DMESG_MAX_LINE_LEN) {
403-
line_buff[line_pos++] = '\n';
404395
line_buff[line_pos++] = 0;
405396

406397
drm_puts(p, line_buff);
@@ -412,10 +403,11 @@ void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix,
412403
}
413404
}
414405

406+
if (suffix)
407+
line_buff[line_pos++] = suffix;
408+
415409
if (line_pos) {
416-
line_buff[line_pos++] = '\n';
417410
line_buff[line_pos++] = 0;
418-
419411
drm_puts(p, line_buff);
420412
}
421413

drivers/gpu/drm/xe/xe_devcoredump.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static inline int xe_devcoredump_init(struct xe_device *xe)
2626
}
2727
#endif
2828

29-
void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix,
29+
void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix, char suffix,
3030
const void *blob, size_t offset, size_t size);
3131

3232
#endif

drivers/gpu/drm/xe/xe_guc_log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void xe_guc_log_print(struct xe_guc_log *log, struct drm_printer *p)
7878

7979
xe_map_memcpy_from(xe, copy, &log->bo->vmap, 0, size);
8080

81-
xe_print_blob_ascii85(p, "Log data", copy, 0, size);
81+
xe_print_blob_ascii85(p, "Log data", '\n', copy, 0, size);
8282

8383
vfree(copy);
8484
}

0 commit comments

Comments
 (0)