[Intel-gfx] [PATCH] drm/i915: Export number of fail injection checkpoints through debugfs

Michał Winiarski michal.winiarski at intel.com
Wed Jun 6 11:33:56 UTC 2018


We'd like to start testing module load with fault injection. To avoid
making any asumptions on number of available fault injection
checkpoints (either in IGT or in i915), we can compute it at runtime and
export it in debugfs.

Signed-off-by: Michał Winiarski <michal.winiarski at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Imre Deak <imre.deak at intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 14 ++++++++++++++
 drivers/gpu/drm/i915/i915_drv.c     | 13 +++++--------
 drivers/gpu/drm/i915/i915_drv.h     |  7 +++++--
 3 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 698af45e229c..32cf8bb83ed5 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -2279,6 +2279,17 @@ static int i915_rps_boost_info(struct seq_file *m, void *data)
 	return 0;
 }
 
+#if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
+static int i915_fail_injection_info(struct seq_file *m, void *data)
+{
+	struct drm_i915_private *i915 = node_to_i915(m->private);
+
+	seq_printf(m, "Available checkpoints: %u\n", i915->load_fail_count);
+
+	return 0;
+}
+#endif
+
 static int i915_llc(struct seq_file *m, void *data)
 {
 	struct drm_i915_private *dev_priv = node_to_i915(m->private);
@@ -4797,6 +4808,9 @@ static const struct drm_info_list i915_debugfs_list[] = {
 	{"i915_sseu_status", i915_sseu_status, 0},
 	{"i915_drrs_status", i915_drrs_status, 0},
 	{"i915_rps_boost_info", i915_rps_boost_info, 0},
+#if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
+	{"i915_fail_injection_info", i915_fail_injection_info, 0},
+#endif
 };
 #define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
 
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 6b599b1837dc..0c3acc255085 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -57,14 +57,11 @@
 static struct drm_driver driver;
 
 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
-static unsigned int i915_load_fail_count;
 
-bool __i915_inject_load_failure(const char *func, int line)
+bool __i915_inject_load_failure(struct drm_i915_private *i915,
+				const char *func, int line)
 {
-	if (i915_load_fail_count >= i915_modparams.inject_load_failure)
-		return false;
-
-	if (++i915_load_fail_count == i915_modparams.inject_load_failure) {
+	if (++i915->load_fail_count == i915_modparams.inject_load_failure) {
 		DRM_INFO("Injecting failure at checkpoint %u [%s:%d]\n",
 			 i915_modparams.inject_load_failure, func, line);
 		return true;
@@ -114,11 +111,11 @@ __i915_printk(struct drm_i915_private *dev_priv, const char *level,
 	va_end(args);
 }
 
-static bool i915_error_injected(struct drm_i915_private *dev_priv)
+static bool i915_error_injected(struct drm_i915_private *i915)
 {
 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
 	return i915_modparams.inject_load_failure &&
-	       i915_load_fail_count == i915_modparams.inject_load_failure;
+	       i915->load_fail_count == i915_modparams.inject_load_failure;
 #else
 	return false;
 #endif
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index a4bb30c32a52..f694e5ebd39f 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -107,9 +107,10 @@
 	I915_STATE_WARN((x), "%s", "WARN_ON(" __stringify(x) ")")
 
 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
-bool __i915_inject_load_failure(const char *func, int line);
+bool __i915_inject_load_failure(struct drm_i915_private *i915,
+				const char *func, int line);
 #define i915_inject_load_failure() \
-	__i915_inject_load_failure(__func__, __LINE__)
+	__i915_inject_load_failure(dev_priv, __func__, __LINE__)
 #else
 #define i915_inject_load_failure() false
 #endif
@@ -2120,6 +2121,8 @@ struct drm_i915_private {
 
 	struct i915_pmu pmu;
 
+	unsigned int load_fail_count;
+
 	/*
 	 * NOTE: This is the dri1/ums dungeon, don't add stuff here. Your patch
 	 * will be rejected. Instead look for a better place.
-- 
2.17.0



More information about the Intel-gfx mailing list