#include <linux/pm_runtime.h>
 #include <linux/oom.h>
 
+static unsigned int i915_load_fail_count;
+
+bool __i915_inject_load_failure(const char *func, int line)
+{
+       if (i915_load_fail_count >= i915.inject_load_failure)
+               return false;
+
+       if (++i915_load_fail_count == i915.inject_load_failure) {
+               DRM_INFO("Injecting failure at checkpoint %u [%s:%d]\n",
+                        i915.inject_load_failure, func, line);
+               return true;
+       }
+
+       return false;
+}
 
 static int i915_getparam(struct drm_device *dev, void *data,
                         struct drm_file *file_priv)
        struct drm_i915_private *dev_priv = dev->dev_private;
        int ret;
 
+       if (i915_inject_load_failure())
+               return -ENODEV;
+
        ret = intel_bios_init(dev_priv);
        if (ret)
                DRM_INFO("failed to find VBIOS tables\n");
        struct intel_device_info *device_info;
        int ret = 0;
 
+       if (i915_inject_load_failure())
+               return -ENODEV;
+
        dev_priv->dev = dev;
 
        /* Setup the write-once "constant" device info */
        struct drm_device *dev = dev_priv->dev;
        int ret;
 
+       if (i915_inject_load_failure())
+               return -ENODEV;
+
        if (i915_get_bridge_dev(dev))
                return -EIO;
 
        uint32_t aperture_size;
        int ret;
 
+       if (i915_inject_load_failure())
+               return -ENODEV;
+
        intel_device_info_runtime_init(dev);
 
        ret = i915_gem_gtt_init(dev);
 
 #define I915_STATE_WARN_ON(x)                                          \
        I915_STATE_WARN((x), "%s", "WARN_ON(" __stringify(x) ")")
 
+bool __i915_inject_load_failure(const char *func, int line);
+#define i915_inject_load_failure() \
+       __i915_inject_load_failure(__func__, __LINE__)
+
 static inline const char *yesno(bool v)
 {
        return v ? "yes" : "no";
 
        .enable_guc_submission = false,
        .guc_log_level = -1,
        .enable_dp_mst = true,
+       .inject_load_failure = 0,
 };
 
 module_param_named(modeset, i915.modeset, int, 0400);
 module_param_named_unsafe(enable_dp_mst, i915.enable_dp_mst, bool, 0600);
 MODULE_PARM_DESC(enable_dp_mst,
        "Enable multi-stream transport (MST) for new DisplayPort sinks. (default: true)");
+module_param_named_unsafe(inject_load_failure, i915.inject_load_failure, uint, 0400);
+MODULE_PARM_DESC(inject_load_failure,
+       "Force an error after a number of failure check points (0:disabled (default), N:force failure at the Nth failure check point)");