summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915/i915_utils.h
diff options
context:
space:
mode:
authorJani Nikula <jani.nikula@intel.com>2019-08-08 16:42:43 +0300
committerJani Nikula <jani.nikula@intel.com>2019-08-09 11:51:58 +0300
commit358c855cb60a27a2e91e002604d2c9ed03bdcb96 (patch)
treeaba3fadf98af883b221b1f91c93b3f0292e91777 /drivers/gpu/drm/i915/i915_utils.h
parent0a2ecbe5a9a8169375fe7fb6a0453aef94ece464 (diff)
downloadlinux-358c855cb60a27a2e91e002604d2c9ed03bdcb96.tar.xz
drm/i915: move printing and load error inject to i915_utils.[ch]
Seems like a better fit. Reduce clutter in i915_drv.[ch]. Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Jani Nikula <jani.nikula@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/bc458fa5e62fc8dae46216666f64ed6976fafaee.1565271681.git.jani.nikula@intel.com
Diffstat (limited to 'drivers/gpu/drm/i915/i915_utils.h')
-rw-r--r--drivers/gpu/drm/i915/i915_utils.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_utils.h b/drivers/gpu/drm/i915/i915_utils.h
index 0c0fda36334d..d652ba5d2320 100644
--- a/drivers/gpu/drm/i915/i915_utils.h
+++ b/drivers/gpu/drm/i915/i915_utils.h
@@ -31,6 +31,8 @@
#include <linux/types.h>
#include <linux/workqueue.h>
+struct drm_i915_private;
+
#undef WARN_ON
/* Many gcc seem to no see through this and fall over :( */
#if 0
@@ -49,6 +51,34 @@
#define MISSING_CASE(x) WARN(1, "Missing case (%s == %ld)\n", \
__stringify(x), (long)(x))
+void __printf(3, 4)
+__i915_printk(struct drm_i915_private *dev_priv, const char *level,
+ const char *fmt, ...);
+
+#define i915_report_error(dev_priv, fmt, ...) \
+ __i915_printk(dev_priv, KERN_ERR, fmt, ##__VA_ARGS__)
+
+#if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
+
+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_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__)
+
#if defined(GCC_VERSION) && GCC_VERSION >= 70000
#define add_overflows_t(T, A, B) \
__builtin_add_overflow_p((A), (B), (T)0)