So many corner cases are virtually impossible to hit in contrived test cases, but are immediately apparent when run on the diverse conditions in the wild. To trigger fallbacks of fallbacks we need to inject errors whilst testing, to guide the tests along the long forgotten paths. This patch starts using CONFIG_FAULT_INJECTION to conditionally perform fault injection. Using this interface, we can inject probabilistic faults, or impose space constraints, along with limiting injection to a task and controlling what output to print -- all from a common debugfs interface. Q: How do we name these beasties? Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> --- drivers/gpu/drm/i915/Kconfig.debug | 2 ++ drivers/gpu/drm/i915/i915_debugfs.c | 25 ++++++++++++++++++ drivers/gpu/drm/i915/i915_faultinjection.h | 42 ++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_gem.c | 4 +++ 4 files changed, 73 insertions(+) create mode 100644 drivers/gpu/drm/i915/i915_faultinjection.h diff --git a/drivers/gpu/drm/i915/Kconfig.debug b/drivers/gpu/drm/i915/Kconfig.debug index cee87bfd10c4..e039eab5c5bd 100644 --- a/drivers/gpu/drm/i915/Kconfig.debug +++ b/drivers/gpu/drm/i915/Kconfig.debug @@ -19,6 +19,8 @@ config DRM_I915_DEBUG bool "Enable additional driver debugging" depends on DRM_I915 select PREEMPT_COUNT + select FAULT_INJECTION + select FAULT_INJECTION_DEBUG_FS select X86_MSR # used by igt/pm_rpm select DRM_VGEM # used by igt/prime_vgem (dmabuf interop checks) default n diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 9aa62c5b5f65..b28b740fe7f8 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -39,6 +39,7 @@ #include "intel_ringbuffer.h" #include <drm/i915_drm.h> #include "i915_drv.h" +#include "i915_faultinjection.h" enum { ACTIVE_LIST, @@ -5451,6 +5452,19 @@ void intel_display_crc_init(struct drm_device *dev) } } +#if CONFIG_FAULT_INJECTION +DECLARE_FAULT_ATTR(i915_fi_insert_mappable_node); +#endif + +static const struct { + const char *name; + struct fault_attr *attr; +} i915_fi_entries[] = { +#if CONFIG_FAULT_INJECTION_DEBUG_FS + { "fi-insert-mappable-node", &i915_fi_insert_mappable_node }, +#endif +}; + int i915_debugfs_register(struct drm_i915_private *dev_priv) { struct drm_minor *minor = dev_priv->drm.primary; @@ -5474,6 +5488,17 @@ int i915_debugfs_register(struct drm_i915_private *dev_priv) return ret; } + for (i = 0; i < ARRAY_SIZE(i915_fi_entries); i++) { + struct dentry *de; + + de = fault_create_debugfs_attr(i915_fi_entries[i].name, + minor->debugfs_root, + i915_fi_entries[i].attr); + if (!IS_ERR(de) && + drm_add_fake_info_node(minor, de, NULL)) + debugfs_remove_recursive(de); + } + return drm_debugfs_create_files(i915_debugfs_list, I915_DEBUGFS_ENTRIES, minor->debugfs_root, minor); diff --git a/drivers/gpu/drm/i915/i915_faultinjection.h b/drivers/gpu/drm/i915/i915_faultinjection.h new file mode 100644 index 000000000000..69edcc16c4c4 --- /dev/null +++ b/drivers/gpu/drm/i915/i915_faultinjection.h @@ -0,0 +1,42 @@ +/* + * Copyright © 2016 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#ifndef I915_FAULTINJECTION_H +#define I915_FAULTINJECTION_H + +struct fault_attr; + +#ifdef CONFIG_FAULT_INJECTION +#include <linux/fault-inject.h> + +extern struct fault_attr i915_fi_insert_mappable_node; + +#define i915_should_fail(f, s) should_fail(f, s) +#endif + +#ifndef i915_should_fail +#define i915_should_fail(f, s) 0 +#endif + +#endif /* I915_FAULTINJECTION_H */ diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 9e826585edb2..6cb6332127dd 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -30,6 +30,7 @@ #include <drm/i915_drm.h> #include "i915_drv.h" #include "i915_gem_dmabuf.h" +#include "i915_faultinjection.h" #include "i915_vgpu.h" #include "i915_trace.h" #include "intel_drv.h" @@ -69,6 +70,9 @@ static int insert_mappable_node(struct drm_i915_private *i915, struct drm_mm_node *node, u32 size) { + if (i915_should_fail(&i915_fi_insert_mappable_node, size)) + return -ENOSPC; + memset(node, 0, sizeof(*node)); return drm_mm_insert_node_in_range_generic(&i915->ggtt.base.mm, node, size, 0, 0, 0, -- 2.8.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx