Skip to contentSkip to conversation

drm/xe/guc: Add LFD format output for guc log

PATCH Superseded Zhanjun Dong 2 participants 9 messages Jul 18, 2025

Subsystems (2)

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v5 cover drm/xe/guc: Add LFD format output for guc log

Add new debugfs entry "guc_log_lfd", which supports output guc log in LFD(Log Format Descriptors) format.
Add GuC crash dump data empty check. LFD will only include crash dump section when data is not empty.

---
Cc: Michal Wajdeczko <[email protected]>
Cc: Jonathan Cavitt <[email protected]>
Cc: Matthew Brost <[email protected]>

Changes in v5:
Cleanup inconsistent macro, type and symbol names (Michal) Switch to use 1K local stack for buffer usage (Michal)
Changes in v4:
Rebase with debugfs changes (Michal)
Drop "_t" suffix in structures name (Matthew, Michal)
Split log abi header as seperate patch (Michal)
Fix static vaiable multiple instance access issue (Michal) Switched to fixed size(2M) of lfd buffer, removed buffer size check for KLVs Removed log event buffer content copy, read from log buffer chunks directly Changes in v3:
Split ABI header, debugfs and GuC code out as seperate patch Remove bit fields in structure define, changed to GENMASK
Remove crash_dumped flag, changed to dump data empty check Changes in v2:
Split GuC init config abi defines out from LFD abi header file Split crash dump detect as seperate patch
Add size check for LFD functions
Make abi header comments kernel-doc style

Zhanjun Dong (6):
drm/xe/guc: Add log init config abi definitions drm/xe/guc: Add LFD related abi definitions drm/xe/guc: Add new debugfs entry for lfd format output drm/xe/guc: Add GuC log init config in LFD format drm/xe/guc: Add GuC log event buffer output in LFD format drm/xe/guc: Only add GuC crash dump if available

 drivers/gpu/drm/xe/abi/guc_lfd_abi.h | 282 ++++++++++++++++++++
 drivers/gpu/drm/xe/abi/guc_lic_abi.h | 107 ++++++++
 drivers/gpu/drm/xe/xe_guc_debugfs.c  |   7 +
 drivers/gpu/drm/xe/xe_guc_log.c      | 382 +++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_guc_log.h      |   1 +
 5 files changed, 779 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/abi/guc_lfd_abi.h
 create mode 100644 drivers/gpu/drm/xe/abi/guc_lic_abi.h
Signature · 1 line
2.34.1
#1 lore raw

PATCH v5 1/6 drm/xe/guc: Add log init config abi definitions

Add GuC log init config (LIC) ABI definitions.

---
 drivers/gpu/drm/xe/abi/guc_lic_abi.h | 107 +++++++++++++++++++++++++++
 1 file changed, 107 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/abi/guc_lic_abi.h
drivers/gpu/drm/xe/abi/guc_lic_abi.h new file +107 -0
new file mode 100644
index 000000000000..10b2d1829564
@@ -0,0 +1,107 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#ifndef _ABI_GUC_LIC_ABI_H_
+#define _ABI_GUC_LIC_ABI_H_
+
+#include <linux/types.h>
+
+/** enum guc_lic_type - Log Init Config TLV IDs. */
+enum guc_lic_type {
+	/**
+	 * @GUC_LIC_TYPE_GUC_SW_VERSION: GuC firmware version. Value
+	 * is a 32 bit number represented by guc_sw_version.
+	 */
+	GUC_LIC_TYPE_GUC_SW_VERSION = 0x1,
+	/**
+	 * @GUC_LIC_TYPE_GUC_DEVICE_ID: GuC device id. Value is a 32
+	 * bit.
+	 */
+	GUC_LIC_TYPE_GUC_DEVICE_ID = 0x2,
+	/**
+	 * @GUC_LIC_TYPE_TSC_FREQUENCY: GuC timestamp counter
+	 * frequency. Value is a 32 bit number representing frequency in
+	 * kHz. This timestamp is utilized in log entries, timer and
+	 * for engine utilization tracking.
+	 */
+	GUC_LIC_TYPE_TSC_FREQUENCY = 0x3,
+	/**
+	 * @GUC_LIC_TYPE_GMD_ID: HW GMD ID. Value is a 32 bit number
+	 * representing graphics, media and display HW architecture IDs.
+	 */
+	GUC_LIC_TYPE_GMD_ID = 0x4,
+	/**
+	 * @GUC_LIC_TYPE_BUILD_PLATFORM_ID: GuC build platform ID.
+	 * Value is 32 bits.
+	 */
+	GUC_LIC_TYPE_BUILD_PLATFORM_ID = 0x5,
+};
+
+/**
+ * struct guc_sw_version - This structure describes the full version of a
+ * software component.
+ */
+struct guc_sw_version {
+	/** @dw0: A 32 bits dword, contains multiple bit fields */
+	u32 dw0;
+#define GUC_SW_VERSION_PATCH_VERSION		GENMASK(7, 0)
+#define GUC_SW_VERSION_MINOR_VERSION		GENMASK(15, 8)
+#define GUC_SW_VERSION_MAJOR_VERSION		GENMASK(23, 16)
+#define GUC_SW_VERSION_BRANCH_ID		GENMASK(31, 24)
+} __packed;
+
+/**
+ * struct guc_lic_format_version - Log Init Config Structure Version.
+ * Major-Minor is not a fractional number (i.e. Ver 1.3 would be older
+ * than 1.12)
+ */
+struct guc_lic_format_version {
+	/** @dw0: A 32 bits dword, contains multiple bit fields */
+	u32 dw0;
+	/*
+	 *  Log-Init-Config structure minor version. Must be
+	 * GUC_LOG_INIT_CONFIG_FORMAT_VERSION_MINOR
+	 */
+#define GUC_LIC_FORMAT_VERSION_MINOR_VERSION		GENMASK(15, 0)
+	/*
+	 *  Log-Init-Config structure major version. Must be
+	 * GUC_LOG_INIT_CONFIG_FORMAT_VERSION_MAJOR
+	 */
+#define GUC_LIC_FORMAT_VERSION_MAJOR_VERSION		GENMASK(31, 16)
+} __packed;
+
+/**
+ * struct guc_lic - GuC lic (Log-Init-Config) structure.
+ * This is populated by the GUC at log init time and is located in the log
+ * buffer as per the Log Buffer Layout (In Memory). The array of guc log
+ * buffer states plus this structure must not exceed 4KB
+ */
+struct guc_lic {
+	/**
+	 * @magic: A magic number set by GuC to identify that this
+	 * structure contains valid information: magic = GUC_LIC_MAGIC.
+	 * Used to verify the information in this structure is valid.
+	 */
+	u32 magic;
+#define GUC_LIC_MAGIC			0x8086900D
+
+	/**
+	 * @version: The version of the this structure. Represented by
+	 * guc_lic_format_version
+	 */
+	struct guc_lic_format_version version;
+#define GUC_LIC_FORMAT_VERSION_MAJOR	1u
+#define GUC_LIC_FORMAT_VERSION_MINOR	0u
+
+	/** @dw_size: Number of Dws the `data` array contains. */
+	u32 dw_size;
+	/**
+	 * @data: Array of dwords representing a list of LIC KLVs of
+	 * type guc_klv_generic with keys represented by guc_lic_type
+	 */
+	u32 data[] __counted_by(dw_size);
+} __packed;
+
+#endif
Signature · 1 line
2.34.1
#2 lore raw

PATCH v5 2/6 drm/xe/guc: Add LFD related abi definitions

In reply to Zhanjun Dong

Add GuC LFD (Log Format Descriptors) related ABI definitions.

---
 drivers/gpu/drm/xe/abi/guc_lfd_abi.h | 282 +++++++++++++++++++++++++++
 1 file changed, 282 insertions(+)
 create mode 100644 drivers/gpu/drm/xe/abi/guc_lfd_abi.h
drivers/gpu/drm/xe/abi/guc_lfd_abi.h new file +282 -0
new file mode 100644
index 000000000000..b6888ab47e25
@@ -0,0 +1,282 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2025 Intel Corporation
+ */
+
+#ifndef _ABI_GUC_LFD_ABI_H_
+#define _ABI_GUC_LFD_ABI_H_
+
+#include <linux/types.h>
+
+#include "guc_lic_abi.h"
+
+/* Magic keys define */
+#define GUC_LFD_DRIVER_KEY_STREAMING		0x8086AAAA474C5346
+#define GUC_LFD_LOG_BUFFER_MARKER_2		0xDEADFEED
+#define GUC_LFD_CRASH_DUMP_BUFFER_MARKER_2	0x8086DEAD
+#define GUC_LFD_STATE_CAPTURE_BUFFER_MARKER_2	0xBEEFFEED
+#define GUC_LFD_LOG_BUFFER_MARKER_1V2		0xCABBA9E6
+#define GUC_LFD_STATE_CAPTURE_BUFFER_MARKER_1V2	0xCABBA9F7
+#define GUC_LFD_DATA_HEADER_MAGIC		0x8086
+
+/* The current major version of GuC-Log-File format. */
+#define GUC_LFD_FORMAT_VERSION_MAJOR		0x0001
+/* The current minor version of GuC-Log-File format. */
+#define GUC_LFD_FORMAT_VERSION_MINOR		0x0000
+
+/** enum guc_lfd_type - Log format descriptor type */
+enum guc_lfd_type {
+	/**
+	 * @GUC_LFD_TYPE_FW_REQUIRED_RANGE_START: Start of range for
+	 * required LFDs from GuC
+	 */
+	GUC_LFD_TYPE_FW_REQUIRED_RANGE_START = 0x1,
+	/**
+	 * @GUC_LFD_TYPE_FW_VERSION: GuC Firmware Version structure. LFDs
+	 * payload is guc_lfd_data_fw_version
+	 */
+	GUC_LFD_TYPE_FW_VERSION = GUC_LIC_TYPE_GUC_SW_VERSION,
+	/**
+	 * @GUC_LFD_TYPE_GUC_DEVICE_ID: GuC microcontroller device ID.
+	 * LFDs payload is guc_lfd_data_guc_devid
+	 */
+	GUC_LFD_TYPE_GUC_DEVICE_ID = GUC_LIC_TYPE_GUC_DEVICE_ID,
+	/**
+	 * @GUC_LFD_TYPE_TSC_FREQUENCY: Frequency of GuC timestamps. LFDs
+	 * payload is guc_lfd_data_tsc_freq
+	 */
+	GUC_LFD_TYPE_TSC_FREQUENCY = GUC_LIC_TYPE_TSC_FREQUENCY,
+	/**
+	 * @GUC_LFD_TYPE_GMD_ID: HW GMD ID. LFDs payload is
+	 * guc_lfd_data_gmdid
+	 */
+	GUC_LFD_TYPE_GMD_ID = GUC_LIC_TYPE_GMD_ID,
+	/**
+	 * @GUC_LFD_TYPE_BUILD_PLATFORM_ID: GuC build platform ID. LFDs
+	 * payload is guc_lfd_data_build_platformid
+	 */
+	GUC_LFD_TYPE_BUILD_PLATFORM_ID = GUC_LIC_TYPE_BUILD_PLATFORM_ID,
+	/** @GUC_LFD_TYPE_FW_REQUIRED_RANGE_END: End of this range */
+	GUC_LFD_TYPE_FW_REQUIRED_RANGE_END = 0x1FFF,
+	/**
+	 * @GUC_LFD_TYPE_FW_OPTIONAL_RANGE_START: Start of range for
+	 * required LFDs from GuC
+	 */
+	GUC_LFD_TYPE_FW_OPTIONAL_RANGE_START = 0x2000,
+	/**
+	 * @GUC_LFD_TYPE_LOG_EVENTS_BUFFER: Log-event-entries buffer. LFDs
+	 * payload is guc_lfd_data_log_events_buf
+	 */
+	GUC_LFD_TYPE_LOG_EVENTS_BUFFER = 0x2000,
+	/**
+	 * @GUC_LFD_TYPE_FW_CRASH_DUMP: GuC generated crash-dump blob.
+	 * LFDs payload is guc_lfd_data_fw_crashdump
+	 */
+	GUC_LFD_TYPE_FW_CRASH_DUMP = 0x2001,
+	/** @GUC_LFD_TYPE_FW_OPTIONAL_RANGE_END: End of this range */
+	GUC_LFD_TYPE_FW_OPTIONAL_RANGE_END = 0x3FFF,
+	/**
+	 * @GUC_LFD_TYPE_KMD_REQUIRED_RANGE_START: Start of range for
+	 * required KMD LFDs
+	 */
+	GUC_LFD_TYPE_KMD_REQUIRED_RANGE_START = 0x4000,
+	/**
+	 * @GUC_LFD_TYPE_OS_ID: An identifier for the OS. LFDs payload is
+	 * guc_lfd_data_os_id
+	 */
+	GUC_LFD_TYPE_OS_ID = 0x4000,
+	/** @GUC_LFD_TYPE_KMD_REQUIRED_RANGE_END: End of this range */
+	GUC_LFD_TYPE_KMD_REQUIRED_RANGE_END = 0x5FFF,
+	/**
+	 * @GUC_LFD_TYPE_KMD_OPTIONAL_RANGE_START: Start of range for
+	 * optional KMD LFDs
+	 */
+	GUC_LFD_TYPE_KMD_OPTIONAL_RANGE_START = 0x6000,
+	/**
+	 * @GUC_LFD_TYPE_BINARY_SCHEMA_FORMAT: Binary representation of
+	 * GuC log-events schema. LFDs TLV payload is
+	 * guc_lfd_data_binary_schema
+	 */
+	GUC_LFD_TYPE_BINARY_SCHEMA_FORMAT = 0x6000,
+	/**
+	 * @GUC_LFD_TYPE_HOST_COMMENT: ASCII string containing comments
+	 * from the host/KMD. LFDs TLV payload is
+	 * guc_lfd_data_host_comment
+	 */
+	GUC_LFD_TYPE_HOST_COMMENT = 0x6001,
+	/** @GUC_LFD_TYPE_KMD_OPTIONAL_RANGE_END: End of this range */
+	GUC_LFD_TYPE_KMD_OPTIONAL_RANGE_END = 0x7FFF,
+	/** @GUC_LFD_TYPE_RESERVED_RANGE_START: Start of reserved range */
+	GUC_LFD_TYPE_RESERVED_RANGE_START = 0x8000,
+	/** @GUC_LFD_TYPE_RESERVED_RANGE_END: End of this range */
+	GUC_LFD_TYPE_RESERVED_RANGE_END = 0xFFFF,
+};
+
+/** enum guc_lfd_os_type - OS Type LFD-ID */
+enum guc_lfd_os_type {
+	/** @GUC_LFD_OS_TYPE_OSID_WIN: Windows OS */
+	GUC_LFD_OS_TYPE_OSID_WIN = 0x1,
+	/** @GUC_LFD_OS_TYPE_OSID_LIN: Linux OS */
+	GUC_LFD_OS_TYPE_OSID_LIN = 0x2,
+	/** @GUC_LFD_OS_TYPE_OSID_VMW: VMWare OS */
+	GUC_LFD_OS_TYPE_OSID_VMW = 0x3,
+	/** @GUC_LFD_OS_TYPE_OSID_OTHER: Other */
+	GUC_LFD_OS_TYPE_OSID_OTHER = 0x4,
+};
+
+/**
+ * struct guc_lfd_data - Log format descriptor (LFD).
+ * A type of KLV with custom field-sizes + magic numbers.
+ */
+struct guc_lfd_data {
+	/** @dw0: A 32 bits dword, contains multiple bit fields */
+	u32 dw0;
+	/*
+	 * Expected value: GUC_LFD_DATA_HEADER_MAGIC.
+	 * Helpful in detecting file errors.
+	 */
+#define GUC_LFD_DATA_MAGIC		GENMASK(15, 0)
+	/*
+	 * File descriptor type (the 'T' in TLV) is used to identify how
+	 * to interpret `data` below. For the range of types, see
+	 * guc_lfd_type
+	 */
+#define GUC_LFD_DATA_DESC_TYPE		GENMASK(31, 16)
+	/** @dw_size: Number of dwords the `data` field contains. */
+	u32 dw_size;
+	/** @data: Data defined by File descriptor type. */
+	u32 data[] __counted_by(dw_size);
+} __packed;
+
+/**
+ * struct guc_lfd_version - GuC Log File Format Version.
+ * Major-Minor is not a fractional number (i.e. Ver 1.3 would be older
+ * than 1.12)
+ */
+struct guc_lfd_version {
+	/** @dw0: A 32 bits dword, contains multiple bit fields */
+	u32 dw0;
+	/*
+	 * Guc-Log-File Format minor version. Must be
+	 * GUC_LOG_FILE_FORMAT_VERSION_MINOR
+	 */
+#define GUC_LFD_VERSION_MINOR	GENMASK(15, 0)
+	/*
+	 * Guc-Log-File Format major version. Must be
+	 * GUC_LOG_FILE_FORMAT_VERSION_MAJOR
+	 */
+#define GUC_LFD_VERSION_MAJOR	GENMASK(31, 16)
+} __packed;
+
+/**
+ * struct guc_lfd_data_guc_devid - GuC Device ID.
+ * This is mandatory fw LFD data
+ */
+struct guc_lfd_data_guc_devid {
+	/**
+	 * @guc_devid: GuC microcontroller device ID defined as described
+	 * in GUC_LIC_TYPE_GUC_DEVICE_ID
+	 */
+	u32 guc_devid;
+} __packed;
+
+/**
+ * struct guc_lfd_data_tsc_freq - GuC TSC Fequency.
+ * This is mandatory fw LFD data
+ */
+struct guc_lfd_data_tsc_freq {
+	/**
+	 * @tsc_freq: GuC timestamp counter frequency as described in
+	 * GUC_LIC_TYPE_TSC_FREQUENCY
+	 */
+	u32 tsc_freq;
+} __packed;
+
+/** struct guc_lfd_data_gmdid - GMD ID. */
+struct guc_lfd_data_gmdid {
+	/** @gmd_id: GMD ID as described in GUC_LIC_TYPE_GMD_ID */
+	u32 gmd_id;
+} __packed;
+
+/** struct guc_lfd_data_build_platformid - GuC build platform ID. */
+struct guc_lfd_data_build_platformid {
+	/**
+	 * @platform_build_id: GuC build platform ID as described in
+	 * GUC_LIC_TYPE_BUILD_PLATFORM_ID
+	 */
+	u32 platform_build_id;
+} __packed;
+
+/**
+ * struct guc_lfd_data_log_events_buf - GuC Log Events Buffer.
+ * This is optional fw LFD data
+ */
+struct guc_lfd_data_log_events_buf {
+	/**
+	 * @log_events_format_version: version of GuC log format of buffer
+	 */
+	u32 log_events_format_version;
+	/**
+	 * @log_format_buf: If `log_format_version` == 1, array of
+	 * guc_log_format_version_1. If `log_format_version` == 2, array
+	 * of guc_log_format_version_2. Dword size determined by
+	 * guc_logfile_lfd.`desc_dw_size` - 1
+	 */
+	u32 log_format_buf[];
+} __packed;
+
+/**
+ * struct guc_lfd_data_os_info - OS Version Information.
+ * This is mandatory host LFD data
+ */
+struct guc_lfd_data_os_info {
+	/**
+	 * @os_id: enum values to identify the OS brand (1=Windows,
+	 * 2=Linux, etc..). See guc_lfd_os_type for the range of types
+	 */
+	u32 os_id;
+	/**
+	 * @build_version: ASCII string containing OS build version
+	 * information based on os_id. String is padded with null
+	 * characters to ensure its DWORD aligned. Dword size determined
+	 * by guc_logfile_lfd.`desc_dw_size` - 1
+	 */
+	char build_version[];
+} __packed;
+
+/**
+ * struct guc_lfd_data_fw_version - GuC FW Version.
+ * This is mandatory fw LFD data
+ */
+struct guc_lfd_data_fw_version {
+	/**
+	 * @guc_sw_version: The full version of the GuC microkernel that
+	 * generated the logs as described in
+	 * GUC_LIC_TYPE_GUC_SW_VERSION.
+	 */
+	struct guc_sw_version guc_sw_version;
+} __packed;
+
+/**
+ * struct guc_logfile_header - Header of GuC Log Streaming-LFD-File Format.
+ * This structure encapsulates the layout of the guc-log-file format
+ */
+struct guc_lfd_file_header {
+	/**
+	 * @magic: A magic number set by producer of a GuC log file to
+	 * identify that file is a valid guc-log-file containing a stream
+	 * of LFDs: Expected value: GUC_LFD_DRIVER_KEY_STREAMING
+	 */
+	u64 magic;
+	/**
+	 * @version: Version of this file format layout as per
+	 * guc_lfd_version
+	 */
+	struct guc_lfd_version version;
+	/**
+	 * @lfd_stream: A stream of one or more guc_lfd_data LFD data
+	 */
+	struct guc_lfd_data lfd_stream;
+} __packed;
+
+#endif
Signature · 1 line
2.34.1
#3 lore raw

PATCH v5 3/6 drm/xe/guc: Add new debugfs entry for lfd format output

In reply to Zhanjun Dong

Add new debugfs entry "guc_log_lfd", prepared for output guc log in LFD(Log Format Descriptors) format.

---
 drivers/gpu/drm/xe/xe_guc_debugfs.c |  7 +++++++
 drivers/gpu/drm/xe/xe_guc_log.c     | 32 +++++++++++++++++++++++++++++
 drivers/gpu/drm/xe/xe_guc_log.h     |  1 +
 3 files changed, 40 insertions(+)
drivers/gpu/drm/xe/xe_guc_debugfs.c +7 -0
index 0b102ab46c4d..6cbc4240a3bd 100644
@@ -85,6 +85,12 @@ static int guc_log(struct xe_guc *guc, struct drm_printer *p)
 	return 0;
 }
 
+static int guc_log_lfd(struct xe_guc *guc, struct drm_printer *p)
+{
+	xe_guc_log_print_lfd(&guc->log, p);
+	return 0;
+}
+
 static int guc_log_dmesg(struct xe_guc *guc, struct drm_printer *p)
 {
 	xe_guc_log_print_dmesg(&guc->log);
@@ -121,6 +127,7 @@ static const struct drm_info_list slpc_debugfs_list[] = {
 /* everything else should be added here */
 static const struct drm_info_list pf_only_debugfs_list[] = {
 	{ "guc_log", .show = guc_debugfs_show, .data = guc_log },
+	{ "guc_log_lfd", .show = guc_debugfs_show, .data = guc_log_lfd },
 	{ "guc_log_dmesg", .show = guc_debugfs_show, .data = guc_log_dmesg },
 };
 
drivers/gpu/drm/xe/xe_guc_log.c +32 -0
index c01ccb35dc75..d2256773aaf3 100644
@@ -9,6 +9,7 @@
 
 #include <drm/drm_managed.h>
 
+#include "abi/guc_lfd_abi.h"
 #include "regs/xe_guc_regs.h"
 #include "xe_bo.h"
 #include "xe_devcoredump.h"
@@ -19,6 +20,12 @@
 #include "xe_mmio.h"
 #include "xe_module.h"
 
+static const struct guc_lfd_file_header default_guc_lfd_file_header = {
+	.magic = GUC_LFD_DRIVER_KEY_STREAMING,
+	.version.dw0 = FIELD_PREP_CONST(GUC_LFD_VERSION_MINOR, GUC_LFD_FORMAT_VERSION_MINOR) |
+		       FIELD_PREP_CONST(GUC_LFD_VERSION_MAJOR, GUC_LFD_FORMAT_VERSION_MAJOR)
+};
+
 static struct xe_guc *
 log_to_guc(struct xe_guc_log *log)
 {
@@ -216,6 +223,17 @@ void xe_guc_log_snapshot_print(struct xe_guc_log_snapshot *snapshot, struct drm_
 	}
 }
 
+static void
+xe_guc_log_snapshot_print_lfd(struct xe_guc_log_snapshot *snapshot, struct drm_printer *p)
+{
+	if (!snapshot || !snapshot->size)
+		return;
+
+	/* Output LFD file header */
+	xe_print_blob_ascii85(p, "[LOG].data", 0, &default_guc_lfd_file_header, 0,
+			      offsetof(struct guc_lfd_file_header, lfd_stream));
+}
+
 /**
  * xe_guc_log_print_dmesg - dump a copy of the GuC log to dmesg
  * @log: GuC log structure
@@ -251,6 +269,20 @@ void xe_guc_log_print(struct xe_guc_log *log, struct drm_printer *p)
 	xe_guc_log_snapshot_free(snapshot);
 }
 
+/**
+ * xe_guc_log_print_lfd - dump a copy of the GuC log to some useful location
+ * @log: GuC log structure
+ * @p: the printer object to output to
+ */
+void xe_guc_log_print_lfd(struct xe_guc_log *log, struct drm_printer *p)
+{
+	struct xe_guc_log_snapshot *snapshot;
+
+	snapshot = xe_guc_log_snapshot_capture(log, false);
+	xe_guc_log_snapshot_print_lfd(snapshot, p);
+	xe_guc_log_snapshot_free(snapshot);
+}
+
 int xe_guc_log_init(struct xe_guc_log *log)
 {
 	struct xe_device *xe = log_to_xe(log);
drivers/gpu/drm/xe/xe_guc_log.h +1 -0
index f1e2b0be90a9..0f6299886010 100644
@@ -40,6 +40,7 @@ struct xe_device;
 
 int xe_guc_log_init(struct xe_guc_log *log);
 void xe_guc_log_print(struct xe_guc_log *log, struct drm_printer *p);
+void xe_guc_log_print_lfd(struct xe_guc_log *log, struct drm_printer *p);
 void xe_guc_log_print_dmesg(struct xe_guc_log *log);
 struct xe_guc_log_snapshot *xe_guc_log_snapshot_capture(struct xe_guc_log *log, bool atomic);
 void xe_guc_log_snapshot_print(struct xe_guc_log_snapshot *snapshot, struct drm_printer *p);
Signature · 1 line
2.34.1
#4 lore raw

PATCH v5 4/6 drm/xe/guc: Add GuC log init config in LFD format

In reply to Zhanjun Dong

Add support to output GuC log init config (LIC) in LFD format.

---
 drivers/gpu/drm/xe/xe_guc_log.c | 204 ++++++++++++++++++++++++++++++++
 1 file changed, 204 insertions(+)
drivers/gpu/drm/xe/xe_guc_log.c +204 -0
index d2256773aaf3..2258d73d9c24 100644
@@ -7,6 +7,7 @@
 
 #include <linux/fault-inject.h>
 
+#include <linux/utsname.h>
 #include <drm/drm_managed.h>
 
 #include "abi/guc_lfd_abi.h"
@@ -20,12 +21,67 @@
 #include "xe_mmio.h"
 #include "xe_module.h"
 
+/* LFD supported LIC type range */
+#define GUC_LOG_LIC_TYPE_FIRST	(GUC_LIC_TYPE_GUC_SW_VERSION)
+#define GUC_LOG_LIC_TYPE_LAST	(GUC_LIC_TYPE_BUILD_PLATFORM_ID)
+
+#define GUC_LOG_BUFFER_STATE_HEADER_LENGTH		4096
+#define GUC_LOG_BUFFER_STATE_HEADER_ENTRY_LOG		0
+#define GUC_LOG_BUFFER_STATE_HEADER_ENTRY_CRASH		1
+#define GUC_LOG_BUFFER_STATE_HEADER_ENTRY_CAPTURE	2
+#define GUC_LOG_BUFFER_STATE_HEADER_ENTRY_INIT		3
+#define GUC_LOG_BUFFER_STATE_HEADER_ENTRY_COUNT		4
+
+#define GUC_LFD_BUFFER_SIZE	SZ_1K
+
+struct guc_log_buffer_entry_list {
+	u32 offset;
+	u32 rd_ptr;
+	u32 wr_ptr;
+	u32 buf_size;
+};
+
+struct guc_log_init_config_save {
+	u32 version;
+	/*
+	 * Array of init config KLVs.
+	 * Range from GUC_LOG_LIC_TYPE_FIRST to GUC_LOG_LIC_TYPE_LAST
+	 */
+	u32 KLV[GUC_LOG_LIC_TYPE_LAST - GUC_LOG_LIC_TYPE_FIRST + 1];
+	struct guc_log_buffer_entry_list entry[GUC_LOG_BUFFER_STATE_HEADER_ENTRY_COUNT];
+};
+
+static const struct guc_lfd_data default_guc_lfd_data = {
+	.dw0 = FIELD_PREP_CONST(GUC_LFD_DATA_MAGIC, GUC_LFD_DATA_HEADER_MAGIC)
+};
+
 static const struct guc_lfd_file_header default_guc_lfd_file_header = {
 	.magic = GUC_LFD_DRIVER_KEY_STREAMING,
 	.version.dw0 = FIELD_PREP_CONST(GUC_LFD_VERSION_MINOR, GUC_LFD_FORMAT_VERSION_MINOR) |
 		       FIELD_PREP_CONST(GUC_LFD_VERSION_MAJOR, GUC_LFD_FORMAT_VERSION_MAJOR)
 };
 
+static struct guc_log_buffer_entry_markers {
+	u32 key[2];
+} const entry_markers[4] = {
+	{{
+		GUC_LFD_LOG_BUFFER_MARKER_1V2,
+		GUC_LFD_LOG_BUFFER_MARKER_2
+	}},
+	{{
+		GUC_LFD_LOG_BUFFER_MARKER_1V2,
+		GUC_LFD_CRASH_DUMP_BUFFER_MARKER_2
+	}},
+	{{
+		GUC_LFD_STATE_CAPTURE_BUFFER_MARKER_1V2,
+		GUC_LFD_STATE_CAPTURE_BUFFER_MARKER_2
+	}},
+	{{
+		GUC_LIC_MAGIC,
+		((GUC_LIC_FORMAT_VERSION_MAJOR << 16) | GUC_LIC_FORMAT_VERSION_MINOR)
+	}}
+};
+
 static struct xe_guc *
 log_to_guc(struct xe_guc_log *log)
 {
@@ -223,15 +279,163 @@ void xe_guc_log_snapshot_print(struct xe_guc_log_snapshot *snapshot, struct drm_
 	}
 }
 
+static int xe_guc_log_add_lfd_header(void *buf, int buf_size)
+{
+	int len = sizeof(default_guc_lfd_data);
+
+	memcpy(buf, &default_guc_lfd_data, len);
+	return len;
+}
+
+static int xe_guc_log_add_payload(void *buf, int buf_size, u32 data_len, void *data)
+{
+	struct guc_lfd_data *lfd = buf;
+
+	/* make length DW aligned */
+	lfd->dw_size = DIV_ROUND_UP(data_len, sizeof(u32));
+	memcpy(lfd->data, data, data_len);
+	return lfd->dw_size * sizeof(u32);
+}
+
+static int xe_guc_log_add_typed_payload(void *buf, int buf_size, u32 type,
+					u32 data_len, void *data)
+{
+	struct guc_lfd_data *lfd = buf;
+	int index;
+
+	index = xe_guc_log_add_lfd_header(buf, buf_size);
+	lfd->dw0 |= FIELD_PREP(GUC_LFD_DATA_DESC_TYPE, type);
+	index += xe_guc_log_add_payload(buf, buf_size, data_len, data);
+
+	return index;
+}
+
+static inline int lic_type_to_KLV_index(u32 lic_type)
+{
+	XE_WARN_ON(lic_type < GUC_LOG_LIC_TYPE_FIRST || lic_type > GUC_LOG_LIC_TYPE_LAST);
+
+	return lic_type - GUC_LOG_LIC_TYPE_FIRST;
+}
+
+static int xe_guc_log_add_klv(void *buf, int size, u32 lic_type,
+			      struct guc_log_init_config_save *config)
+{
+	int klv_index = lic_type_to_KLV_index(lic_type);
+
+	return xe_guc_log_add_typed_payload(buf, size, lic_type, sizeof(u32),
+					    &config->KLV[klv_index]);
+}
+
+static int xe_guc_log_add_os_id(void *buf, int buf_size, u32 id)
+{
+	struct guc_lfd_data *lfd = buf;
+	struct guc_lfd_data_os_info *os_id;
+	char *version;
+	int info_len;
+
+	os_id = (void *)lfd->data;
+	os_id->os_id = id;
+
+	version = init_utsname()->release;
+	info_len = strnlen(version, buf_size) + 1;
+
+	if (buf_size < sizeof(struct guc_lfd_data) + info_len)
+		return -ENOMEM;
+
+	strscpy(os_id->build_version, version, info_len);
+	return xe_guc_log_add_typed_payload(buf, buf_size, GUC_LFD_TYPE_OS_ID,
+					    info_len + sizeof(*os_id), os_id);
+}
+
+static void xe_guc_log_loop_log_init(struct guc_log_init_config *init,
+				     struct guc_log_init_config_save *config)
+{
+	struct guc_klv_generic_dw_t *p = (void *)init->data;
+	int i;
+
+	for (i = 0; i < init->dw_size;) {
+		int klv_len = FIELD_GET(GUC_KLV_0_LEN, p->kl) + 1;
+		int key = FIELD_GET(GUC_KLV_0_KEY, p->kl);
+
+		if (key < GUC_LOG_LIC_TYPE_FIRST || key > GUC_LOG_LIC_TYPE_LAST)
+			break;
+		config->KLV[lic_type_to_KLV_index(key)] = p->value;
+		i += klv_len;
+		p = (void *)((u32 *)p + klv_len);
+	}
+}
+
+static void xe_guc_log_load_lic(void *guc_log, struct guc_log_init_config_save *config)
+{
+	u32 offset = GUC_LOG_BUFFER_STATE_HEADER_LENGTH;
+	struct guc_log_buffer_state *p = guc_log;
+	int i = 0;
+
+	config->version = p->version;
+	while (p) {
+		for (i = 0; i < GUC_LOG_BUFFER_STATE_HEADER_ENTRY_COUNT; i++) {
+			if (p->marker[0] == entry_markers[i].key[0] &&
+			    p->marker[1] == entry_markers[i].key[1]) {
+				config->entry[i].offset = offset;
+				config->entry[i].rd_ptr = p->read_ptr;
+				config->entry[i].wr_ptr = p->write_ptr;
+				config->entry[i].buf_size = p->size;
+
+				if (i != GUC_LOG_BUFFER_STATE_HEADER_ENTRY_INIT) {
+					offset += p->size;
+					p++;
+				} else {
+					/* Load log init config */
+					xe_guc_log_loop_log_init((void *)p, config);
+
+					/* Init config is the last */
+					return;
+				}
+			}
+		}
+		if (i >= GUC_LOG_BUFFER_STATE_HEADER_ENTRY_COUNT)
+			break;
+	}
+}
+
+static int
+xe_guc_log_output_lfd_init(struct drm_printer *p, struct xe_guc_log_snapshot *snapshot,
+			   struct guc_log_init_config_save *config)
+{
+	int type, len;
+	size_t size = 0;
+	char buf[GUC_LFD_BUFFER_SIZE] = {0};
+
+	/* FW required types */
+	for (type = GUC_LOG_LIC_TYPE_FIRST; type <= GUC_LOG_LIC_TYPE_LAST; type++)
+		size += xe_guc_log_add_klv(&buf[size], GUC_LFD_BUFFER_SIZE - size, type, config);
+
+	/* KMD required type(s) */
+	len = xe_guc_log_add_os_id(&buf[size], GUC_LFD_BUFFER_SIZE - size,
+				   GUC_LFD_OS_TYPE_OSID_LIN);
+	if (len < 0)
+		return len;
+	size += len;
+
+	xe_print_blob_ascii85(p, NULL, 0, buf, 0, size);
+	return size;
+}
+
 static void
 xe_guc_log_snapshot_print_lfd(struct xe_guc_log_snapshot *snapshot, struct drm_printer *p)
 {
+	struct guc_log_init_config_save config;
+
 	if (!snapshot || !snapshot->size)
 		return;
 
 	/* Output LFD file header */
 	xe_print_blob_ascii85(p, "[LOG].data", 0, &default_guc_lfd_file_header, 0,
 			      offsetof(struct guc_lfd_file_header, lfd_stream));
+
+	/* Output LFD stream */
+	xe_guc_log_load_lic(snapshot->copy[0], &config);
+	xe_guc_log_output_lfd_init(p, snapshot, &config);
 }
 
 /**
Signature · 1 line
2.34.1
#5 lore raw

PATCH v5 5/6 drm/xe/guc: Add GuC log event buffer output in LFD format

In reply to Zhanjun Dong

Add GuC log event buffer output in LFD format.

---
 drivers/gpu/drm/xe/xe_guc_log.c | 88 ++++++++++++++++++++++++++++++++-
 1 file changed, 87 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_guc_log.c +87 -1
index 2258d73d9c24..e4ee67a9aa28 100644
@@ -421,10 +421,92 @@ xe_guc_log_output_lfd_init(struct drm_printer *p, struct xe_guc_log_snapshot *sn
 	return size;
 }
 
+static void
+xe_guc_log_print_over_chunks(struct drm_printer *p, struct xe_guc_log_snapshot *snapshot,
+			     u32 from, u32 to)
+{
+	int chunk_from = from % GUC_LOG_CHUNK_SIZE;
+	int chunk_id = from / GUC_LOG_CHUNK_SIZE;
+	int to_chunk_id = to / GUC_LOG_CHUNK_SIZE;
+	int chunk_to = to % GUC_LOG_CHUNK_SIZE;
+	int pos = from;
+
+	do {
+		size_t size = (to_chunk_id > chunk_id ? GUC_LOG_CHUNK_SIZE : chunk_to) - chunk_from;
+
+		xe_print_blob_ascii85(p, NULL, 0, snapshot->copy[chunk_id], chunk_from, size);
+		pos += size;
+		chunk_id++;
+		chunk_from = 0;
+	} while (pos < to);
+}
+
+static void
+xe_guc_log_lfd_print_from_chunks(struct drm_printer *p, struct xe_guc_log_snapshot *snapshot,
+				 struct guc_log_buffer_entry_list *entry)
+{
+	/* Output data from guc log chunks directly */
+	if (entry->rd_ptr < entry->wr_ptr) {
+		xe_guc_log_print_over_chunks(p, snapshot,
+					     entry->offset + entry->rd_ptr,
+					     entry->offset + entry->wr_ptr);
+	} else {
+		/* print from rd to buf end 1st */
+		xe_guc_log_print_over_chunks(p, snapshot,
+					     entry->offset + entry->rd_ptr,
+					     entry->offset + entry->buf_size);
+
+		/* print from buf start to wr */
+		xe_guc_log_print_over_chunks(p, snapshot, entry->offset,
+					     entry->offset + entry->wr_ptr);
+	}
+}
+
+static inline int
+xe_guc_log_add_log_event(struct drm_printer *p, struct xe_guc_log_snapshot *snapshot,
+			 struct guc_log_init_config_save *config)
+{
+	size_t size;
+	u32 data_len;
+	struct guc_lfd_data *lfd;
+	struct guc_log_buffer_entry_list *entry;
+	struct guc_lfd_data_log_events_buf *events_buf;
+	char buf[GUC_LFD_BUFFER_SIZE] = {0};
+
+	lfd = (void *)buf;
+	entry = &config->entry[GUC_LOG_BUFFER_STATE_HEADER_ENTRY_LOG];
+
+	/* Skip empty log */
+	if (entry->rd_ptr == entry->wr_ptr)
+		return 0;
+
+	size = xe_guc_log_add_lfd_header(buf, GUC_LFD_BUFFER_SIZE);
+	lfd->dw0 |= FIELD_PREP(GUC_LFD_DATA_DESC_TYPE, GUC_LFD_TYPE_LOG_EVENTS_BUFFER);
+	events_buf = (void *)&lfd->data;
+	events_buf->log_events_format_version = config->version;
+
+	/* Adjust to log_format_buf */
+	data_len = offsetof(struct guc_lfd_data_log_events_buf, log_format_buf);
+	size += data_len;
+
+	/* Calculate data length */
+	data_len += (entry->wr_ptr + entry->buf_size - entry->rd_ptr) % entry->buf_size;
+	/* make length u32 aligned */
+	lfd->dw_size = DIV_ROUND_UP(data_len, sizeof(u32));
+
+	/* Output GUC_LFD_TYPE_LOG_EVENTS_BUFFER header */
+	xe_print_blob_ascii85(p, NULL, 0, buf, 0, size);
+	xe_guc_log_lfd_print_from_chunks(p, snapshot, entry);
+
+	/* log event buffer content did not use buf, exclude from size count */
+	return size;
+}
+
 static void
 xe_guc_log_snapshot_print_lfd(struct xe_guc_log_snapshot *snapshot, struct drm_printer *p)
 {
 	struct guc_log_init_config_save config;
+	size_t size;
 
 	if (!snapshot || !snapshot->size)
 		return;
@@ -435,7 +517,11 @@ xe_guc_log_snapshot_print_lfd(struct xe_guc_log_snapshot *snapshot, struct drm_p
 
 	/* Output LFD stream */
 	xe_guc_log_load_lic(snapshot->copy[0], &config);
-	xe_guc_log_output_lfd_init(p, snapshot, &config);
+	size = xe_guc_log_output_lfd_init(p, snapshot, &config);
+	if (size < 0)
+		return;
+
+	xe_guc_log_add_log_event(p, snapshot, &config);
 }
 
 /**
Signature · 1 line
2.34.1
#6 lore raw

PATCH v5 6/6 drm/xe/guc: Only add GuC crash dump if available

In reply to Zhanjun Dong

Add GuC crash dump data empty check. LFD will only include crash dump section when data is not empty.

---
 drivers/gpu/drm/xe/xe_guc_log.c | 60 +++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
drivers/gpu/drm/xe/xe_guc_log.c +60 -0
index e4ee67a9aa28..6331282a438a 100644
@@ -502,6 +502,65 @@ 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_log_init_config_save *config)
+{
+	struct guc_log_buffer_entry_list *entry;
+	int chunk_from, chunk_id, to_chunk_id;
+	int pos, from, to;
+	size_t size = 0;
+	char buf[GUC_LFD_BUFFER_SIZE] = {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_lfd_data *lfd = (void *)buf;
+
+		size = xe_guc_log_add_lfd_header(buf, GUC_LFD_BUFFER_SIZE);
+		lfd->dw0 |= FIELD_PREP(GUC_LFD_DATA_DESC_TYPE, GUC_LFD_TYPE_FW_CRASH_DUMP);
+		/* Calculate data length */
+		lfd->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);
+
+		/* 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 size;
+}
+
 static void
 xe_guc_log_snapshot_print_lfd(struct xe_guc_log_snapshot *snapshot, struct drm_printer *p)
 {
@@ -522,6 +581,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);
 }
 
 /**
Signature · 1 line
2.34.1
#7 lore raw

✗ CI.checkpatch: warning for drm/xe/guc: Add LFD format output for guc log (rev5)

In reply to Zhanjun Dong
== Series Details ==

== Series Details ==

Series: drm/xe/guc: Add LFD format output for guc log (rev5)
URL : https://patchwork.freedesktop.org/series/146541/
State : warning

== Summary ==

+ KERNEL=/kernel
+ git clone https://gitlab.freedesktop.org/drm/maintainer-tools mt Cloning into 'mt'...
warning: redirecting to https://gitlab.freedesktop.org/drm/maintainer-tools.git/
+ git -C mt rev-list -n1 origin/master 63535c743231a7497a612c53f6edbb8a7d14412d
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit a4e308a48d46bfe2d3a04a09e453372d3e43b30a

Author: Zhanjun Dong <[email protected]>
Date:   Fri Jul 18 19:12:23 2025 -0400

drm/xe/guc: Only add GuC crash dump if available

Add GuC crash dump data empty check. LFD will only include crash dump section when data is not empty.

+ /mt/dim checkpatch 17cc1a17481ab5481b6cd9f01eb073a254b7a3b2 drm-intel a57bf650c2e4 drm/xe/guc: Add log init config abi definitions
-:11: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #11:
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 107 lines checked
e23777b7feac drm/xe/guc: Add LFD related abi definitions
-:11: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #11:
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 282 lines checked 1c1ec3af21ab drm/xe/guc: Add new debugfs entry for lfd format output 8d81b9272da8 drm/xe/guc: Add GuC log init config in LFD format 71dc7426a182 drm/xe/guc: Add GuC log event buffer output in LFD format a4e308a48d46 drm/xe/guc: Only add GuC crash dump if available

#8 lore raw

✗ CI.KUnit: failure for drm/xe/guc: Add LFD format output for guc log (rev5)

In reply to Zhanjun Dong
== Series Details ==

== Series Details ==

Series: drm/xe/guc: Add LFD format output for guc log (rev5)
URL : https://patchwork.freedesktop.org/series/146541/
State : failure

== Summary ==

+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig
ERROR:root:../drivers/gpu/drm/xe/xe_guc_log.c:350:45: warning: ‘struct guc_log_init_config’ declared inside parameter list will not be visible outside of this definition or declaration
350 | static void xe_guc_log_loop_log_init(struct guc_log_init_config *init,

      |                                             ^~~~~~~~~~~~~~~~~~~

../drivers/gpu/drm/xe/xe_guc_log.c: In function ‘xe_guc_log_loop_log_init’:
../drivers/gpu/drm/xe/xe_guc_log.c:353:54: error: invalid use of undefined type ‘struct guc_log_init_config’
353 | struct guc_klv_generic_dw_t *p = (void *)init->data;
| ^~
../drivers/gpu/drm/xe/xe_guc_log.c:356:29: error: invalid use of undefined type ‘struct guc_log_init_config’
356 | for (i = 0; i < init->dw_size;) {
| ^~
make[7]: *** [../scripts/Makefile.build:287: drivers/gpu/drm/xe/xe_guc_log.o] Error 1 make[7]: *** Waiting for unfinished jobs....
make[6]: *** [../scripts/Makefile.build:554: drivers/gpu/drm/xe] Error 2
make[6]: *** Waiting for unfinished jobs....
make[5]: *** [../scripts/Makefile.build:554: drivers/gpu/drm] Error 2
make[4]: *** [../scripts/Makefile.build:554: drivers/gpu] Error 2
make[3]: *** [../scripts/Makefile.build:554: drivers] Error 2
make[2]: *** [/kernel/Makefile:2003: .] Error 2
make[1]: *** [/kernel/Makefile:248: __sub-make] Error 2
make: *** [Makefile:248: __sub-make] Error 2

[23:37:10] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:

$ make ARCH=um O=.kunit olddefconfig
[23:37:14] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make all compile_commands.json scripts_gdb ARCH=um O=.kunit --jobs=48
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel