Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Zhanjun Dong <zhanjun.dong@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Zhanjun Dong <zhanjun.dong@intel.com>
Subject: [PATCH v8 5/6] drm/xe/guc: Only add GuC crash dump if available
Date: Thu, 27 Nov 2025 12:07:58 -0500	[thread overview]
Message-ID: <20251127170759.2620994-6-zhanjun.dong@intel.com> (raw)
In-Reply-To: <20251127170759.2620994-1-zhanjun.dong@intel.com>

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@intel.com>
---
 drivers/gpu/drm/xe/xe_guc_log.c | 45 +++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_guc_log.c b/drivers/gpu/drm/xe/xe_guc_log.c
index 51c54d2a49fd..40c9e812e9d5 100644
--- a/drivers/gpu/drm/xe/xe_guc_log.c
+++ b/drivers/gpu/drm/xe/xe_guc_log.c
@@ -498,6 +498,50 @@ xe_guc_log_add_log_event(struct drm_printer *p, struct xe_guc_log_snapshot *snap
 	return size;
 }
 
+static int
+xe_guc_log_add_crash_dump(struct drm_printer *p, struct xe_guc_log_snapshot *snapshot,
+			  struct guc_lic_save *config)
+{
+	struct guc_log_buffer_entry_list *entry;
+	int chunk_from, chunk_id;
+	int from, to, i;
+	size_t size = 0;
+	u32 *buf32;
+
+	entry = &config->entry[GUC_LOG_TYPE_CRASH_DUMP];
+
+	/* 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;
+	buf32 = snapshot->copy[chunk_id] + chunk_from;
+
+	for (i = 0; i < entry->buf_size / sizeof(u32); i++)
+		if (buf32[i])
+			break;
+
+	/* Buffer has non-zero data? */
+	if (i < entry->buf_size / sizeof(u32)) {
+		struct guc_lfd_data lfd;
+
+		size = xe_guc_log_add_lfd_header(&lfd);
+		lfd.header |= FIELD_PREP(GUC_LFD_DATA_HEADER_MASK_TYPE, GUC_LFD_TYPE_FW_CRASH_DUMP);
+		/* Calculate data length */
+		lfd.data_count = DIV_ROUND_UP(entry->buf_size, sizeof(u32));
+		/* Output GUC_LFD_TYPE_FW_CRASH_DUMP header */
+		lfd_output_binary(p, (char *)&lfd, size);
+
+		/* rd/wr ptr is not used for crash dump */
+		xe_guc_log_print_chunks(p, snapshot, from, to);
+	}
+	return size;
+}
+
 void
 xe_guc_log_snapshot_print_lfd(struct xe_guc_log_snapshot *snapshot, struct drm_printer *p);
 void
@@ -527,6 +571,7 @@ xe_guc_log_snapshot_print_lfd(struct xe_guc_log_snapshot *snapshot, struct drm_p
 		return;
 
 	xe_guc_log_add_log_event(p, snapshot, &config);
+	xe_guc_log_add_crash_dump(p, snapshot, &config);
 }
 
 /**
-- 
2.34.1


  parent reply	other threads:[~2025-11-27 17:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-27 17:07 [PATCH v8 0/6] drm/xe/guc: Add LFD format output for guc log Zhanjun Dong
2025-11-27 17:07 ` [PATCH v8 1/6] drm/xe/guc: Add log init config abi definitions Zhanjun Dong
2025-11-27 17:07 ` [PATCH v8 2/6] drm/xe/guc: Add LFD related " Zhanjun Dong
2025-11-27 17:07 ` [PATCH v8 3/6] drm/xe/guc: Add GuC log init config in LFD format Zhanjun Dong
2025-11-27 17:07 ` [PATCH v8 4/6] drm/xe/guc: Add GuC log event buffer output " Zhanjun Dong
2025-12-04 20:55   ` Julia Filipchuk
2025-11-27 17:07 ` Zhanjun Dong [this message]
2025-12-04 20:41   ` [PATCH v8 5/6] drm/xe/guc: Only add GuC crash dump if available Julia Filipchuk
2025-11-27 17:07 ` [PATCH v8 6/6] drm/xe/guc: Add new debugfs entry for lfd format output Zhanjun Dong
2025-11-27 19:06 ` ✗ CI.checkpatch: warning for drm/xe/guc: Add LFD format output for guc log (rev8) Patchwork
2025-11-27 19:08 ` ✓ CI.KUnit: success " Patchwork
2025-11-27 20:22 ` ✓ Xe.CI.BAT: " Patchwork
2025-11-27 22:18 ` ✗ Xe.CI.Full: failure " Patchwork
2025-12-04 21:25   ` Dong, Zhanjun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251127170759.2620994-6-zhanjun.dong@intel.com \
    --to=zhanjun.dong@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox