drm/i915: introduce GEM_WARN_ON
Subsystems (2)
PATCH 1/2 drm/i915: introduce GEM_WARN_ON
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
--- drivers/gpu/drm/i915/i915_gem.h | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_gem.h +2 -0
@@ -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
Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 drm/i915: move vma sanity checking into i915_vma_bind
If we move the sanity checking from gen8_alloc_va_range_3lvl and gen6_alloc_va_range into i915_vma_bind, we will increase our coverage to now both callbacks. We also convert each WARN_ON over to a GEM_WARN_ON.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 12 ------------ drivers/gpu/drm/i915/i915_vma.c | 6 ++++++ 2 files changed, 6 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +0 -12
@@ -1303,15 +1303,6 @@ static int gen8_alloc_va_range_3lvl(struct i915_address_space *vm,uint32_t pdpes =I915_PDPES_PER_PDP (dev_priv);int ret; -/* Wrap is never okay since we can only represent 48b, and we don't -* actually use the other side of the canonical address space. -*/ -if (WARN_ON (start + length < start)) -return -ENODEV ; - -if (WARN_ON (start + length > vm->total)) -return -ENODEV ; - ret =alloc_gen8_temp_bitmaps (&new_page_dirs, &new_page_tables, pdpes);if (ret)return ret;
@@ -1929,9 +1920,6 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,uint32_t pde;int ret; -if (WARN_ON (start_in + length_in > ppgtt->base.total)) -return -ENODEV ; - start = start_save = start_in; length = length_save = length_in;
drivers/gpu/drm/i915/i915_vma.c +6 -0
@@ -176,6 +176,12 @@ int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,if (bind_flags ==0 )return 0 ; +if (GEM_WARN_ON (vma->node.start + vma->node.size < vma->node.start)) +return -ENODEV ; + +if (GEM_WARN_ON (vma->node.start + vma->node.size > vma->vm->total)) +return -ENODEV ; +if (vma_flags ==0 && vma->vm->allocate_va_range) {trace_i915_va_alloc (vma); ret = vma->vm->allocate_va_range(vma->vm,
Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2] drm/i915: move vma sanity checking into i915_vma_bind
Quoted 48 lines · Matthew Auld
If we move the sanity checking from
gen8_alloc_va_range_3lvlandgen6_alloc_va_rangeintoi915_vma_bind, we will increase our coverage to now both callbacks. We also convert eachWARN_ONover to aGEM_WARN_ON.Cc Joonas Lahtinen <[email protected]>Cc Chris Wilson <[email protected]>Suggested-by Chris Wilson <[email protected]>Signed-off-by Matthew Auld <[email protected]>--- drivers/gpu/drm/i915/i915_gem_gtt.c | 12 ------------ drivers/gpu/drm/i915/i915_vma.c | 6 ++++++ 2 files changed, 6 insertions(+), 12 deletions(-)drivers/gpu/drm/i915/i915_gem_gtt.c +0
-12@@ -1303,15 +1303,6 @@ static int gen8_alloc_va_range_3lvl(struct i915_address_space *vm,uint32_t pdpes =I915_PDPES_PER_PDP (dev_priv);int ret; -/* Wrap is never okay since we can only represent 48b, and we don't -* actually use the other side of the canonical address space. -*/ -if (WARN_ON (start + length < start)) -return -ENODEV ; - -if (WARN_ON (start + length > vm->total)) -return -ENODEV ; - ret =alloc_gen8_temp_bitmaps (&new_page_dirs, &new_page_tables, pdpes);if (ret)return ret;@@ -1929,9 +1920,6 @@ static int gen6_alloc_va_range(struct i915_address_space *vm,uint32_t pde;int ret; -if (WARN_ON (start_in + length_in > ppgtt->base.total)) -return -ENODEV ; - start = start_save = start_in; length = length_save = length_in;drivers/gpu/drm/i915/i915_vma.c +0
-0
drivers/gpu/drm/i915/i915_vma.c int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level, · line 177
Quoted 2 lines
drivers/gpu/drm/i915/i915_vma.c +0
-0@@ -176,6 +176,12 @@ int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,if (bind_flags ==0 )return 0 ;
#define range_overfows(start, size, max) ({
typeof(start) start__ = (start);
typeof(size) size__ = (size);
typeof(max) max__ = (max);
(void)(&start__ == &size__);
(void)(&start__ == &max__);
start > max || size > max - start;
})if (GEM_WARN_ON(range_overflows(vma->node.start,
vma->node.size,
vma->vm->total))
return -ENODEV;Then look at pread/pwrite for where we can reuse range_overflows(), e.g. if (range_overflows(args->offset, args->size, obj->base.size)) {
Might need a range_overflows_t();
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Joonas Lahtinen
maintainerQuoted 12 lines · Matthew Auld
In a similar spirit to
GEM_BUG_ONwe now also haveGEM_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:
- useBUILD_BUG_ON_INVALIDfor !DEBUG_GEM
- clarify commit messageCc Joonas Lahtinen <[email protected]>Cc Chris Wilson <[email protected]>Suggested-by Chris Wilson <[email protected]>Signed-off-by Matthew Auld <[email protected]>
<SNIP>
Quoted 9 lines
+++
b/drivers/gpu/drm/i915/i915_gem.h(quoted diff) +0
-0@@ -27,8 +27,10 @@
#ifdefCONFIG_DRM_I915_DEBUG_GEM
#defineGEM_BUG_ON(expr)BUG_ON(expr)
+#defineGEM_WARN_ON(expr)WARN_ON(expr)
#else
#defineGEM_BUG_ON(expr)BUILD_BUG_ON_INVALID(expr)+#defineGEM_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
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 28 lines · Joonas Lahtinen
Quoted 12 lines · Matthew Auld
In a similar spirit to
GEM_BUG_ONwe now also haveGEM_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:
- useBUILD_BUG_ON_INVALIDfor !DEBUG_GEM
- clarify commit messageCc Joonas Lahtinen <[email protected]>Cc Chris Wilson <[email protected]>Suggested-by Chris Wilson <[email protected]>Signed-off-by Matthew Auld <[email protected]><SNIP>
drivers/gpu/drm/i915/i915_gem.h line 33
Quoted 9 lines
+++
b/drivers/gpu/drm/i915/i915_gem.hdrivers/gpu/drm/i915/i915_gem.h +2
-0@@ -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)
Quoted 1 line
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.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915: introduce GEM_WARN_ON
In reply to Matthew Auld== Series Details ==
== Series Details ==
Series: series starting with [1/2] drm/i915: introduce GEM_WARN_ON
URL : https://patchwork.freedesktop.org/series/16750/
State : success
== Summary ==
Series 16750v1 Series without cover letter
https://patchwork.freedesktop.org/api/1.0/series/16750/revisions/1/mbox/
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-b:
incomplete -> PASS (fi-snb-2600)fi-bdw-5557u total:247 pass:233 dwarn:0 dfail:0 fail:0 skip:14 fi-bsw-n3050 total:247 pass:208 dwarn:0 dfail:0 fail:0 skip:39 fi-bxt-t5700 total:247 pass:220 dwarn:0 dfail:0 fail:0 skip:27 fi-byt-j1900 total:247 pass:220 dwarn:0 dfail:0 fail:0 skip:27 fi-byt-n2820 total:247 pass:216 dwarn:0 dfail:0 fail:0 skip:31 fi-hsw-4770 total:247 pass:228 dwarn:0 dfail:0 fail:0 skip:19 fi-hsw-4770r total:247 pass:228 dwarn:0 dfail:0 fail:0 skip:19 fi-ilk-650 total:247 pass:195 dwarn:0 dfail:0 fail:0 skip:52 fi-ivb-3520m total:247 pass:226 dwarn:0 dfail:0 fail:0 skip:21 fi-ivb-3770 total:247 pass:226 dwarn:0 dfail:0 fail:0 skip:21 fi-kbl-7500u total:247 pass:226 dwarn:0 dfail:0 fail:0 skip:21 fi-skl-6260u total:247 pass:234 dwarn:0 dfail:0 fail:0 skip:13 fi-skl-6700hq total:247 pass:227 dwarn:0 dfail:0 fail:0 skip:20 fi-skl-6700k total:247 pass:224 dwarn:3 dfail:0 fail:0 skip:20 fi-skl-6770hq total:247 pass:234 dwarn:0 dfail:0 fail:0 skip:13 fi-snb-2520m total:247 pass:216 dwarn:0 dfail:0 fail:0 skip:31 fi-snb-2600 total:247 pass:215 dwarn:0 dfail:0 fail:0 skip:32
c596a6521837b06a740e894030d11024f391bd6e drm-tip: 2016y-12m-13d-15h-48m-22s UTC integration manifest 622d9a7 drm/i915: move vma sanity checking into i915_vma_bind
1a6db28 drm/i915: introduce GEM_WARN_ON
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3278/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx