diff mbox

[CI,2/2] drm/i915: Print the condition causing GEM_BUG_ON

Message ID 20171031112254.881-2-mika.kuoppala@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mika Kuoppala Oct. 31, 2017, 11:22 a.m. UTC
It is easier to categorize and debug bugs if the failed condition
is in plain sight in the actual dmesg output. Make it so.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Chris Wilson Oct. 31, 2017, 12:40 p.m. UTC | #1
Quoting Mika Kuoppala (2017-10-31 11:22:54)
> It is easier to categorize and debug bugs if the failed condition
> is in plain sight in the actual dmesg output. Make it so.
> 
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem.h b/drivers/gpu/drm/i915/i915_gem.h
> index ee54597465b6..84ba68e83df5 100644
> --- a/drivers/gpu/drm/i915/i915_gem.h
> +++ b/drivers/gpu/drm/i915/i915_gem.h
> @@ -28,7 +28,11 @@
>  #include <linux/bug.h>
>  
>  #ifdef CONFIG_DRM_I915_DEBUG_GEM
> -#define GEM_BUG_ON(expr) BUG_ON(expr)
> +#define GEM_BUG_ON(condition) do { if (unlikely((condition))) {        \
> +               printk(KERN_ERR "GEM_BUG_ON(%s)\n", __stringify(condition)); \
> +               BUG(); \
> +               } \
> +       } while(0)

I'm thinking the ones we actually hit, we should spend the time in
writing up better debug output (i.e. GEM_BUG(expr, fmt, ...));

GEM_BUG_ON(expr) would become GEM_BUG(expr, __stringify(expr));
That shall be the next task.
-Chris
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.h b/drivers/gpu/drm/i915/i915_gem.h
index ee54597465b6..84ba68e83df5 100644
--- a/drivers/gpu/drm/i915/i915_gem.h
+++ b/drivers/gpu/drm/i915/i915_gem.h
@@ -28,7 +28,11 @@ 
 #include <linux/bug.h>
 
 #ifdef CONFIG_DRM_I915_DEBUG_GEM
-#define GEM_BUG_ON(expr) BUG_ON(expr)
+#define GEM_BUG_ON(condition) do { if (unlikely((condition))) {	\
+		printk(KERN_ERR "GEM_BUG_ON(%s)\n", __stringify(condition)); \
+		BUG(); \
+		} \
+	} while(0)
 #define GEM_WARN_ON(expr) WARN_ON(expr)
 
 #define GEM_DEBUG_DECL(var) var