[PATCH 1/2] drm: Add DRM_ERROR_ON replacement for WARN_ON

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



i915 has a habit of using WARN_ON and spewing stacktraces into the
kernel logs and beyond. For the majority of cases, we do not care about
the stacktrace, we know precisely where and when the error occurs so
hunting down the exact instance is not a concern, we only need the
content of the error.

Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
---
 include/drm/drmP.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 4717449d6aa9..b76af322d812 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -164,6 +164,23 @@ void drm_err(const char *format, ...);
 	drm_err(fmt, ##__VA_ARGS__)
 
 /**
+ * Assertion-esque error output.
+ *
+ * \param cond condition on which to *fail*
+ * \param fmt printf() like format string.
+ * \param arg arguments
+ *
+ * This is similar to WARN_ON but only prints a DRM_ERROR rather than a whole
+ * stacktrace.
+ */
+#define DRM_ERROR_ON(cond, fmt, ...) ({					\
+	bool __cond = !!(cond);						\
+	if (unlikely(__cond))						\
+		drm_err("assertion failed, %s: " fmt, #cond, ##__VA_ARGS__); \
+	unlikely(__cond);						\
+})
+
+/**
  * Rate limited error output.  Like DRM_ERROR() but won't flood the log.
  *
  * \param fmt printf() like format string.
-- 
2.4.6

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux