diff mbox

[1/2] drm/i915: introduce GEM_WARN_ON

Message ID 20161213160059.6646-1-matthew.auld@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Matthew Auld Dec. 13, 2016, 4 p.m. UTC
In a similar spirit to GEM_BUG_ON we now also have GEM_WARN_ON, with the
simple goal of expressing warnings which are truly insane, and so are
only really useful for CI where we have some abusive tests.

v2:
  - use BUILD_BUG_ON_INVALID for !DEBUG_GEM
  - clarify commit message

Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
---
 drivers/gpu/drm/i915/i915_gem.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Joonas Lahtinen Dec. 13, 2016, 4:25 p.m. UTC | #1
On ti, 2016-12-13 at 16:00 +0000, Matthew Auld wrote:
> In a similar spirit to GEM_BUG_ON we now also have GEM_WARN_ON, with the
> simple goal of expressing warnings which are truly insane, and so are
> only really useful for CI where we have some abusive tests.
> 
> v2:
>   - use BUILD_BUG_ON_INVALID for !DEBUG_GEM
>   - clarify commit message
> 
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>

<SNIP>

> +++ b/drivers/gpu/drm/i915/i915_gem.h
> @@ -27,8 +27,10 @@
>  
>  #ifdef CONFIG_DRM_I915_DEBUG_GEM
>  #define GEM_BUG_ON(expr) BUG_ON(expr)
> +#define GEM_WARN_ON(expr) WARN_ON(expr)
>  #else
>  #define GEM_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
> +#define GEM_WARN_ON(expr) (BUILD_BUG_ON_INVALID(expr), 0)

+#define GEM_WARN_ON(expr) GEM_BUG_ON(expr)

Should be enough in the #else branch just like in linux/mmdebug.h

Regards, joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
Matthew Auld Dec. 13, 2016, 4:52 p.m. UTC | #2
On 13 December 2016 at 16:25, Joonas Lahtinen
<joonas.lahtinen@linux.intel.com> wrote:
> On ti, 2016-12-13 at 16:00 +0000, Matthew Auld wrote:
>> In a similar spirit to GEM_BUG_ON we now also have GEM_WARN_ON, with the
>> simple goal of expressing warnings which are truly insane, and so are
>> only really useful for CI where we have some abusive tests.
>>
>> v2:
>>   - use BUILD_BUG_ON_INVALID for !DEBUG_GEM
>>   - clarify commit message
>>
>> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>> Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
>> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
>
> <SNIP>
>
>> +++ b/drivers/gpu/drm/i915/i915_gem.h
>> @@ -27,8 +27,10 @@
>>
>>  #ifdef CONFIG_DRM_I915_DEBUG_GEM
>>  #define GEM_BUG_ON(expr) BUG_ON(expr)
>> +#define GEM_WARN_ON(expr) WARN_ON(expr)
>>  #else
>>  #define GEM_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
>> +#define GEM_WARN_ON(expr) (BUILD_BUG_ON_INVALID(expr), 0)
>
> +#define GEM_WARN_ON(expr) GEM_BUG_ON(expr)
>
> Should be enough in the #else branch just like in linux/mmdebug.h
BUILD_BUG_INVALID(expr) will do a (void) cast to discard the result of
the sizeof operation, but then we don't end up ignoring said result if
we use it in the context of an if condition, which will make the
compiler very unhappy.
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.h b/drivers/gpu/drm/i915/i915_gem.h
index 8801a14a78a2..a585d47c420a 100644
--- a/drivers/gpu/drm/i915/i915_gem.h
+++ b/drivers/gpu/drm/i915/i915_gem.h
@@ -27,8 +27,10 @@ 
 
 #ifdef CONFIG_DRM_I915_DEBUG_GEM
 #define GEM_BUG_ON(expr) BUG_ON(expr)
+#define GEM_WARN_ON(expr) WARN_ON(expr)
 #else
 #define GEM_BUG_ON(expr) BUILD_BUG_ON_INVALID(expr)
+#define GEM_WARN_ON(expr) (BUILD_BUG_ON_INVALID(expr), 0)
 #endif
 
 #define I915_NUM_ENGINES 5