Skip to contentSkip to conversation

tests/intel/xe_err_injection: Add Local Uncorrectable Error Injection Through LSC Storage

PATCH New Soham Purkait 1 participant 3 messages Aug 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover tests/intel/xe_err_injection: Add Local Uncorrectable Error Injection Through LSC Storage

Adds coverage for local uncorrectable unicast LSC (Load/Store Cache) storage errors.

The test injects into the LSC storage array, drives a heavy LSC workload on all compute engines to trigger recovery, and validates error counter increment. A post-recovery workload run confirms the error counter stays stable.

Ravi Kishore Koppuravuri (1):
From: Ravi Kishore Koppuravuri <[email protected]> DO
NOT REVIEW. COMPILATION ONLY.

Soham Purkait (1):
tests/intel/xe_err_injection: Add test for local Uncorrectable Error
Injection through LSC Storage

 include/drm-uapi/drm_ras.h     |  67 +++
 lib/igt_drm_netlink.c          | 565 +++++++++++++++++++++++
 lib/igt_drm_netlink.h          |  48 ++
 lib/meson.build                |   9 +
 tests/intel/xe_err_injection.c | 810 +++++++++++++++++++++++++++++++++
 tests/intel/xe_err_injection.h |  39 ++
 tests/meson.build              |   1 +
 7 files changed, 1539 insertions(+)
 create mode 100644 include/drm-uapi/drm_ras.h
 create mode 100644 lib/igt_drm_netlink.c
 create mode 100644 lib/igt_drm_netlink.h
 create mode 100644 tests/intel/xe_err_injection.c
 create mode 100644 tests/intel/xe_err_injection.h
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 From: Ravi Kishore Koppuravuri <[email protected]> DO NOT REVIEW. COMPILATION ONLY.

From: Ravi Kishore Koppuravuri <[email protected]>

This patch is from https://patchwork.freedesktop.org/series/171275
Added only for Compilation.

---
 include/drm-uapi/drm_ras.h     |  67 ++++
 lib/igt_drm_netlink.c          | 565 ++++++++++++++++++++++++++++++
 lib/igt_drm_netlink.h          |  48 +++
 lib/meson.build                |   9 +
 tests/intel/xe_err_injection.c | 623 +++++++++++++++++++++++++++++++++
 tests/intel/xe_err_injection.h |  28 ++
 tests/meson.build              |   1 +
 7 files changed, 1341 insertions(+)
 create mode 100644 include/drm-uapi/drm_ras.h
 create mode 100644 lib/igt_drm_netlink.c
 create mode 100644 lib/igt_drm_netlink.h
 create mode 100644 tests/intel/xe_err_injection.c
 create mode 100644 tests/intel/xe_err_injection.h
include/drm-uapi/drm_ras.h new file +67 -0
new file mode 100644
index 000000000..099978187
@@ -0,0 +1,67 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef _UAPI_LINUX_DRM_RAS_H
+#define _UAPI_LINUX_DRM_RAS_H
+
+#define DRM_RAS_FAMILY_NAME	"drm-ras"
+#define DRM_RAS_FAMILY_VERSION	1
+
+/*
+ * Type of the node. Currently, only error-counter nodes are supported, which
+ * expose reliability counters for a hardware/software component.
+ */
+enum drm_ras_node_type {
+	DRM_RAS_NODE_TYPE_ERROR_COUNTER = 1,
+};
+
+enum {
+	DRM_RAS_A_NODE_ATTRS_NODE_ID = 1,
+	DRM_RAS_A_NODE_ATTRS_DEVICE_NAME,
+	DRM_RAS_A_NODE_ATTRS_NODE_NAME,
+	DRM_RAS_A_NODE_ATTRS_NODE_TYPE,
+
+	__DRM_RAS_A_NODE_ATTRS_MAX,
+	DRM_RAS_A_NODE_ATTRS_MAX = (__DRM_RAS_A_NODE_ATTRS_MAX - 1)
+};
+
+enum {
+	DRM_RAS_A_ERROR_COUNTER_ATTRS_NODE_ID = 1,
+	DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID,
+	DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_NAME,
+	DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_VALUE,
+	DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_THRESHOLD,
+
+	__DRM_RAS_A_ERROR_COUNTER_ATTRS_MAX,
+	DRM_RAS_A_ERROR_COUNTER_ATTRS_MAX = (__DRM_RAS_A_ERROR_COUNTER_ATTRS_MAX - 1)
+};
+
+enum {
+	DRM_RAS_A_ERROR_EVENT_ATTRS_DEVICE_NAME = 1,
+	DRM_RAS_A_ERROR_EVENT_ATTRS_NODE_ID,
+	DRM_RAS_A_ERROR_EVENT_ATTRS_NODE_NAME,
+	DRM_RAS_A_ERROR_EVENT_ATTRS_ERROR_ID,
+	DRM_RAS_A_ERROR_EVENT_ATTRS_ERROR_NAME,
+	DRM_RAS_A_ERROR_EVENT_ATTRS_ERROR_VALUE,
+
+	__DRM_RAS_A_ERROR_EVENT_ATTRS_MAX,
+	DRM_RAS_A_ERROR_EVENT_ATTRS_MAX = (__DRM_RAS_A_ERROR_EVENT_ATTRS_MAX - 1)
+};
+
+enum {
+	DRM_RAS_CMD_LIST_NODES = 1,
+	DRM_RAS_CMD_GET_ERROR_COUNTER,
+	DRM_RAS_CMD_CLEAR_ERROR_COUNTER,
+	DRM_RAS_CMD_GET_ERROR_THRESHOLD,
+	DRM_RAS_CMD_SET_ERROR_THRESHOLD,
+	DRM_RAS_CMD_ERROR_EVENT,
+
+	__DRM_RAS_CMD_MAX,
+	DRM_RAS_CMD_MAX = (__DRM_RAS_CMD_MAX - 1)
+};
+
+#define DRM_RAS_MCGRP_ERROR_NOTIFY	"error-notify"
+
+#endif /* _UAPI_LINUX_DRM_RAS_H */
lib/igt_drm_netlink.c new file +565 -0

565 lines not on this page · raw message

lib/igt_drm_netlink.h new file +48 -0

48 lines not on this page · raw message

lib/meson.build +9 -0
index a7cde027e..343a60e56 100644
@@ -27,6 +27,7 @@ lib_sources = [
 	'igt_device_scan.c',
 	'igt_drm_clients.h',
 	'igt_drm_fdinfo.c',
+	'igt_drm_netlink.c',
         'igt_fs.c',
 	'igt_aux.c',
 	'igt_dp.c',
@@ -145,6 +146,13 @@ lib_sources = [
 	'vendor/uwildmat/uwildmat.c',
 ]
 
+libnl = declare_dependency(dependencies : [
+	dependency('libnl-3.0', required : true),
+	dependency('libnl-genl-3.0', required : true),
+	dependency('libnl-cli-3.0', required : true),
+	dependency('libnl-utils', required : false),
+])
+
 lib_deps = [
 	cairo,
 	glib,
@@ -152,6 +160,7 @@ lib_deps = [
 	libdrm,
 	libdw,
 	libkmod,
+        libnl,
 	libpci,
 	libudev,
 	math,
tests/intel/xe_err_injection.c new file +623 -0

623 lines not on this page · raw message

tests/intel/xe_err_injection.h new file +28 -0
new file mode 100644
index 000000000..1a9ea2f2e
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#ifndef XE_ERR_INJECTION_H
+#define XE_ERR_INJECTION_H
+
+/* GT Uncorrectable unicast worker command parity error injection */
+#define MC_PKT_CTRL_MGSR_3D_ADDRESS 0x00FD4
+#define MC_PKT_CTRL_MGSR_3D_VALUE 0x80000000
+#define WKR_FABRIC_ERR_INJ_GAMWALK_3D_ADDRESS 0xF310
+#define WKR_FABRIC_ERR_INJ_GAMWALK_3D_VALUE 0x1
+
+#define POST_RECOVERY_WL 1
+#define POST_ARMING_INJECTION_WL 0
+
+/* L2 Bank (LBCFLOCKMSGREG) error injection */
+#define L2_BANK_ERR_INJ 0xB1B4
+#define DATA_1BIT_ERR_INJ_REQ (1 << 3)
+#define FUSA_TEST_MODE_ERR_INJ_REQ (1 << 2)
+#define MASK_BIT_FOR_DATA_1BIT_ERR_INJ_REQ (1 << 19)
+#define MASK_BIT_FOR_FUSA_TEST_MODE_ERR_INJ_REQ (1 << 18)
+#define L2_BANK_DATA_1BIT_ERR_INJ_CONFIG \
+	(DATA_1BIT_ERR_INJ_REQ | FUSA_TEST_MODE_ERR_INJ_REQ | \
+	 MASK_BIT_FOR_DATA_1BIT_ERR_INJ_REQ | MASK_BIT_FOR_FUSA_TEST_MODE_ERR_INJ_REQ)
+
+#endif /* XE_ERR_INJECTION_H */
tests/meson.build +1 -0
index 1ac89bab7..c21e14e65 100644
@@ -292,6 +292,7 @@ intel_xe_progs = [
 	'xe_debugfs',
 	'xe_dma_buf_sync',
 	'xe_drm_fdinfo',
+	'xe_err_injection',
 	'xe_eu_stall',
 	'xe_evict',
 	'xe_evict_ccs',
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/2 tests/intel/xe_err_injection: Add test for local Uncorrectable Error Injection through LSC Storage

In reply to Soham Purkait

Local Uncorrectable Unicast LSC storage error injection driven by a heavy LSC workload on all compute engines to trigger recovery post error injection. Also validate error counter increment and post-recovery error counter stability.

---
 tests/intel/xe_err_injection.c | 187 +++++++++++++++++++++++++++++++++
 tests/intel/xe_err_injection.h |  11 ++
 2 files changed, 198 insertions(+)
tests/intel/xe_err_injection.c +187 -0
index d17d049f4..56e5a600d 100644
@@ -16,6 +16,8 @@
 #include <string.h>
 #include <time.h>
 #include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
 #include <unistd.h>
 
 #include "igt.h"
@@ -30,6 +32,9 @@
 #include "xe/xe_query.h"
 #include "xe_err_injection.h"
 
+#define LSC_HEAVY_WL_ITERS	64
+#define LSC_HEAVY_WL_ELEMS	(256 * 1024)
+
 enum {
 	RECOVERY_SUCCESS = 1,
 	RECOVERY_FAILED,
@@ -64,6 +69,54 @@ static void run_xe_compute_on_all_engines(int fd, bool state)
 	}
 }
 
+static void run_heavy_lsc_workload_on_all_engines(int fd)
+{
+	pid_t pid;
+	int status = 0;
+
+	igt_info("Running heavy LSC workload (%d iters, %u elems) on all compute engines\n",
+		 LSC_HEAVY_WL_ITERS, LSC_HEAVY_WL_ELEMS);
+
+	pid = fork();
+	igt_assert_f(pid >= 0, "fork() failed: %m\n");
+
+	if (pid == 0) {
+		struct drm_xe_engine_class_instance *hwe;
+		struct user_execenv env = { };
+		int devnull, i;
+
+		devnull = open("/dev/null", O_WRONLY);
+		if (devnull >= 0) {
+			dup2(devnull, STDOUT_FILENO);
+			dup2(devnull, STDERR_FILENO);
+			close(devnull);
+		}
+
+		env.array_size = LSC_HEAVY_WL_ELEMS;
+
+		xe_for_each_engine(fd, hwe) {
+			if (hwe->engine_class != DRM_XE_ENGINE_CLASS_COMPUTE)
+				continue;
+
+			for (i = 0; i < LSC_HEAVY_WL_ITERS; i++)
+				xe_run_intel_compute_kernel_on_engine(fd, hwe,
+								      &env,
+								      EXECENV_PREF_SYSTEM);
+		}
+		_exit(0);
+	}
+
+	while (waitpid(pid, &status, 0) < 0 && errno == EINTR)
+		;
+
+	if (WIFEXITED(status))
+		igt_info("Heavy LSC workload child exited (status=%d)\n",
+			 WEXITSTATUS(status));
+	else if (WIFSIGNALED(status))
+		igt_info("Heavy LSC workload child killed by signal %d\n",
+			 WTERMSIG(status));
+}
+
 static void write_reg(struct xe_mmio *mmio, uint32_t reg, uint32_t value)
 {
 	xe_mmio_write32(mmio, reg, value);
@@ -83,6 +136,62 @@ static void modify_reg_bit(struct xe_mmio *mmio, uint32_t reg_addr,
 	xe_mmio_write32(mmio, reg_addr, regval);
 }
 
+static uint32_t disable_powergate(struct xe_mmio *mmio)
+{
+	uint32_t prev = xe_mmio_read32(mmio, POWERGATE_ENABLE_ADDRESS);
+
+	xe_mmio_write32(mmio, POWERGATE_ENABLE_ADDRESS,
+			POWERGATE_ENABLE_DISABLE_ALL_VALUE);
+	igt_info("POWERGATE_ENABLE (0x%X): 0x%08x -> 0x%08x (all PG disabled)\n",
+		 POWERGATE_ENABLE_ADDRESS, prev,
+		 xe_mmio_read32(mmio, POWERGATE_ENABLE_ADDRESS));
+
+	return prev;
+}
+
+static void restore_powergate(struct xe_mmio *mmio, uint32_t saved_val)
+{
+	uint32_t cur = xe_mmio_read32(mmio, POWERGATE_ENABLE_ADDRESS);
+
+	xe_mmio_write32(mmio, POWERGATE_ENABLE_ADDRESS, saved_val);
+	igt_info("POWERGATE_ENABLE (0x%X): 0x%08x -> 0x%08x (PG restored)\n",
+		 POWERGATE_ENABLE_ADDRESS, cur,
+		 xe_mmio_read32(mmio, POWERGATE_ENABLE_ADDRESS));
+}
+
+static void acquire_steer_sem(struct xe_mmio *mmio, unsigned long timeout_ms)
+{
+	if (timeout_ms == 0) {
+		igt_info("Waiting indefinitely for steering semaphore (0x%X)\n",
+			 STEER_SEM_ADDRESS);
+		while (xe_mmio_read32(mmio, STEER_SEM_ADDRESS) !=
+		       STEER_SEM_ACQUIRED_VALUE)
+			usleep(STEER_SEM_POLL_INTERVAL_MS * 1000);
+	} else {
+		bool acquired;
+
+		acquired = igt_wait(xe_mmio_read32(mmio, STEER_SEM_ADDRESS) ==
+				    STEER_SEM_ACQUIRED_VALUE,
+				    timeout_ms,
+				    STEER_SEM_POLL_INTERVAL_MS);
+		igt_assert_f(acquired,
+			     "Timed out (%lums) waiting for steering semaphore (0x%X) to be acquired; last read=0x%08x\n",
+			     timeout_ms, STEER_SEM_ADDRESS,
+			     xe_mmio_read32(mmio, STEER_SEM_ADDRESS));
+	}
+	igt_info("Steering semaphore acquired (0x%X = 0x%08x)\n",
+		 STEER_SEM_ADDRESS,
+		 xe_mmio_read32(mmio, STEER_SEM_ADDRESS));
+}
+
+static void release_steer_sem(struct xe_mmio *mmio)
+{
+	xe_mmio_write32(mmio, STEER_SEM_ADDRESS, STEER_SEM_ACQUIRED_VALUE);
+	igt_info("Steering semaphore released (0x%X = 0x%08x)\n",
+		 STEER_SEM_ADDRESS,
+		 xe_mmio_read32(mmio, STEER_SEM_ADDRESS));
+}
+
 static int acquire_forcewake(int fd)
 {
 	int fw_handle;
@@ -283,6 +392,80 @@ static void wkr_cmd_parity_err_injection(struct xe_mmio *mmio, int fd)
 	gt_uc_wkr_parity_recovered = true;
 }
 
+/**
+ * SUBTEST: test_GT-local-Uncorrectable-lsc-storage-err
+ * Description: GT Local Uncorrectable Unicast LSC storage error injection
+ * Functionality: error injection
+ */
+static void lsc_storage_uc_err_injection(struct xe_mmio *mmio, int fd)
+{
+	int fw_handle;
+	uint32_t error_counter_before;
+	uint32_t error_counter_after;
+	uint32_t saved_powergate;
+	uint32_t node_id = 1;
+	uint32_t error_id = 1;
+
+	fw_handle = acquire_forcewake(fd);
+	saved_powergate = disable_powergate(mmio);
+
+	error_counter_before = get_counter(node_id, error_id);
+
+	acquire_steer_sem(mmio, STEER_SEM_POLL_TIMEOUT_MS);
+	write_reg(mmio, MC_PKT_CTRL_MGSR_3D_ADDRESS,
+		  MC_PKT_CTRL_MGSR_3D_ARM_VALUE);
+	write_reg(mmio, LSC_STORAGE_ERR_INJ_TDL_GFX_ADDRESS,
+		  LSC_STORAGE_ERR_INJ_TDL_GFX_VALUE);
+	write_reg(mmio, MC_PKT_CTRL_MGSR_3D_ADDRESS,
+		  MC_PKT_CTRL_MGSR_3D_VALUE);
+	release_steer_sem(mmio);
+
+	igt_info("Injected GT Local Uncorrectable Unicast LSC Storage error\n");
+
+	run_heavy_lsc_workload_on_all_engines(fd);
+
+	restore_powergate(mmio, saved_powergate);
+	release_forcewake(fw_handle);
+	print_aer_recovery_status();
+	error_counter_after = get_counter(node_id, error_id);
+
+	igt_assert_f(error_counter_before != UINT32_MAX &&
+		     error_counter_after != UINT32_MAX,
+		     "Failed to fetch valid error counters: before=%u after=%u\n",
+		     error_counter_before, error_counter_after);
+
+	igt_info("error counter: before injection=%u after injection=%u\n",
+		 error_counter_before, error_counter_after);
+
+	igt_assert_f(error_counter_after > error_counter_before,
+		     "GT Local Uncorrectable Unicast LSC storage error injection "
+		     "failed: before injection=%u after injection=%u\n",
+		     error_counter_before, error_counter_after);
+
+	igt_info("Post recovery: re-running heavy LSC workload with no injection\n");
+	error_counter_before = get_counter(node_id, error_id);
+	run_heavy_lsc_workload_on_all_engines(fd);
+	error_counter_after = get_counter(node_id, error_id);
+
+	igt_assert_f(error_counter_before != UINT32_MAX &&
+		     error_counter_after != UINT32_MAX,
+		     "Failed to fetch valid Post recovery error counters: before=%u after=%u\n",
+		     error_counter_before, error_counter_after);
+
+	igt_info("Post recovery error counter: before wl=%u after wl=%u\n",
+		 error_counter_before, error_counter_after);
+
+	igt_assert_f(error_counter_before == error_counter_after,
+		     "Post recovery LSC workload unexpectedly bumped error counter: "
+		     "before=%u after=%u\n",
+		     error_counter_before, error_counter_after);
+
+	igt_info("Post recovery LSC workload clean: counters match (%u)\n",
+		 error_counter_after);
+
+	igt_info("GT Local Uncorrectable Unicast LSC storage error injection successful\n");
+}
+
 /* Inject a GT correctable error */
 static void l2_bank_corr_err_injection(struct xe_mmio *mmio, int fd)
 {
@@ -604,6 +787,10 @@ int igt_main()
 		inject_error("test_GT-UC-unicast-wkr-cmd-parity-err-post-recovery-wl", &mmio, fd);
 	}
 
+	igt_describe("Inject GT Local Uncorrectable Unicast LSC storage error.");
+	igt_subtest("test_GT-local-Uncorrectable-lsc-storage-err")
+		lsc_storage_uc_err_injection(&mmio, fd);
+
 	igt_describe("Inject GT correctable error and validate error-notify event with threshold set to 1.");
 	igt_subtest("test_l2-bank-corr-err-threshold-1")
 		inject_error("test_l2-bank-corr-err-threshold-1", &mmio, fd);
tests/intel/xe_err_injection.h +11 -0
index 1a9ea2f2e..03c5a14ee 100644
@@ -7,11 +7,22 @@
 #define XE_ERR_INJECTION_H
 
 /* GT Uncorrectable unicast worker command parity error injection */
+#define STEER_SEM_ADDRESS 0x00FD0
+#define STEER_SEM_ACQUIRED_VALUE 0x1
+#define STEER_SEM_POLL_TIMEOUT_MS 1000
+#define STEER_SEM_POLL_INTERVAL_MS 1
 #define MC_PKT_CTRL_MGSR_3D_ADDRESS 0x00FD4
 #define MC_PKT_CTRL_MGSR_3D_VALUE 0x80000000
 #define WKR_FABRIC_ERR_INJ_GAMWALK_3D_ADDRESS 0xF310
 #define WKR_FABRIC_ERR_INJ_GAMWALK_3D_VALUE 0x1
 
+#define MC_PKT_CTRL_MGSR_3D_ARM_VALUE 0x1
+#define LSC_STORAGE_ERR_INJ_TDL_GFX_ADDRESS 0xE760
+#define LSC_STORAGE_ERR_INJ_TDL_GFX_VALUE 0x8
+
+#define POWERGATE_ENABLE_ADDRESS 0xA210
+#define POWERGATE_ENABLE_DISABLE_ALL_VALUE 0x0
+
 #define POST_RECOVERY_WL 1
 #define POST_ARMING_INJECTION_WL 0
 
Signature · 1 line
2.43.0