Use fault-inject framework to trigger punit_error_handler()
for testing.
Usage:
echo 100 > .../inject_punit_error/probability
echo 1 > .../inject_punit_error/times
Signed-off-by: Mallesh Koujalagi <[email protected]>
---
drivers/gpu/drm/xe/xe_debugfs.c | 4 ++++
drivers/gpu/drm/xe/xe_debugfs.h | 2 ++
drivers/gpu/drm/xe/xe_ras.c | 17 +++++++++++++++++
3 files changed, 23 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_debugfs.c
b/drivers/gpu/drm/xe/xe_debugfs.c
index 5a3877fcb0f0..5599d493feca 100644
--- a/drivers/gpu/drm/xe/xe_debugfs.c
+++ b/drivers/gpu/drm/xe/xe_debugfs.c
@@ -42,6 +42,7 @@
DECLARE_FAULT_ATTR(gt_reset_failure);
DECLARE_FAULT_ATTR(inject_csc_hw_error);
+DECLARE_FAULT_ATTR(inject_punit_error);
static bool csc_hw_error_available(struct xe_device *xe)
{
@@ -62,6 +63,8 @@ static struct {
{ .name = "inject_csc_hw_error",
.attr = &inject_csc_hw_error,
.is_visible = csc_hw_error_available },
+ { .name = "inject_punit_error",
+ .attr = &inject_punit_error },
};
/*
@@ -76,6 +79,7 @@ bool xe_fault_##name(void) \
FAULT_ACTION(gt_reset, gt_reset_failure)
FAULT_ACTION(csc_hw_error, inject_csc_hw_error)
+FAULT_ACTION(punit_error, inject_punit_error)
static void xe_fault_inject_debugfs_register(struct xe_device *xe,
struct dentry *root)
diff --git a/drivers/gpu/drm/xe/xe_debugfs.h
b/drivers/gpu/drm/xe/xe_debugfs.h
index cd56f7442b99..dd57914dd4f2 100644
--- a/drivers/gpu/drm/xe/xe_debugfs.h
+++ b/drivers/gpu/drm/xe/xe_debugfs.h
@@ -13,10 +13,12 @@ struct xe_device;
#ifdef CONFIG_DEBUG_FS
bool xe_fault_gt_reset(void);
bool xe_fault_csc_hw_error(void);
+bool xe_fault_punit_error(void);
void xe_debugfs_register(struct xe_device *xe);
#else
static inline bool xe_fault_gt_reset(void) { return false; }
static inline bool xe_fault_csc_hw_error(void) { return false; }
+static inline bool xe_fault_punit_error(void) { return false; }
static inline void xe_debugfs_register(struct xe_device *xe) { }
#endif
diff --git a/drivers/gpu/drm/xe/xe_ras.c
b/drivers/gpu/drm/xe/xe_ras.c
index 92b4181026cb..da06c16cf7ed 100644
--- a/drivers/gpu/drm/xe/xe_ras.c
+++ b/drivers/gpu/drm/xe/xe_ras.c
@@ -3,6 +3,7 @@
* Copyright © 2026 Intel Corporation
*/
+#include "xe_debugfs.h"
#include "xe_device.h"
#include "xe_drm_ras.h"
#include "xe_pm.h"
@@ -391,6 +392,22 @@ enum xe_ras_recovery_action
xe_ras_process_errors(struct xe_device *xe)
size_t rlen;
int ret;
+ /*
+ * Only allow the injected PUNIT error once the DRM device is
registered.