drm/i915: Assert that created vma has a whole number of pages
authorChris Wilson <[email protected]>
Thu, 19 Jan 2017 19:26:59 +0000 (19:26 +0000)
committerChris Wilson <[email protected]>
Sat, 21 Jan 2017 10:32:32 +0000 (10:32 +0000)
VMA (and their objects) are supposed to composed of whole pages. Add an
assert to catch any invalid construct when we create the VMA.

Signed-off-by: Chris Wilson <[email protected]>
Cc: Mika Kuoppala <[email protected]>
Reviewed-by: Mika Kuoppala <[email protected]>
Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
Reviewed-by: Joonas Lahtinen <[email protected]>
drivers/gpu/drm/i915/i915_vma.c

index ecb495b1c5d3a9b5f9d8a0fda66d4b8e6cc7cd90..559966dc3d356d70bc0a456e2ae9d972736d4f1e 100644 (file)
@@ -110,6 +110,8 @@ vma_create(struct drm_i915_gem_object *obj,
        if (unlikely(vma->size > vm->total))
                goto err_vma;
 
+       GEM_BUG_ON(!IS_ALIGNED(vma->size, I915_GTT_PAGE_SIZE));
+
        if (i915_is_ggtt(vm)) {
                if (unlikely(overflows_type(vma->size, u32)))
                        goto err_vma;