drm/i915: Add i915 to i915_inject_probe_failure
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Fri, 2 Aug 2019 18:40:50 +0000 (18:40 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 2 Aug 2019 20:14:29 +0000 (21:14 +0100)
With i915 added to i915_inject_probe_failure we can use dedicated
printk when injecting artificial load failure.

Also make this function look like other i915 functions that return
error code and make it more flexible to return any provided error
code instead of previously assumed -ENODEV.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20190802184055.31988-2-michal.wajdeczko@intel.com
drivers/gpu/drm/i915/display/intel_connector.c
drivers/gpu/drm/i915/gt/intel_engine_cs.c
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_pci.c
drivers/gpu/drm/i915/intel_gvt.c
drivers/gpu/drm/i915/intel_uncore.c
drivers/gpu/drm/i915/intel_wopcm.c

index d0163d86c42ab13f0579dc9d46294e90ead50a6d..cf8823ce960669fb030dbad9446116aaa94cc7f9 100644 (file)
@@ -118,7 +118,7 @@ int intel_connector_register(struct drm_connector *connector)
        if (ret)
                goto err;
 
-       if (i915_inject_probe_failure()) {
+       if (i915_inject_probe_failure(to_i915(connector->dev))) {
                ret = -EFAULT;
                goto err_backlight;
        }
index 65cbf1d9118d5840feb475aeaae8d716e95c538b..8bd9a9adf4a5eac4d574052dd742522a3e10edaa 100644 (file)
@@ -426,7 +426,7 @@ int intel_engines_init_mmio(struct drm_i915_private *i915)
        WARN_ON(engine_mask &
                GENMASK(BITS_PER_TYPE(mask) - 1, I915_NUM_ENGINES));
 
-       if (i915_inject_probe_failure())
+       if (i915_inject_probe_failure(i915))
                return -ENODEV;
 
        for (i = 0; i < ARRAY_SIZE(intel_engines); i++) {
index d6178f5c6b502c8c657dc1f0307bbb2dc89654e7..21f1b29d06a2ebbfb6fee0008ecdcb7a1abb6fc4 100644 (file)
@@ -83,19 +83,20 @@ static struct drm_driver driver;
 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
 static unsigned int i915_probe_fail_count;
 
-bool __i915_inject_probe_failure(const char *func, int line)
+int __i915_inject_load_error(struct drm_i915_private *i915, int err,
+                            const char *func, int line)
 {
        if (i915_probe_fail_count >= i915_modparams.inject_load_failure)
-               return false;
+               return 0;
 
-       if (++i915_probe_fail_count == i915_modparams.inject_load_failure) {
-               DRM_INFO("Injecting failure at checkpoint %u [%s:%d]\n",
-                        i915_modparams.inject_load_failure, func, line);
-               i915_modparams.inject_load_failure = 0;
-               return true;
-       }
+       if (++i915_probe_fail_count < i915_modparams.inject_load_failure)
+               return 0;
 
-       return false;
+       __i915_printk(i915, KERN_INFO,
+                     "Injecting failure %d at checkpoint %u [%s:%d]\n",
+                     err, i915_modparams.inject_load_failure, func, line);
+       i915_modparams.inject_load_failure = 0;
+       return err;
 }
 
 bool i915_error_injected(void)
@@ -687,7 +688,7 @@ static int i915_driver_modeset_probe(struct drm_device *dev)
        struct pci_dev *pdev = dev_priv->drm.pdev;
        int ret;
 
-       if (i915_inject_probe_failure())
+       if (i915_inject_probe_failure(dev_priv))
                return -ENODEV;
 
        if (HAS_DISPLAY(dev_priv)) {
@@ -894,7 +895,7 @@ static int i915_driver_early_probe(struct drm_i915_private *dev_priv)
 {
        int ret = 0;
 
-       if (i915_inject_probe_failure())
+       if (i915_inject_probe_failure(dev_priv))
                return -ENODEV;
 
        intel_device_info_subplatform_init(dev_priv);
@@ -985,7 +986,7 @@ static int i915_driver_mmio_probe(struct drm_i915_private *dev_priv)
 {
        int ret;
 
-       if (i915_inject_probe_failure())
+       if (i915_inject_probe_failure(dev_priv))
                return -ENODEV;
 
        if (i915_get_bridge_dev(dev_priv))
@@ -1530,7 +1531,7 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
        struct pci_dev *pdev = dev_priv->drm.pdev;
        int ret;
 
-       if (i915_inject_probe_failure())
+       if (i915_inject_probe_failure(dev_priv))
                return -ENODEV;
 
        intel_device_info_runtime_init(dev_priv);
index 7ca95136d30250739f94fa097f85169b1f991cd6..98045875ebbaec8c39223271a0c803cd771ee7ee 100644 (file)
 
 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
 
-bool __i915_inject_probe_failure(const char *func, int line);
-#define i915_inject_probe_failure() \
-       __i915_inject_probe_failure(__func__, __LINE__)
-
+int __i915_inject_load_error(struct drm_i915_private *i915, int err,
+                            const char *func, int line);
+#define i915_inject_load_error(_i915, _err) \
+       __i915_inject_load_error((_i915), (_err), __func__, __LINE__)
 bool i915_error_injected(void);
 
 #else
 
-#define i915_inject_probe_failure() false
+#define i915_inject_load_error(_i915, _err) 0
 #define i915_error_injected() false
 
 #endif
 
+#define i915_inject_probe_failure(i915) i915_inject_load_error((i915), -ENODEV)
+
 #define i915_probe_error(i915, fmt, ...)                                  \
        __i915_printk(i915, i915_error_injected() ? KERN_DEBUG : KERN_ERR, \
                      fmt, ##__VA_ARGS__)
index e779dba2e5a33a1abd29cc43786b921bb090fb44..5e87acc4b770234c811d7a48a717bbc3a5595d55 100644 (file)
@@ -1520,15 +1520,13 @@ int i915_gem_init(struct drm_i915_private *dev_priv)
        if (ret)
                goto err_gt;
 
-       if (i915_inject_probe_failure()) {
-               ret = -ENODEV;
+       ret = i915_inject_load_error(dev_priv, -ENODEV);
+       if (ret)
                goto err_gt;
-       }
 
-       if (i915_inject_probe_failure()) {
-               ret = -EIO;
+       ret = i915_inject_load_error(dev_priv, -EIO);
+       if (ret)
                goto err_gt;
-       }
 
        intel_uncore_forcewake_put(&dev_priv->uncore, FORCEWAKE_ALL);
        mutex_unlock(&dev_priv->drm.struct_mutex);
index a7e1cde4a6d9dd121a8bfd475a493e8c4b9cd2a9..20e562ced8ccdb2dbb145a543efc695097b2adf6 100644 (file)
@@ -959,7 +959,7 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (err)
                return err;
 
-       if (i915_inject_probe_failure()) {
+       if (i915_inject_probe_failure(to_i915(pci_get_drvdata(pdev)))) {
                i915_pci_remove(pdev);
                return -ENODEV;
        }
index c66b2d8a62196911867b66733fe911dc36a2a0b6..2b6c016387c26cb5648d42d558b98654dbc307b9 100644 (file)
@@ -95,7 +95,7 @@ int intel_gvt_init(struct drm_i915_private *dev_priv)
 {
        int ret;
 
-       if (i915_inject_probe_failure())
+       if (i915_inject_probe_failure(dev_priv))
                return -ENODEV;
 
        if (!i915_modparams.enable_gvt) {
index 4e9c15b60e934eb57964499fc7f3c200def2d22a..773dc0a795771eb9376132304fcceca4a725eece 100644 (file)
@@ -1331,7 +1331,7 @@ static int __fw_domain_init(struct intel_uncore *uncore,
        GEM_BUG_ON(domain_id >= FW_DOMAIN_ID_COUNT);
        GEM_BUG_ON(uncore->fw_domain[domain_id]);
 
-       if (i915_inject_probe_failure())
+       if (i915_inject_probe_failure(uncore->i915))
                return -ENOMEM;
 
        d = kzalloc(sizeof(*d), GFP_KERNEL);
index d9973c0b038406c0894f72d8e57e60083eee93c4..291881937d97fe7b5677db02d722c13f35d1e4f1 100644 (file)
@@ -177,7 +177,7 @@ int intel_wopcm_init(struct intel_wopcm *wopcm)
 
        GEM_BUG_ON(!wopcm->size);
 
-       if (i915_inject_probe_failure())
+       if (i915_inject_probe_failure(i915))
                return -E2BIG;
 
        if (guc_fw_size >= wopcm->size) {