[PATCH v4 6/6] drm/xe/guc: Only add GuC crash dump if available
Zhanjun Dong
zhanjun.dong at intel.com
Wed Apr 23 21:58:21 UTC 2025
Add GuC crash dump data empty check. LFD will only include crash dump
section when data is not empty.
Signed-off-by: Zhanjun Dong <zhanjun.dong at intel.com>
---
drivers/gpu/drm/xe/xe_guc_log.c | 63 +++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_guc_log.c b/drivers/gpu/drm/xe/xe_guc_log.c
index 5aa9b9dbe3f3..6e48c1a42899 100644
--- a/drivers/gpu/drm/xe/xe_guc_log.c
+++ b/drivers/gpu/drm/xe/xe_guc_log.c
@@ -497,6 +497,64 @@ xe_guc_log_add_log_event(struct drm_printer *p, char *buf, struct xe_guc_log_sna
return index;
}
+static int
+xe_guc_log_add_crash_dump(struct drm_printer *p, char *buf, struct xe_guc_log_snapshot *snapshot,
+ struct guc_log_init_config_save *config)
+{
+ struct guc_log_buffer_entry_list *entry;
+ int chunk_from, chunk_id, to_chunk_id;
+ int pos, from, to, index = 0;
+
+ entry = &config->entry[GUC_LOG_BUFFER_STATE_HEADER_ENTRY_CRASH];
+
+ /* Skip zero sized crash dump */
+ if (!entry->buf_size)
+ return 0;
+
+ /* Check if crash dump section are all zero */
+ from = entry->offset;
+ to = entry->offset + entry->buf_size;
+ chunk_from = from % GUC_LOG_CHUNK_SIZE;
+ chunk_id = from / GUC_LOG_CHUNK_SIZE;
+ to_chunk_id = to / GUC_LOG_CHUNK_SIZE;
+ pos = from;
+
+ do {
+ size_t size = (to_chunk_id > chunk_id ? GUC_LOG_CHUNK_SIZE : to) - chunk_from;
+ u32 *buf32 = snapshot->copy[chunk_id] + chunk_from;
+ int i;
+
+ for (i = 0; i < size / sizeof(u32); i++)
+ if (buf32[i])
+ break;
+ if (i < size / sizeof(u32)) {
+ pos += i * sizeof(u32) - chunk_from;
+ break;
+ }
+ pos += size;
+ chunk_id++;
+ chunk_from = 0;
+ } while (pos < to);
+
+ /* Buffer has non-zero data? */
+ if (pos < to) {
+ struct guc_logfile_lfd_data *lfd = (void *)buf;
+
+ memset(buf, 0, GUC_LOG_CHUNK_SIZE);
+ index = xe_guc_log_add_lfd_header(buf, GUC_LOG_CHUNK_SIZE);
+ lfd->dw0 |= FIELD_PREP(GUC_LOGFILE_LFD_DESC_TYPE, GUC_LFD_TYPE_FW_CRASH_DUMP);
+ /* Calculate data length */
+ lfd->desc_dw_size = DIV_ROUND_UP(entry->buf_size, sizeof(u32));
+ /* Output GUC_LFD_TYPE_FW_CRASH_DUMP header */
+ xe_print_blob_ascii85(p, NULL, 0, buf, 0, (size_t)index);
+
+ /* rd/wr ptr is not used for crash dump */
+ xe_guc_log_print_over_chunks(p, snapshot, entry->offset,
+ entry->offset + entry->buf_size);
+ }
+ return index;
+}
+
static void
xe_guc_log_snapshot_print_lfd(struct xe_guc_log_snapshot *snapshot, struct drm_printer *p,
struct xe_guc_log *log)
@@ -521,7 +579,12 @@ xe_guc_log_snapshot_print_lfd(struct xe_guc_log_snapshot *snapshot, struct drm_p
goto lfd_out;
xe_print_blob_ascii85(p, "[LOG].data", 0, lfd_buf, 0, (size_t)index);
+
index = xe_guc_log_add_log_event(p, lfd_buf, snapshot, &config);
+ if (index < 0)
+ goto lfd_out;
+
+ index = xe_guc_log_add_crash_dump(p, lfd_buf, snapshot, &config);
lfd_out:
drm_printf(p, "\n");
--
2.34.1
More information about the Intel-xe
mailing list