diff mbox

[v2] drm/i915: Mark i915.inject_load_failure as being hit

Message ID 20180606142604.13428-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson June 6, 2018, 2:26 p.m. UTC
When we reach the magic value and do inject a fault into our module load,
mark the module option as being hit. Since we fail from inside pci
probe, the module load isn't actually aborted and the module (and
paramters) are left lingering. igt can then inspect the parameter on its
synchronous completion of modprobe to see if the fault injection was
successful, and will keeping on injecting new faults until the module
succeeds in loading having surpassed the number of fault points.

v2: Reset to 0 after being hit;

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: MichaƂ Winiarski <michal.winiarski@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

Comments

kernel test robot June 7, 2018, 11:09 a.m. UTC | #1
Hi Chris,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on v4.17 next-20180606]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/drm-i915-Mark-i915-inject_load_failure-as-being-hit/20180607-174849
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-randconfig-n0-201822 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   In file included from include/linux/printk.h:7:0,
                    from include/linux/kernel.h:14,
                    from include/linux/list.h:9,
                    from include/linux/resource_ext.h:17,
                    from include/linux/acpi.h:26,
                    from drivers/gpu//drm/i915/i915_drv.c:30:
   include/linux/kern_levels.h:5:18: error: initialization makes integer from pointer without a cast [-Werror=int-conversion]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
    #define KERN_ERR KERN_SOH "3" /* error conditions */
                     ^~~~~~~~
   drivers/gpu//drm/i915/i915_drv.c:61:36: note: in expansion of macro 'KERN_ERR'
    static int i915_load_error_level = KERN_ERR;
                                       ^~~~~~~~
   drivers/gpu//drm/i915/i915_drv.c: In function '__i915_inject_load_failure':
>> drivers/gpu//drm/i915/i915_drv.c:72:25: error: assignment makes integer from pointer without a cast [-Werror=int-conversion]
      i915_load_error_level = KERN_DEBUG;
                            ^
   drivers/gpu//drm/i915/i915_drv.c: In function 'i915_driver_load':
>> drivers/gpu//drm/i915/i915_drv.c:123:26: error: passing argument 2 of '__i915_printk' makes pointer from integer without a cast [-Werror=int-conversion]
     __i915_printk(dev_priv, i915_load_error_level, fmt, ##__VA_ARGS__)
                             ^
   drivers/gpu//drm/i915/i915_drv.c:1425:2: note: in expansion of macro 'i915_load_error'
     i915_load_error(dev_priv, "Device initialization failed (%d)\n", ret);
     ^~~~~~~~~~~~~~~
   drivers/gpu//drm/i915/i915_drv.c:87:1: note: expected 'const char *' but argument is of type 'int'
    __i915_printk(struct drm_i915_private *dev_priv, const char *level,
    ^~~~~~~~~~~~~
   cc1: all warnings being treated as errors

vim +/__i915_printk +123 drivers/gpu//drm/i915/i915_drv.c

    58	
    59	#if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
    60	static unsigned int i915_load_fail_count;
  > 61	static int i915_load_error_level = KERN_ERR;
    62	
    63	bool __i915_inject_load_failure(const char *func, int line)
    64	{
    65		if (i915_load_fail_count >= i915_modparams.inject_load_failure)
    66			return false;
    67	
    68		if (++i915_load_fail_count == i915_modparams.inject_load_failure) {
    69			DRM_INFO("Injecting failure at checkpoint %u [%s:%d]\n",
    70				 i915_modparams.inject_load_failure, func, line);
    71			i915_modparams.inject_load_failure = 0;
  > 72			i915_load_error_level = KERN_DEBUG;
    73			return true;
    74		}
    75	
    76		return false;
    77	}
    78	#else
    79	#define i915_load_error_level KERN_ERR
    80	#endif
    81	
    82	#define FDO_BUG_URL "https://bugs.freedesktop.org/enter_bug.cgi?product=DRI"
    83	#define FDO_BUG_MSG "Please file a bug at " FDO_BUG_URL " against DRM/Intel " \
    84			    "providing the dmesg log by booting with drm.debug=0xf"
    85	
    86	void
    87	__i915_printk(struct drm_i915_private *dev_priv, const char *level,
    88		      const char *fmt, ...)
    89	{
    90		static bool shown_bug_once;
    91		struct device *kdev = dev_priv->drm.dev;
    92		bool is_error = level[1] <= KERN_ERR[1];
    93		bool is_debug = level[1] == KERN_DEBUG[1];
    94		struct va_format vaf;
    95		va_list args;
    96	
    97		if (is_debug && !(drm_debug & DRM_UT_DRIVER))
    98			return;
    99	
   100		va_start(args, fmt);
   101	
   102		vaf.fmt = fmt;
   103		vaf.va = &args;
   104	
   105		dev_printk(level, kdev, "[" DRM_NAME ":%ps] %pV",
   106			   __builtin_return_address(0), &vaf);
   107	
   108		if (is_error && !shown_bug_once) {
   109			/*
   110			 * Ask the user to file a bug report for the error, except
   111			 * if they may have caused the bug by fiddling with unsafe
   112			 * module parameters.
   113			 */
   114			if (!test_taint(TAINT_USER))
   115				dev_notice(kdev, "%s", FDO_BUG_MSG);
   116			shown_bug_once = true;
   117		}
   118	
   119		va_end(args);
   120	}
   121	
   122	#define i915_load_error(dev_priv, fmt, ...)				     \
 > 123		__i915_printk(dev_priv, i915_load_error_level, fmt, ##__VA_ARGS__)
   124	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot June 7, 2018, 11:17 a.m. UTC | #2
Hi Chris,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on v4.17 next-20180606]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/drm-i915-Mark-i915-inject_load_failure-as-being-hit/20180607-174849
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-randconfig-x018-201822 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/printk.h:7:0,
                    from include/linux/kernel.h:14,
                    from include/linux/list.h:9,
                    from include/linux/resource_ext.h:17,
                    from include/linux/acpi.h:26,
                    from drivers/gpu/drm/i915/i915_drv.c:30:
>> include/linux/kern_levels.h:5:18: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
    #define KERN_ERR KERN_SOH "3" /* error conditions */
                     ^~~~~~~~
>> drivers/gpu/drm/i915/i915_drv.c:61:36: note: in expansion of macro 'KERN_ERR'
    static int i915_load_error_level = KERN_ERR;
                                       ^~~~~~~~
>> include/linux/kern_levels.h:5:18: error: initializer element is not computable at load time
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
    #define KERN_ERR KERN_SOH "3" /* error conditions */
                     ^~~~~~~~
>> drivers/gpu/drm/i915/i915_drv.c:61:36: note: in expansion of macro 'KERN_ERR'
    static int i915_load_error_level = KERN_ERR;
                                       ^~~~~~~~
   drivers/gpu/drm/i915/i915_drv.c: In function '__i915_inject_load_failure':
>> drivers/gpu/drm/i915/i915_drv.c:72:25: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
      i915_load_error_level = KERN_DEBUG;
                            ^
   drivers/gpu/drm/i915/i915_drv.c: In function 'i915_driver_load':
>> drivers/gpu/drm/i915/i915_drv.c:123:26: warning: passing argument 2 of '__i915_printk' makes pointer from integer without a cast [-Wint-conversion]
     __i915_printk(dev_priv, i915_load_error_level, fmt, ##__VA_ARGS__)
                             ^
>> drivers/gpu/drm/i915/i915_drv.c:1425:2: note: in expansion of macro 'i915_load_error'
     i915_load_error(dev_priv, "Device initialization failed (%d)\n", ret);
     ^~~~~~~~~~~~~~~
   drivers/gpu/drm/i915/i915_drv.c:87:1: note: expected 'const char *' but argument is of type 'int'
    __i915_printk(struct drm_i915_private *dev_priv, const char *level,
    ^~~~~~~~~~~~~
--
   In file included from include/linux/printk.h:7:0,
                    from include/linux/kernel.h:14,
                    from include/linux/list.h:9,
                    from include/linux/resource_ext.h:17,
                    from include/linux/acpi.h:26,
                    from drivers/gpu//drm/i915/i915_drv.c:30:
>> include/linux/kern_levels.h:5:18: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
    #define KERN_ERR KERN_SOH "3" /* error conditions */
                     ^~~~~~~~
   drivers/gpu//drm/i915/i915_drv.c:61:36: note: in expansion of macro 'KERN_ERR'
    static int i915_load_error_level = KERN_ERR;
                                       ^~~~~~~~
>> include/linux/kern_levels.h:5:18: error: initializer element is not computable at load time
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
    #define KERN_ERR KERN_SOH "3" /* error conditions */
                     ^~~~~~~~
   drivers/gpu//drm/i915/i915_drv.c:61:36: note: in expansion of macro 'KERN_ERR'
    static int i915_load_error_level = KERN_ERR;
                                       ^~~~~~~~
   drivers/gpu//drm/i915/i915_drv.c: In function '__i915_inject_load_failure':
   drivers/gpu//drm/i915/i915_drv.c:72:25: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
      i915_load_error_level = KERN_DEBUG;
                            ^
   drivers/gpu//drm/i915/i915_drv.c: In function 'i915_driver_load':
   drivers/gpu//drm/i915/i915_drv.c:123:26: warning: passing argument 2 of '__i915_printk' makes pointer from integer without a cast [-Wint-conversion]
     __i915_printk(dev_priv, i915_load_error_level, fmt, ##__VA_ARGS__)
                             ^
   drivers/gpu//drm/i915/i915_drv.c:1425:2: note: in expansion of macro 'i915_load_error'
     i915_load_error(dev_priv, "Device initialization failed (%d)\n", ret);
     ^~~~~~~~~~~~~~~
   drivers/gpu//drm/i915/i915_drv.c:87:1: note: expected 'const char *' but argument is of type 'int'
    __i915_printk(struct drm_i915_private *dev_priv, const char *level,
    ^~~~~~~~~~~~~

vim +/KERN_ERR +61 drivers/gpu/drm/i915/i915_drv.c

  > 30	#include <linux/acpi.h>
    31	#include <linux/device.h>
    32	#include <linux/oom.h>
    33	#include <linux/module.h>
    34	#include <linux/pci.h>
    35	#include <linux/pm.h>
    36	#include <linux/pm_runtime.h>
    37	#include <linux/pnp.h>
    38	#include <linux/slab.h>
    39	#include <linux/vgaarb.h>
    40	#include <linux/vga_switcheroo.h>
    41	#include <linux/vt.h>
    42	#include <acpi/video.h>
    43	
    44	#include <drm/drmP.h>
    45	#include <drm/drm_crtc_helper.h>
    46	#include <drm/drm_atomic_helper.h>
    47	#include <drm/i915_drm.h>
    48	
    49	#include "i915_drv.h"
    50	#include "i915_trace.h"
    51	#include "i915_pmu.h"
    52	#include "i915_query.h"
    53	#include "i915_vgpu.h"
    54	#include "intel_drv.h"
    55	#include "intel_uc.h"
    56	
    57	static struct drm_driver driver;
    58	
    59	#if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
    60	static unsigned int i915_load_fail_count;
  > 61	static int i915_load_error_level = KERN_ERR;
    62	
    63	bool __i915_inject_load_failure(const char *func, int line)
    64	{
    65		if (i915_load_fail_count >= i915_modparams.inject_load_failure)
    66			return false;
    67	
    68		if (++i915_load_fail_count == i915_modparams.inject_load_failure) {
    69			DRM_INFO("Injecting failure at checkpoint %u [%s:%d]\n",
    70				 i915_modparams.inject_load_failure, func, line);
    71			i915_modparams.inject_load_failure = 0;
  > 72			i915_load_error_level = KERN_DEBUG;
    73			return true;
    74		}
    75	
    76		return false;
    77	}
    78	#else
    79	#define i915_load_error_level KERN_ERR
    80	#endif
    81	
    82	#define FDO_BUG_URL "https://bugs.freedesktop.org/enter_bug.cgi?product=DRI"
    83	#define FDO_BUG_MSG "Please file a bug at " FDO_BUG_URL " against DRM/Intel " \
    84			    "providing the dmesg log by booting with drm.debug=0xf"
    85	
    86	void
    87	__i915_printk(struct drm_i915_private *dev_priv, const char *level,
    88		      const char *fmt, ...)
    89	{
    90		static bool shown_bug_once;
    91		struct device *kdev = dev_priv->drm.dev;
    92		bool is_error = level[1] <= KERN_ERR[1];
    93		bool is_debug = level[1] == KERN_DEBUG[1];
    94		struct va_format vaf;
    95		va_list args;
    96	
    97		if (is_debug && !(drm_debug & DRM_UT_DRIVER))
    98			return;
    99	
   100		va_start(args, fmt);
   101	
   102		vaf.fmt = fmt;
   103		vaf.va = &args;
   104	
   105		dev_printk(level, kdev, "[" DRM_NAME ":%ps] %pV",
   106			   __builtin_return_address(0), &vaf);
   107	
   108		if (is_error && !shown_bug_once) {
   109			/*
   110			 * Ask the user to file a bug report for the error, except
   111			 * if they may have caused the bug by fiddling with unsafe
   112			 * module parameters.
   113			 */
   114			if (!test_taint(TAINT_USER))
   115				dev_notice(kdev, "%s", FDO_BUG_MSG);
   116			shown_bug_once = true;
   117		}
   118	
   119		va_end(args);
   120	}
   121	
   122	#define i915_load_error(dev_priv, fmt, ...)				     \
 > 123		__i915_printk(dev_priv, i915_load_error_level, fmt, ##__VA_ARGS__)
   124	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot June 7, 2018, 6:11 p.m. UTC | #3
Hi Chris,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on v4.17 next-20180607]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Chris-Wilson/drm-i915-Mark-i915-inject_load_failure-as-being-hit/20180607-174849
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/i915/i915_drv.c:61:36: sparse: incorrect type in initializer (different base types) @@    expected int static [signed] [toplevel] i915_load_error_level @@    got evel] i915_load_error_level @@
   drivers/gpu/drm/i915/i915_drv.c:61:36:    expected int static [signed] [toplevel] i915_load_error_level
   drivers/gpu/drm/i915/i915_drv.c:61:36:    got char *<noident>
>> drivers/gpu/drm/i915/i915_drv.c:72:39: sparse: incorrect type in assignment (different base types) @@    expected int static [signed] [toplevel] i915_load_error_level @@    got evel] i915_load_error_level @@
   drivers/gpu/drm/i915/i915_drv.c:72:39:    expected int static [signed] [toplevel] i915_load_error_level
   drivers/gpu/drm/i915/i915_drv.c:72:39:    got char *<noident>
>> drivers/gpu/drm/i915/i915_drv.c:1425:9: sparse: incorrect type in argument 2 (different base types) @@    expected char const *level @@    got int static [signed]char const *level @@
   drivers/gpu/drm/i915/i915_drv.c:1425:9:    expected char const *level
   drivers/gpu/drm/i915/i915_drv.c:1425:9:    got int static [signed] [toplevel] i915_load_error_level
   In file included from include/linux/printk.h:7:0,
                    from include/linux/kernel.h:14,
                    from include/linux/list.h:9,
                    from include/linux/resource_ext.h:17,
                    from include/linux/acpi.h:26,
                    from drivers/gpu/drm/i915/i915_drv.c:30:
   include/linux/kern_levels.h:5:18: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
    #define KERN_SOH "001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
    #define KERN_ERR KERN_SOH "3" /* error conditions */
                     ^~~~~~~~
   drivers/gpu/drm/i915/i915_drv.c:61:36: note: in expansion of macro 'KERN_ERR'
    static int i915_load_error_level = KERN_ERR;
                                       ^~~~~~~~
   include/linux/kern_levels.h:5:18: error: initializer element is not computable at load time
    #define KERN_SOH "001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
    #define KERN_ERR KERN_SOH "3" /* error conditions */
                     ^~~~~~~~
   drivers/gpu/drm/i915/i915_drv.c:61:36: note: in expansion of macro 'KERN_ERR'
    static int i915_load_error_level = KERN_ERR;
                                       ^~~~~~~~
   drivers/gpu/drm/i915/i915_drv.c: In function '__i915_inject_load_failure':
   drivers/gpu/drm/i915/i915_drv.c:72:25: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
      i915_load_error_level = KERN_DEBUG;
                            ^
   drivers/gpu/drm/i915/i915_drv.c: In function 'i915_driver_load':
   drivers/gpu/drm/i915/i915_drv.c:123:26: warning: passing argument 2 of '__i915_printk' makes pointer from integer without a cast [-Wint-conversion]
     __i915_printk(dev_priv, i915_load_error_level, fmt, ##__VA_ARGS__)
                             ^
   drivers/gpu/drm/i915/i915_drv.c:1425:2: note: in expansion of macro 'i915_load_error'
     i915_load_error(dev_priv, "Device initialization failed (%d)n", ret);
     ^~~~~~~~~~~~~~~
   drivers/gpu/drm/i915/i915_drv.c:87:1: note: expected 'const char *' but argument is of type 'int'
    __i915_printk(struct drm_i915_private *dev_priv, const char *level,
    ^~~~~~~~~~~~~

vim +61 drivers/gpu/drm/i915/i915_drv.c

    58	
    59	#if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
    60	static unsigned int i915_load_fail_count;
  > 61	static int i915_load_error_level = KERN_ERR;
    62	
    63	bool __i915_inject_load_failure(const char *func, int line)
    64	{
    65		if (i915_load_fail_count >= i915_modparams.inject_load_failure)
    66			return false;
    67	
    68		if (++i915_load_fail_count == i915_modparams.inject_load_failure) {
    69			DRM_INFO("Injecting failure at checkpoint %u [%s:%d]\n",
    70				 i915_modparams.inject_load_failure, func, line);
    71			i915_modparams.inject_load_failure = 0;
  > 72			i915_load_error_level = KERN_DEBUG;
    73			return true;
    74		}
    75	
    76		return false;
    77	}
    78	#else
    79	#define i915_load_error_level KERN_ERR
    80	#endif
    81	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 6b599b1837dc..f7653e738e46 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -58,6 +58,7 @@  static struct drm_driver driver;
 
 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
 static unsigned int i915_load_fail_count;
+static int i915_load_error_level = KERN_ERR;
 
 bool __i915_inject_load_failure(const char *func, int line)
 {
@@ -67,11 +68,15 @@  bool __i915_inject_load_failure(const char *func, int line)
 	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);
+		i915_modparams.inject_load_failure = 0;
+		i915_load_error_level = KERN_DEBUG;
 		return true;
 	}
 
 	return false;
 }
+#else
+#define i915_load_error_level KERN_ERR
 #endif
 
 #define FDO_BUG_URL "https://bugs.freedesktop.org/enter_bug.cgi?product=DRI"
@@ -114,20 +119,8 @@  __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)
-{
-#if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
-	return i915_modparams.inject_load_failure &&
-	       i915_load_fail_count == i915_modparams.inject_load_failure;
-#else
-	return false;
-#endif
-}
-
 #define i915_load_error(dev_priv, fmt, ...)				     \
-	__i915_printk(dev_priv,						     \
-		      i915_error_injected(dev_priv) ? KERN_DEBUG : KERN_ERR, \
-		      fmt, ##__VA_ARGS__)
+	__i915_printk(dev_priv, i915_load_error_level, fmt, ##__VA_ARGS__)
 
 /* Map PCH device id to PCH type, or PCH_NONE if unknown. */
 static enum intel_pch